]> src.twobees.de Git - dotfiles.git/blob - stow/nvim/.config/nvim/after/plugin/lspsetup.lua
...
[dotfiles.git] / stow / nvim / .config / nvim / after / plugin / lspsetup.lua
1 local lsp = require('lsp-zero')
2
3 lsp.preset('recommended')
4 lsp.configure('sumneko_lua', {
5     settings = {
6         Lua = {
7             diagnostics = {
8                 globals = { 'vim' }
9             }
10         }
11     }
12 })
13
14 lsp.on_attach = function (_, bufnr)
15     local options = { buffer = bufnr, remap = false }
16     vim.keymap.set ("n", "K", vim.lsp.buf.hover, options) -- buffer=0 -> only in current buffer
17     vim.keymap.set ("n", "gd", vim.lsp.buf.definition, options) -- goto definition
18     vim.keymap.set ("n", "gT", vim.lsp.buf.type_definition, options) -- goto typedefinition
19     vim.keymap.set ("n", "gi", vim.lsp.buf.implementation, options) -- goto implementation
20     vim.keymap.set ("n", "dj", vim.diagnostic.goto_next, options) -- goto dignostic next
21     vim.keymap.set ("n", "dk", vim.diagnostic.goto_prev, options) -- goto diognostic prev
22     vim.keymap.set ("n", "dl", "<cmd>Telescope diagnostic", options) -- goto list failure
23     vim.keymap.set ("n", "<leader>r", vim.lsp.buf.rename, options)
24 end
25
26 local cmp = require('cmp')
27 local cmp_select = {behavior = cmp.SelectBehavior.Select}
28 local cmp_mappings = lsp.defaults.cmp_mappings({
29     ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
30     ['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
31     ['<C-y>'] = cmp.mapping.confirm({ select = true }),
32     ["<C-Space>"] = cmp.mapping.complete(),
33 })
34
35 lsp.setup_nvim_cmp({
36     mapping = cmp_mappings,
37 })
38
39 cmp.setup({
40     experimental = { ghost_text = true },
41 });
42
43 lsp.setup()
44
45 vim.diagnostic.config( { virtual_text = true } )