]> src.twobees.de Git - dotfiles.git/blob - stow/nvim/.config/nvim/after/plugin/lspsetup.lua
6a1fcb6ddc82da7608f23b99bc4251daad696d65
[dotfiles.git] / stow / nvim / .config / nvim / after / plugin / lspsetup.lua
1 local lsp = require('lsp-zero')
2 lsp.preset('recommended')
3
4 lsp.configure('lua_ls', {
5     settings = {
6         Lua = {
7             diagnostics = {
8                 globals = { 'vim' }
9             }
10         }
11     }
12 })
13
14
15 lsp.on_attach(function(client, bufnr)
16   lsp.default_keymaps({buffer = bufnr})
17      vim.keymap.set ("n", "<leader>r", vim.lsp.buf.rename, options)
18      vim.keymap.set ("n", "<leader>f", vim.lsp.buf.code_action, options)
19 end)
20
21 lsp.set_sign_icons({
22   error = '✘',
23   warn = '▲',
24   hint = '⚑',
25   info = '»'
26 })
27 -- lsp.on_attach = function (_, bufnr)
28 --     print "attached"
29 --     local options = { buffer = bufnr, remap = false }
30 --     vim.keymap.set ("n", "K", vim.lsp.buf.hover, options) -- buffer=0 -> only in current buffer
31 --     vim.keymap.set ("n", "gd", vim.lsp.buf.definition, options) -- goto definition
32 --     vim.keymap.set ("n", "gT", vim.lsp.buf.type_definition, options) -- goto typedefinition
33 --     vim.keymap.set ("n", "gi", vim.lsp.buf.implementation, options) -- goto implementation
34 --     vim.keymap.set ("n", "dj", vim.diagnostic.goto_next, options) -- goto dignostic next
35 --     vim.keymap.set ("n", "dk", vim.diagnostic.goto_prev, options) -- goto diognostic prev
36 --     vim.keymap.set ("n", "dl", "<cmd>Telescope diagnostic", options) -- goto list failure
37 --     vim.keymap.set ("n", "<leader>r", vim.lsp.buf.rename, options)
38 --     vim.keymap.set ("n", "<leader>f", vim.lsp.buf.code_action, options)
39 -- end
40
41 local cmp = require('cmp')
42 local cmp_select = {behavior = cmp.SelectBehavior.Select}
43 local cmp_mappings = lsp.defaults.cmp_mappings({
44     ['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
45     ['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
46     ['<C-y>'] = cmp.mapping.confirm({ select = true }),
47     ["<C-Space>"] = cmp.mapping.complete(),
48 })
49
50 lsp.setup_nvim_cmp({
51     mapping = cmp_mappings,
52 })
53
54 cmp.setup({
55     experimental = { ghost_text = true },
56 });
57
58
59 lsp.setup()
60
61 vim.diagnostic.config({
62   virtual_text = {
63     -- source = "always",  -- Or "if_many"
64     prefix = '●', -- Could be '■', '▎', 'x'
65   },
66   severity_sort = true,
67   float = {
68     source = "always",  -- Or "if_many"
69   },
70 })
71