]> git.r.bdr.sh - rbdr/dotfiles/blame - config/nvim/lua/lsp.lua
Use new email config
[rbdr/dotfiles] / config / nvim / lua / lsp.lua
CommitLineData
73a2d994 1local lspconfig = require('lspconfig')
fd61b7b4 2local coq = require('coq')
73a2d994
RBR
3local capabilities = vim.lsp.protocol.make_client_capabilities()
4capabilities.textDocument.completion.completionItem.snippetSupport = true
5
fd61b7b4
RBR
6lspconfig.tsserver.setup(coq.lsp_ensure_capabilities({}))
7lspconfig.eslint.setup(coq.lsp_ensure_capabilities({}))
8lspconfig.svelte.setup(coq.lsp_ensure_capabilities({}))
9lspconfig.pyright.setup(coq.lsp_ensure_capabilities({}))
10lspconfig.dartls.setup(coq.lsp_ensure_capabilities({}))
11lspconfig.rust_analyzer.setup(coq.lsp_ensure_capabilities({
73a2d994
RBR
12 -- Server-specific settings. See `:help lspconfig-setup`
13 settings = {
14 ['rust-analyzer'] = {},
15 },
fd61b7b4
RBR
16}))
17lspconfig.lua_ls.setup(coq.lsp_ensure_capabilities({}))
73a2d994
RBR
18
19-- Global mappings.
20-- See `:help vim.diagnostic.*` for documentation on any of the below functions
21vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
22vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
23vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
24vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
25
26-- Use LspAttach autocommand to only map the following keys
27-- after the language server attaches to the current buffer
28vim.api.nvim_create_autocmd('LspAttach', {
29 group = vim.api.nvim_create_augroup('UserLspConfig', {}),
30 callback = function(ev)
31 -- Enable completion triggered by <c-x><c-o>
32 vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
33
34 -- Buffer local mappings.
35 -- See `:help vim.lsp.*` for documentation on any of the below functions
36 local opts = { buffer = ev.buf }
37 vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
38 vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
39 vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
40 vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
41 vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
42 vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
43 vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
44 vim.keymap.set('n', '<space>wl', function()
45 print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
46 end, opts)
47 vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
48 vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
49 vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
50 vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
51 vim.keymap.set('n', '<space>f', function()
52 vim.lsp.buf.format { async = true }
53 end, opts)
54 end,
55})