]> git.r.bdr.sh - rbdr/dotfiles/blame_incremental - config/nvim/lua/lsp.lua
Add aerc config
[rbdr/dotfiles] / config / nvim / lua / lsp.lua
... / ...
CommitLineData
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}
16lspconfig.cssls.setup {
17 capabilities = capabilities,
18}
19lspconfig.html.setup {
20 capabilities = capabilities,
21}
22lspconfig.lua_ls.setup{}
23
24-- Global mappings.
25-- See `:help vim.diagnostic.*` for documentation on any of the below functions
26vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
27vim.keymap.set('n', '[d', vim.diagnostic.goto_prev)
28vim.keymap.set('n', ']d', vim.diagnostic.goto_next)
29vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
30
31-- Use LspAttach autocommand to only map the following keys
32-- after the language server attaches to the current buffer
33vim.api.nvim_create_autocmd('LspAttach', {
34 group = vim.api.nvim_create_augroup('UserLspConfig', {}),
35 callback = function(ev)
36 -- Enable completion triggered by <c-x><c-o>
37 vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
38
39 -- Buffer local mappings.
40 -- See `:help vim.lsp.*` for documentation on any of the below functions
41 local opts = { buffer = ev.buf }
42 vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
43 vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
44 vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
45 vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
46 vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
47 vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
48 vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
49 vim.keymap.set('n', '<space>wl', function()
50 print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
51 end, opts)
52 vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
53 vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
54 vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
55 vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
56 vim.keymap.set('n', '<space>f', function()
57 vim.lsp.buf.format { async = true }
58 end, opts)
59 end,
60})