|
|
|
|
@@ -16,19 +16,12 @@ vim.o.cursorline = true -- Highlight current line
|
|
|
|
|
vim.o.winborder = "single" -- Borders around popups like when you press leader for keybinds
|
|
|
|
|
vim.opt.signcolumn =
|
|
|
|
|
'yes' -- TEST: Prohibit layout shifting by always showing the sign column (left of line numbers), you should see an icon there on this row.
|
|
|
|
|
vim.o.autocomplete = true -- Turn on builtin autocomplete
|
|
|
|
|
vim.o.complete = "o,.,w,b,u" -- Indicates what kind of items to show in the autocomplete
|
|
|
|
|
vim.o.completeopt = "fuzzy,menuone,noselect,popup" -- Options for autocomplete
|
|
|
|
|
vim.o.pumheight = 7 -- Max items to show in autocomplete
|
|
|
|
|
vim.o.pummaxwidth = 80 -- Max width of autocomplete
|
|
|
|
|
vim.o.updatetime = 250
|
|
|
|
|
vim.o.timeoutlen = 300
|
|
|
|
|
|
|
|
|
|
vim.o.updatetime = 250 -- Speed up the CursorHold autocmd event
|
|
|
|
|
vim.o.timeoutlen = 300 -- Speed up completion of key event
|
|
|
|
|
-- SECTION: Globals
|
|
|
|
|
vim.g.mapleader = ' ' -- Mapping leader to space.
|
|
|
|
|
vim.g.maplocalleader = ' ' -- Mapping leader to space.
|
|
|
|
|
vim.g.have_nerd_font = true -- Enable nerd font
|
|
|
|
|
|
|
|
|
|
-- SECTION: Lazy settings
|
|
|
|
|
-- INFO: Lines in this function will be executed after main event loop is free, prohibiting startup lag.
|
|
|
|
|
vim.schedule(function()
|
|
|
|
|
@@ -50,18 +43,32 @@ vim.keymap.set('n', '<Esc>', '<cmd>nohlsearch<CR>')
|
|
|
|
|
vim.keymap.set('n', '<leader>f', vim.lsp.buf.format, { desc = "Format buffer" })
|
|
|
|
|
|
|
|
|
|
-- Start the file picker in different modes
|
|
|
|
|
vim.keymap.set('n', '<leader>sf', ":Pick files<CR>", { desc = "Search files" })
|
|
|
|
|
vim.keymap.set('n', '<leader>sg', ":Pick grep_live<CR>", { desc = "Search files" })
|
|
|
|
|
vim.keymap.set('n', '<leader>sf', function()
|
|
|
|
|
require('mini.pick').builtin.files()
|
|
|
|
|
end, { desc = "Search files" })
|
|
|
|
|
vim.keymap.set('n', '<leader>sg', ":Pick grep_live<CR>", { desc = "Search file contents" })
|
|
|
|
|
vim.keymap.set('n', '<leader>sh', ":Pick help<CR>", { desc = "Search help pages" })
|
|
|
|
|
vim.keymap.set('n', '<leader>sr', ":Pick resume<CR>", { desc = "Resume last search" })
|
|
|
|
|
vim.keymap.set('n', '<leader>sb', ":Pick buffers<CR>", { desc = "Search buffers" })
|
|
|
|
|
|
|
|
|
|
-- Get help with keybinds
|
|
|
|
|
vim.keymap.set('n', '<leader>?', ":WhichKey<CR>", { desc = "Show keybinds" })
|
|
|
|
|
|
|
|
|
|
-- File explorer
|
|
|
|
|
vim.keymap.set('n', '\\', ":Oil --float<CR>", { desc = "File explorer" })
|
|
|
|
|
|
|
|
|
|
-- SECTION: Install packages
|
|
|
|
|
vim.pack.add({
|
|
|
|
|
'https://github.com/catppuccin/nvim', -- color scheme
|
|
|
|
|
'https://github.com/nvim-mini/mini.pick', -- File picker, grep
|
|
|
|
|
'https://github.com/nvim-mini/mini.pairs', -- Auto create {}, (), [] - pairs etc.
|
|
|
|
|
'https://github.com/nvim-mini/mini.notify', -- Popup notifications
|
|
|
|
|
'https://github.com/nvim-mini/mini.completion', -- Autocomplete, needs snippets and icons
|
|
|
|
|
'https://github.com/nvim-mini/mini.snippets', -- Snippets
|
|
|
|
|
'https://github.com/nvim-mini/mini.icons', -- Icons
|
|
|
|
|
'https://github.com/nvim-mini/mini.cursorword', -- Highlight word under cursor
|
|
|
|
|
'https://github.com/nvim-mini/mini.hipatterns', -- Highlight todos and rgb colors
|
|
|
|
|
'https://github.com/nvim-mini/mini.statusline', -- Statusline at the bottom
|
|
|
|
|
'https://github.com/neovim/nvim-lspconfig', -- Language servers
|
|
|
|
|
'https://github.com/mason-org/mason.nvim', -- LSP deps installer
|
|
|
|
|
'https://github.com/mason-org/mason-lspconfig.nvim', -- Lets you install mason tooling using lsp names
|
|
|
|
|
@@ -69,9 +76,8 @@ vim.pack.add({
|
|
|
|
|
'https://github.com/folke/lazydev.nvim', -- Automatically resolve vim api paths.
|
|
|
|
|
'https://github.com/folke/which-key.nvim', -- Shortcut hints (bar at the bottom when pressing space)
|
|
|
|
|
'https://github.com/nvim-lua/plenary.nvim', -- Helper lua functions, dep of todo-comments.
|
|
|
|
|
'https://github.com/folke/todo-comments.nvim', -- Helper lua functions, dep of todo-comments.
|
|
|
|
|
'https://github.com/nvim-treesitter/nvim-treesitter',
|
|
|
|
|
|
|
|
|
|
'https://github.com/nvim-treesitter/nvim-treesitter', -- Syntax highlighting
|
|
|
|
|
'https://github.com/stevearc/oil.nvim', -- File explorer
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- SECTION: Colorscheme
|
|
|
|
|
@@ -89,19 +95,40 @@ wk.add({
|
|
|
|
|
{ '<leader>o', group = 'Source current file', mode = { 'n' } },
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
require('todo-comments').setup({
|
|
|
|
|
keywords = {
|
|
|
|
|
SECTION = {
|
|
|
|
|
icon = " ",
|
|
|
|
|
color = "hint",
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- require('todo-comments').setup({
|
|
|
|
|
-- keywords = {
|
|
|
|
|
-- SECTION = {
|
|
|
|
|
-- icon = " ",
|
|
|
|
|
-- color = "hint",
|
|
|
|
|
-- }
|
|
|
|
|
-- }
|
|
|
|
|
-- })
|
|
|
|
|
|
|
|
|
|
-- Mini
|
|
|
|
|
require('mini.pick').setup()
|
|
|
|
|
local MiniPicker = require('mini.pick').setup({
|
|
|
|
|
source = {
|
|
|
|
|
show = require('mini.pick').default_show,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
require('mini.pairs').setup()
|
|
|
|
|
require('mini.notify').setup()
|
|
|
|
|
require('mini.icons').setup()
|
|
|
|
|
MiniIcons.tweak_lsp_kind()
|
|
|
|
|
require('mini.snippets').setup()
|
|
|
|
|
require('mini.completion').setup()
|
|
|
|
|
require('mini.cursorword').setup()
|
|
|
|
|
require('mini.hipatterns').setup({
|
|
|
|
|
highlighters = {
|
|
|
|
|
todo = { pattern = '%f[%w]()TODO()%f[%W]', group = 'MiniHipatternsTodo' },
|
|
|
|
|
section = { pattern = '%f[%w]()SECTION()%f[%W]', group = 'MiniHipatternsNote' },
|
|
|
|
|
warning = { pattern = '%f[%w]()WARNING()%f[%W]', group = 'MiniHipatternsHack' },
|
|
|
|
|
error = { pattern = '%f[%w]()ERROR()%f[%W]', group = 'MiniHipatternsTodo' },
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
require('mini.statusline').setup()
|
|
|
|
|
require('oil').setup()
|
|
|
|
|
|
|
|
|
|
require('nvim-treesitter').setup({
|
|
|
|
|
auto_install = true
|
|
|
|
|
@@ -111,7 +138,12 @@ require('nvim-treesitter').setup({
|
|
|
|
|
require("mason").setup()
|
|
|
|
|
require("mason-lspconfig").setup({
|
|
|
|
|
-- Install lsp deps here
|
|
|
|
|
ensure_installed = { 'lua_ls' },
|
|
|
|
|
ensure_installed = {
|
|
|
|
|
'lua_ls',
|
|
|
|
|
'ts_ls',
|
|
|
|
|
'ansiblels',
|
|
|
|
|
'eslint'
|
|
|
|
|
},
|
|
|
|
|
automatic_enable = true
|
|
|
|
|
})
|
|
|
|
|
require("mason-tool-installer").setup({
|
|
|
|
|
@@ -122,20 +154,7 @@ require("mason-tool-installer").setup({
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- SECTION: Autocommands
|
|
|
|
|
vim.api.nvim_create_autocmd('TextYankPost', {
|
|
|
|
|
desc = 'Highlight when yanking (copying) text',
|
|
|
|
|
group = vim.api.nvim_create_augroup('highlight-yank', { clear = true }),
|
|
|
|
|
callback = function()
|
|
|
|
|
vim.highlight.on_yank()
|
|
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
-- Actions on LspAttach
|
|
|
|
|
vim.api.nvim_create_autocmd('LspAttach', {
|
|
|
|
|
group = vim.api.nvim_create_augroup('my.lsp', {}),
|
|
|
|
|
callback = function(ev)
|
|
|
|
|
-- INFO: Helpers
|
|
|
|
|
-- SECTION: Helpers
|
|
|
|
|
local function client_supports_method(client, method, bufnr)
|
|
|
|
|
if vim.fn.has 'nvim-0.11' == 1 then
|
|
|
|
|
return client:supports_method(method, bufnr)
|
|
|
|
|
@@ -144,12 +163,20 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- SECTION: Autocommands
|
|
|
|
|
vim.api.nvim_create_autocmd('TextYankPost', {
|
|
|
|
|
desc = 'Highlight when yanking (copying) text',
|
|
|
|
|
group = vim.api.nvim_create_augroup('highlight-yank', { clear = true }),
|
|
|
|
|
callback = function()
|
|
|
|
|
vim.highlight.on_yank()
|
|
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
-- Actions on LspAttach
|
|
|
|
|
vim.api.nvim_create_autocmd('LspAttach', {
|
|
|
|
|
group = vim.api.nvim_create_augroup('my.lsp', {}),
|
|
|
|
|
callback = function(ev)
|
|
|
|
|
local client = assert(vim.lsp.get_client_by_id(ev.data.client_id))
|
|
|
|
|
|
|
|
|
|
-- Enable auto-completion
|
|
|
|
|
if client:supports_method('textDocument/completion') then
|
|
|
|
|
vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true })
|
|
|
|
|
end
|
|
|
|
|
-- Auto-format ("lint") on save.
|
|
|
|
|
-- Usually not needed if server supports "textDocument/willSaveWaitUntil".
|
|
|
|
|
if not client:supports_method('textDocument/willSaveWaitUntil')
|
|
|
|
|
@@ -163,30 +190,6 @@ vim.api.nvim_create_autocmd('LspAttach', {
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Highlight the word you are standing on after a little while
|
|
|
|
|
if client and client_supports_method(client, vim.lsp.protocol.Methods.textDocument_documentHighlight, ev.buf) then
|
|
|
|
|
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
|
|
|
|
|
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
|
|
|
|
|
buffer = ev.buf,
|
|
|
|
|
group = highlight_augroup,
|
|
|
|
|
callback = vim.lsp.buf.document_highlight,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
|
|
|
|
|
buffer = ev.buf,
|
|
|
|
|
group = highlight_augroup,
|
|
|
|
|
callback = vim.lsp.buf.clear_references,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd('LspDetach', {
|
|
|
|
|
group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }),
|
|
|
|
|
callback = function(event2)
|
|
|
|
|
vim.lsp.buf.clear_references()
|
|
|
|
|
vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf }
|
|
|
|
|
end,
|
|
|
|
|
})
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- Swap out the icons in the leftmost column and show inlay hints
|
|
|
|
|
vim.diagnostic.config {
|
|
|
|
|
severity_sort = true,
|
|
|
|
|
|