|
|
@ -113,7 +113,7 @@ vim.opt.splitbelow = true
|
|
|
|
-- See `:help 'list'`
|
|
|
|
-- See `:help 'list'`
|
|
|
|
-- and `:help 'listchars'`
|
|
|
|
-- and `:help 'listchars'`
|
|
|
|
vim.opt.list = true
|
|
|
|
vim.opt.list = true
|
|
|
|
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '␣' }
|
|
|
|
vim.opt.listchars = { tab = '» ', trail = '~', nbsp = '␣', extends = '>', precedes = '<', space = '·' }
|
|
|
|
|
|
|
|
|
|
|
|
-- Preview substitutions live, as you type!
|
|
|
|
-- Preview substitutions live, as you type!
|
|
|
|
vim.opt.inccommand = 'split'
|
|
|
|
vim.opt.inccommand = 'split'
|
|
|
@ -254,18 +254,55 @@ require('lazy').setup({
|
|
|
|
{ -- Useful plugin to show you pending keybinds.
|
|
|
|
{ -- Useful plugin to show you pending keybinds.
|
|
|
|
'folke/which-key.nvim',
|
|
|
|
'folke/which-key.nvim',
|
|
|
|
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
|
|
|
|
event = 'VimEnter', -- Sets the loading event to 'VimEnter'
|
|
|
|
config = function() -- This is the function that runs, AFTER loading
|
|
|
|
opts = {
|
|
|
|
require('which-key').setup()
|
|
|
|
icons = {
|
|
|
|
|
|
|
|
-- set icon mappings to true if you have a Nerd Font
|
|
|
|
|
|
|
|
mappings = vim.g.have_nerd_font,
|
|
|
|
|
|
|
|
-- If you are using a Nerd Font: set icons.keys to an empty table which will use the
|
|
|
|
|
|
|
|
-- default whick-key.nvim defined Nerd Font icons, otherwise define a string table
|
|
|
|
|
|
|
|
keys = vim.g.have_nerd_font and {} or {
|
|
|
|
|
|
|
|
Up = '<Up> ',
|
|
|
|
|
|
|
|
Down = '<Down> ',
|
|
|
|
|
|
|
|
Left = '<Left> ',
|
|
|
|
|
|
|
|
Right = '<Right> ',
|
|
|
|
|
|
|
|
C = '<C-…> ',
|
|
|
|
|
|
|
|
M = '<M-…> ',
|
|
|
|
|
|
|
|
D = '<D-…> ',
|
|
|
|
|
|
|
|
S = '<S-…> ',
|
|
|
|
|
|
|
|
CR = '<CR> ',
|
|
|
|
|
|
|
|
Esc = '<Esc> ',
|
|
|
|
|
|
|
|
ScrollWheelDown = '<ScrollWheelDown> ',
|
|
|
|
|
|
|
|
ScrollWheelUp = '<ScrollWheelUp> ',
|
|
|
|
|
|
|
|
NL = '<NL> ',
|
|
|
|
|
|
|
|
BS = '<BS> ',
|
|
|
|
|
|
|
|
Space = '<Space> ',
|
|
|
|
|
|
|
|
Tab = '<Tab> ',
|
|
|
|
|
|
|
|
F1 = '<F1>',
|
|
|
|
|
|
|
|
F2 = '<F2>',
|
|
|
|
|
|
|
|
F3 = '<F3>',
|
|
|
|
|
|
|
|
F4 = '<F4>',
|
|
|
|
|
|
|
|
F5 = '<F5>',
|
|
|
|
|
|
|
|
F6 = '<F6>',
|
|
|
|
|
|
|
|
F7 = '<F7>',
|
|
|
|
|
|
|
|
F8 = '<F8>',
|
|
|
|
|
|
|
|
F9 = '<F9>',
|
|
|
|
|
|
|
|
F10 = '<F10>',
|
|
|
|
|
|
|
|
F11 = '<F11>',
|
|
|
|
|
|
|
|
F12 = '<F12>',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
-- Document existing key chains
|
|
|
|
-- Document existing key chains
|
|
|
|
require('which-key').register {
|
|
|
|
spec = {
|
|
|
|
['<leader>c'] = { name = '[C]ode', _ = 'which_key_ignore' },
|
|
|
|
{ '<leader>c', group = '[C]ode', mode = { 'n', 'x' } },
|
|
|
|
['<leader>d'] = { name = '[D]ocument', _ = 'which_key_ignore' },
|
|
|
|
{ '<leader>d', group = '[D]ocument' },
|
|
|
|
['<leader>r'] = { name = '[R]ename', _ = 'which_key_ignore' },
|
|
|
|
{ '<leader>r', group = '[R]ename' },
|
|
|
|
['<leader>s'] = { name = '[S]earch', _ = 'which_key_ignore' },
|
|
|
|
{ '<leader>s', group = '[S]earch' },
|
|
|
|
['<leader>w'] = { name = '[W]orkspace', _ = 'which_key_ignore' },
|
|
|
|
{ '<leader>w', group = '[W]orkspace' },
|
|
|
|
}
|
|
|
|
{ '<leader>t', group = '[T]oggle' },
|
|
|
|
end,
|
|
|
|
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
-- NOTE: Plugins can specify dependencies.
|
|
|
|
-- NOTE: Plugins can specify dependencies.
|
|
|
@ -391,6 +428,8 @@ require('lazy').setup({
|
|
|
|
-- Useful status updates for LSP.
|
|
|
|
-- Useful status updates for LSP.
|
|
|
|
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
|
|
|
-- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})`
|
|
|
|
{ 'j-hui/fidget.nvim', opts = {} },
|
|
|
|
{ 'j-hui/fidget.nvim', opts = {} },
|
|
|
|
|
|
|
|
-- Allows extra capabilities provided by nvim-cmp
|
|
|
|
|
|
|
|
'hrsh7th/cmp-nvim-lsp',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
config = function()
|
|
|
|
config = function()
|
|
|
|
-- Brief Aside: **What is LSP?**
|
|
|
|
-- Brief Aside: **What is LSP?**
|
|
|
@ -481,17 +520,29 @@ require('lazy').setup({
|
|
|
|
-- See `:help CursorHold` for information about when this is executed
|
|
|
|
-- See `:help CursorHold` for information about when this is executed
|
|
|
|
--
|
|
|
|
--
|
|
|
|
-- When you move your cursor, the highlights will be cleared (the second autocommand).
|
|
|
|
-- When you move your cursor, the highlights will be cleared (the second autocommand).
|
|
|
|
|
|
|
|
--
|
|
|
|
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
|
|
|
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
|
|
|
if client and client.server_capabilities.documentHighlightProvider then
|
|
|
|
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
|
|
|
|
|
|
|
|
local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false })
|
|
|
|
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
|
|
|
|
vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, {
|
|
|
|
buffer = event.buf,
|
|
|
|
buffer = event.buf,
|
|
|
|
|
|
|
|
group = highlight_augroup,
|
|
|
|
callback = vim.lsp.buf.document_highlight,
|
|
|
|
callback = vim.lsp.buf.document_highlight,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
|
|
|
|
vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, {
|
|
|
|
buffer = event.buf,
|
|
|
|
buffer = event.buf,
|
|
|
|
|
|
|
|
group = highlight_augroup,
|
|
|
|
callback = vim.lsp.buf.clear_references,
|
|
|
|
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
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
})
|
|
|
@ -587,20 +638,43 @@ require('lazy').setup({
|
|
|
|
|
|
|
|
|
|
|
|
{ -- Autoformat
|
|
|
|
{ -- Autoformat
|
|
|
|
'stevearc/conform.nvim',
|
|
|
|
'stevearc/conform.nvim',
|
|
|
|
|
|
|
|
event = { 'BufWritePre' },
|
|
|
|
|
|
|
|
cmd = { 'ConformInfo' },
|
|
|
|
|
|
|
|
keys = {
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
'<leader>f',
|
|
|
|
|
|
|
|
function()
|
|
|
|
|
|
|
|
require('conform').format { async = true, lsp_format = 'fallback' }
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
mode = '',
|
|
|
|
|
|
|
|
desc = '[F]ormat buffer',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
opts = {
|
|
|
|
opts = {
|
|
|
|
notify_on_error = false,
|
|
|
|
notify_on_error = false,
|
|
|
|
format_on_save = {
|
|
|
|
format_on_save = function(bufnr)
|
|
|
|
timeout_ms = 500,
|
|
|
|
-- Disable "format_on_save lsp_fallback" for languages that don't
|
|
|
|
lsp_fallback = true,
|
|
|
|
-- have a well standardized coding style. You can add additional
|
|
|
|
},
|
|
|
|
-- languages here or re-enable it for the disabled ones.
|
|
|
|
|
|
|
|
local disable_filetypes = { c = true, cpp = true }
|
|
|
|
|
|
|
|
local lsp_format_opt
|
|
|
|
|
|
|
|
if disable_filetypes[vim.bo[bufnr].filetype] then
|
|
|
|
|
|
|
|
lsp_format_opt = 'never'
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
lsp_format_opt = 'fallback'
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
|
|
|
timeout_ms = 500,
|
|
|
|
|
|
|
|
lsp_format = lsp_format_opt,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
end,
|
|
|
|
formatters_by_ft = {
|
|
|
|
formatters_by_ft = {
|
|
|
|
lua = { 'stylua' },
|
|
|
|
lua = { 'stylua' },
|
|
|
|
-- Conform can also run multiple formatters sequentially
|
|
|
|
-- Conform can also run multiple formatters sequentially
|
|
|
|
-- python = { "isort", "black" },
|
|
|
|
-- python = { "isort", "black" },
|
|
|
|
--
|
|
|
|
--
|
|
|
|
-- You can use a sub-list to tell conform to run *until* a formatter
|
|
|
|
-- You can use 'stop_after_first' to run the first available formatter from the list
|
|
|
|
-- is found.
|
|
|
|
-- javascript = { "prettierd", "prettier", stop_after_first = true },
|
|
|
|
-- javascript = { { "prettierd", "prettier" } },
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -660,6 +734,10 @@ require('lazy').setup({
|
|
|
|
-- Select the [p]revious item
|
|
|
|
-- Select the [p]revious item
|
|
|
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
|
|
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Scroll the documentation window [b]ack / [f]orward
|
|
|
|
|
|
|
|
['<C-b>'] = cmp.mapping.scroll_docs(-4),
|
|
|
|
|
|
|
|
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
|
|
|
|
|
|
|
|
|
|
|
-- Accept ([y]es) the completion.
|
|
|
|
-- Accept ([y]es) the completion.
|
|
|
|
-- This will auto-import if your LSP supports it.
|
|
|
|
-- This will auto-import if your LSP supports it.
|
|
|
|
-- This will expand snippets if the LSP sent a snippet.
|
|
|
|
-- This will expand snippets if the LSP sent a snippet.
|
|
|
@ -763,21 +841,39 @@ require('lazy').setup({
|
|
|
|
{ -- Highlight, edit, and navigate code
|
|
|
|
{ -- Highlight, edit, and navigate code
|
|
|
|
'nvim-treesitter/nvim-treesitter',
|
|
|
|
'nvim-treesitter/nvim-treesitter',
|
|
|
|
build = ':TSUpdate',
|
|
|
|
build = ':TSUpdate',
|
|
|
|
|
|
|
|
main = 'nvim-treesitter.configs', -- Sets main module to use for opts
|
|
|
|
config = function()
|
|
|
|
config = function()
|
|
|
|
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
|
|
|
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
|
|
|
|
|
|
|
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
|
|
|
---@diagnostic disable-next-line: missing-fields
|
|
|
|
require('nvim-treesitter.configs').setup {
|
|
|
|
require('nvim-treesitter.configs').setup {
|
|
|
|
ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc' },
|
|
|
|
ensure_installed = {
|
|
|
|
|
|
|
|
'bash',
|
|
|
|
|
|
|
|
'c',
|
|
|
|
|
|
|
|
'javascript',
|
|
|
|
|
|
|
|
'python',
|
|
|
|
|
|
|
|
'svelte',
|
|
|
|
|
|
|
|
'elixir',
|
|
|
|
|
|
|
|
'go',
|
|
|
|
|
|
|
|
'diff',
|
|
|
|
|
|
|
|
'html',
|
|
|
|
|
|
|
|
'lua',
|
|
|
|
|
|
|
|
'markdown',
|
|
|
|
|
|
|
|
'vim',
|
|
|
|
|
|
|
|
'vimdoc',
|
|
|
|
|
|
|
|
},
|
|
|
|
-- Autoinstall languages that are not installed
|
|
|
|
-- Autoinstall languages that are not installed
|
|
|
|
auto_install = true,
|
|
|
|
auto_install = true,
|
|
|
|
highlight = { enable = true },
|
|
|
|
highlight = {
|
|
|
|
indent = { enable = true },
|
|
|
|
enable = true,
|
|
|
|
|
|
|
|
additional_vim_regex_highlighting = { 'ruby' },
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
indent = { enable = true, disable = { 'ruby', 'elixir' } },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vim.api.nvim_set_option('foldenable', false)
|
|
|
|
vim.api.nvim_set_option_value('foldenable', false, {})
|
|
|
|
vim.api.nvim_set_option('foldmethod', 'expr')
|
|
|
|
vim.api.nvim_set_option_value('foldmethod', 'expr', {})
|
|
|
|
vim.api.nvim_set_option('foldexpr', 'nvim_treesitter#foldexpr()')
|
|
|
|
vim.api.nvim_set_option_value('foldexpr', 'nvim_treesitter#foldexpr()', {})
|
|
|
|
|
|
|
|
|
|
|
|
-- There are additional nvim-treesitter modules that you can use to interact
|
|
|
|
-- There are additional nvim-treesitter modules that you can use to interact
|
|
|
|
-- with nvim-treesitter. You should go explore a few and see what interests you:
|
|
|
|
-- with nvim-treesitter. You should go explore a few and see what interests you:
|
|
|
|