summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2022-06-25 22:32:19 +0200
committerSanto Cariotti <santo@dcariotti.me>2022-06-25 22:32:19 +0200
commitd2ec5893708af1e4b05e6ad4198bc3ff4fd2ee10 (patch)
tree73d0e6e511c940a5421a9db0d4db968d17d821fd
parente4aa341795840faca08eac0d419e8b52820bc9b5 (diff)
nvim: reorder lsp
-rw-r--r--.config/nvim/lua/lsp_conf.lua49
1 files changed, 23 insertions, 26 deletions
diff --git a/.config/nvim/lua/lsp_conf.lua b/.config/nvim/lua/lsp_conf.lua
index 35f88eb..6555f2e 100644
--- a/.config/nvim/lua/lsp_conf.lua
+++ b/.config/nvim/lua/lsp_conf.lua
@@ -28,48 +28,45 @@ null_ls.setup({
null_ls.builtins.formatting.clang_format,
-- JS/TS
null_ls.builtins.formatting.prettier,
- }
+ },
+ on_attach = function(client)
+ if client.resolved_capabilities.document_formatting then
+ vim.keymap.set('n', '<A-f>', '<cmd>lua vim.lsp.buf.formatting_sync(nil, 2000)<cr>', opts)
+ vim.cmd "autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync(nil, 2000)"
+ end
+ end
})
-- Setup lspconfig.
+require "lsp_signature".setup()
+
--- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
+
+local common_on_attach = function(client, bufnr)
+ -- Mappings.
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "gD", "<cmd>lua vim.lsp.buf.declaration()<CR>", opts)
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "gd", "<cmd>lua vim.lsp.buf.definition()<CR>", opts)
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "K", "<cmd>lua vim.lsp.buf.hover()<CR>", opts)
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
+ vim.api.nvim_buf_set_keymap(bufnr, "n", "<space>e", "<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>", opts)
+
+ lsp_status.on_attach(client)
+end
+
+
local servers = { 'pyright', 'rust_analyzer', 'tsserver', 'clangd' }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup {
capabilities = coq.lsp_ensure_capabilities(),
- on_attach = function(client, bufnr)
- client.resolved_capabilities.document_formatting = false
-
- require "lsp_signature".on_attach()
-
- -- Mappings.
- local opts = { noremap=true, silent=true }
-
- -- See `:help vim.lsp.*` for documentation on any of the below functions
- vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
- vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
- vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
- vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
- vim.keymap.set('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
- end,
+ on_attach = common_on_attach,
flags = {
debounce_text_changes = 150,
}
}
end
--- nvim_lsp["null-ls"].setup({
--- on_attach = function(client)
--- if client.resolved_capabilities.document_formatting then
--- vim.keymap.set('n', '<A-f>', '<cmd>lua vim.lsp.buf.formatting_sync()<cr>', opts)
--- vim.cmd "autocmd BufWritePre <buffer> lua vim.lsp.buf.formatting_seq_sync()"
--- end
--- end
--- })
---
---
trouble.setup({
use_diagnostic_signs = true,
auto_close = true,