1 local lsp = require('lsp-zero')
3 lsp.preset('recommended')
4 lsp.configure('sumneko_lua', {
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)
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(),
36 mapping = cmp_mappings,
40 experimental = { ghost_text = true },
45 vim.diagnostic.config( { virtual_text = true } )