.config/nvim/lua/config/lsp.lua

Mon, 13 Feb 2023 21:25:15 -0600

author
Meredith Howard <mhoward@roomag.org>
date
Mon, 13 Feb 2023 21:25:15 -0600
changeset 1019
7e42fd320166
parent 1016
07d37da233ef
child 1022
d509e282ae10
permissions
-rw-r--r--

Further nvim work

1016
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
1 vim.diagnostic.config({
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
2 virtual_text = { true, severity = "WARN", },
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
3 })
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
4
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
5 vim.api.nvim_create_autocmd("LspAttach", {
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
6 once = true,
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
7 callback = function(args)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
8 vim.opt.number = true
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
9 end,
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
10 })
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
11
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
12 local opts = { noremap=true, silent=true }
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
13 vim.keymap.set('n', '<leader>d', vim.diagnostic.open_float, opts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
14 vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
15 vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
16 vim.keymap.set('n', '<leader>ld', vim.diagnostic.setloclist, opts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
17
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
18 vim.api.nvim_create_autocmd("LspAttach", {
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
19 callback = function(args)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
20 local bufnr = args.buf
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
21 local bufopts = { noremap=true, silent=true, buffer=bufnr }
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
22
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
23 vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
24 vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
25 vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
26 vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
27 vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
28 vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, bufopts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
29 vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
30 vim.keymap.set('n', '<leader>wl', function()
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
31 print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
32 end, bufopts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
33 vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, bufopts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
34 vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
35 vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
36 vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
37 vim.keymap.set('n', '<leader>f', function() vim.lsp.buf.format { async = true } end, bufopts)
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
38 end,
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
39 })
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
40
07d37da233ef Add lsp-specific config
Meredith Howard <mhoward@roomag.org>
parents:
diff changeset
41

mercurial