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