diff options
author | Thomas Voss <mail@thomasvoss.com> | 2023-09-12 12:16:31 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2023-09-12 12:16:31 +0200 |
commit | 24fc98bfaca3f07c90ff33a3bfeb738fd84ff79a (patch) | |
tree | 7c5c9c870ed808d5cbee848808c70ff9ec1816c3 /.config/nvim/after/plugin/lsp.lua | |
parent | a5feec43c14bd05e8dd98d24fba7e25fdbb6fd7d (diff) |
nvim: Add extensive Neovim configuration
Diffstat (limited to '.config/nvim/after/plugin/lsp.lua')
-rw-r--r-- | .config/nvim/after/plugin/lsp.lua | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua new file mode 100644 index 0000000..6891256 --- /dev/null +++ b/.config/nvim/after/plugin/lsp.lua @@ -0,0 +1,40 @@ +local lsp = require('lsp-zero') + +lsp.preset('recommended') +lsp.ensure_installed({ + 'clangd', + 'gopls', + 'rust_analyzer', +}) + +lsp.nvim_workspace() + +local cmp = require('cmp') +local cmp_select = {behavior = cmp.SelectBehavior.Select} +local cmp_mappings = lsp.defaults.cmp_mappings({ + ['<C-k>'] = cmp.mapping.select_prev_item(cmp_select), + ['<C-j>'] = cmp.mapping.select_next_item(cmp_select), + ['<CR>'] = cmp.mapping.confirm({ select = true }), + ['<C-Space>'] = cmp.mapping.complete(), +}) + +lsp.set_preferences({ + suggest_lsp_servers = false, + sign_icons = { } +}) + +lsp.setup_nvim_cmp({ + mapping = cmp_mappings +}) + +lsp.on_attach(function(_, bufnr) + local opts = {buffer = bufnr, remap = false} + + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', '<leader>la', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', '<leader>lr', vim.lsp.buf.rename, opts) + vim.keymap.set('n', '<leader>l=', vim.lsp.buf.format, opts) + vim.keymap.set('i', '<C-h>', vim.lsp.buf.signature_help, opts) +end) + +lsp.setup() |