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