diff options
author | Jasper Ras <jaspert.ras@gmail.com> | 2024-11-09 14:26:34 +0100 |
---|---|---|
committer | Jasper Ras <jaspert.ras@gmail.com> | 2024-11-09 14:26:34 +0100 |
commit | 3fce1b5d9350c116270111e92f2d993e1b518d4d (patch) | |
tree | daada43eb23df53d6a0df3622d4bfe913851d1f3 /home-manager/neovim/lsp-zero-nvim.lua | |
parent | 4211ed3b82be9af26460a0a8d88dce9ce319bb47 (diff) |
Inline home-manager
Diffstat (limited to 'home-manager/neovim/lsp-zero-nvim.lua')
-rw-r--r-- | home-manager/neovim/lsp-zero-nvim.lua | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/home-manager/neovim/lsp-zero-nvim.lua b/home-manager/neovim/lsp-zero-nvim.lua new file mode 100644 index 0000000..2abd191 --- /dev/null +++ b/home-manager/neovim/lsp-zero-nvim.lua @@ -0,0 +1,66 @@ +local lsp = require('lsp-zero').preset({ + manage_nvim_cmp = { + set_sources = 'recommended', + } +}) + +lsp.on_attach(function(client, bufnr) + local opts = {buffer = bufnr} + + lsp.default_keymaps(opts) + + vim.keymap.set('n', 'gd', '<cmd>Telescope lsp_definitions<cr>', opts) + vim.keymap.set('n', 'gi', '<cmd>Telescope lsp_implementations<cr>', opts) + vim.keymap.set('n', 'gr', '<cmd>Telescope lsp_references<cr>', opts) + vim.keymap.set('n', '<F5>', '<cmd>LspRestart<cr>', opts) +end) + +-- When you don't have mason.nvim installed +-- You'll need to list the servers installed in your system +lsp.setup_servers({'nixd', 'pyright', 'phpactor', 'gopls', 'lua_ls', 'ansiblels'}) + +-- (Optional) Configure lua language server for neovim +local lspconfig = require('lspconfig') +lspconfig.lua_ls.setup { + settings = { + Lua = { + runtime = { + -- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT', + }, + diagnostics = { + -- Get the language server to recognize the `vim` global + globals = {'vim'}, + }, + workspace = { + -- Make the server aware of Neovim runtime files + library = vim.api.nvim_get_runtime_file("", true), + checkThirdParty = false, + }, + -- Do not send telemetry data containing a randomized but unique identifier + telemetry = { + enable = false, + }, + }, + }, +} + +lsp.setup() + +local cmp = require('cmp') +local cmp_action = require('lsp-zero').cmp_action() + +cmp.setup({ + sources = { + {name = 'nvim_lsp'}, + {name = 'nvim_lua'}, + }, + mapping = { + ['<CR>'] = cmp.mapping.confirm({select = false}), + ['<C-f>'] = cmp_action.luasnip_jump_forward(), + ['<C-b>'] = cmp_action.luasnip_jump_backward(), + ['<Tab>'] = cmp_action.luasnip_supertab(), + ['<S-Tab>'] = cmp_action.luasnip_shift_supertab(), + }, +}) + |