]> git.r.bdr.sh - rbdr/dotfiles/blob - config/nvim/lua/lsp.lua
Use the patched fonts
[rbdr/dotfiles] / config / nvim / lua / lsp.lua
1 local lspconfig = require('lspconfig')
2 local coq = require('coq')
3 local capabilities = vim.lsp.protocol.make_client_capabilities()
4 capabilities.textDocument.completion.completionItem.snippetSupport = true
5
6 lspconfig.tsserver.setup(coq.lsp_ensure_capabilities({}))
7 lspconfig.eslint.setup(coq.lsp_ensure_capabilities({}))
8 lspconfig.svelte.setup(coq.lsp_ensure_capabilities({}))
9 lspconfig.pyright.setup(coq.lsp_ensure_capabilities({}))
10 lspconfig.dartls.setup(coq.lsp_ensure_capabilities({}))
11 lspconfig.rust_analyzer.setup(coq.lsp_ensure_capabilities({
12 -- Server-specific settings. See `:help lspconfig-setup`
13 settings = {
14 ['rust-analyzer'] = {},
15 },
16 }))
17 lspconfig.lua_ls.setup(coq.lsp_ensure_capabilities({}))
18
19 -- Global mappings.
20 -- See `:help vim.diagnostic.*` for documentation on any of the below functions
21 vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
22 vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
23 vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
24 vim.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
28 vim.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 })