diff --git a/modules/terminal-life/nvim/default.nix b/modules/terminal-life/nvim/default.nix index 08e25759..931e71e6 100644 --- a/modules/terminal-life/nvim/default.nix +++ b/modules/terminal-life/nvim/default.nix @@ -80,6 +80,7 @@ in nodePackages.vue-language-server nodePackages.vscode-langservers-extracted nodePackages.yaml-language-server + python39Packages.python-lsp-server python3Full python-language-server solargraph @@ -91,6 +92,12 @@ in ]; plugins = with pkgs.vimPlugins; [ + nvim-cmp + cmp-nvim-lsp + cmp_luasnip + luasnip + + lsp_extensions-nvim nvim-lspconfig lsp_extensions-nvim completion-nvim diff --git a/modules/terminal-life/nvim/lsp.vim b/modules/terminal-life/nvim/lsp.vim index 467a7357..9252dd89 100644 --- a/modules/terminal-life/nvim/lsp.vim +++ b/modules/terminal-life/nvim/lsp.vim @@ -114,7 +114,13 @@ lua <'] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, + [''] = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, + } EOF " Visualize diagnostics @@ -143,14 +199,3 @@ autocmd CursorHold * lua vim.lsp.diagnostic.show_line_diagnostics() " have a fixed column for the diagnostics to appear in " this removes the jitter when warnings/errors flow in set signcolumn=yes - -" NeoVim 0.5 Code navigation shortcuts -nnoremap gd lua vim.lsp.buf.definition() -nnoremap K lua vim.lsp.buf.hover() -nnoremap gD lua vim.lsp.buf.implementation() -nnoremap lua vim.lsp.buf.signature_help() -nnoremap 1gD lua vim.lsp.buf.type_definition() -nnoremap gr lua vim.lsp.buf.references() -nnoremap g0 lua vim.lsp.buf.document_symbol() -nnoremap gW lua vim.lsp.buf.workspace_symbol() -nnoremap lua vim.lsp.buf.declaration()