aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan J. Martinez <jjm@usebox.net>2022-02-20 14:41:36 +0000
committerJuan J. Martinez <jjm@usebox.net>2022-05-29 22:57:31 +0100
commitfd92e5df3f8ebcae72dadbef8bd3b1c4d3e28693 (patch)
tree38b89ffc5d7d05aacd4d8752ba74bf800e127185
parente09856face477e157a2e7f9dc40a95561453dbca (diff)
downloaddotnvim-fd92e5df3f8ebcae72dadbef8bd3b1c4d3e28693.tar.gz
dotnvim-fd92e5df3f8ebcae72dadbef8bd3b1c4d3e28693.zip
Support settings per LSP server
-rw-r--r--lsp.lua51
1 files changed, 27 insertions, 24 deletions
diff --git a/lsp.lua b/lsp.lua
index b720dd0..7854edb 100644
--- a/lsp.lua
+++ b/lsp.lua
@@ -11,38 +11,32 @@ vim.api.nvim_set_keymap('n', 'da', '<cmd>lua vim.diagnostic.setloclist()<CR>', o
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
- -- Enable completion triggered by <c-x><c-o>
- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
+ -- Enable completion triggered by <c-x><c-o>
+ vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
- -- Mappings.
- -- See `:help vim.lsp.*` for documentation on any of the below functions
- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-]>', '<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', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gsh', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
- vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<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', '<leader>F', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
+ -- Mappings.
+ -- See `:help vim.lsp.*` for documentation on any of the below functions
+ vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-]>', '<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', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
+ vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gsh', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
+ vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
+ vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<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', '<leader>F', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
local signs = { Error = "🔥", Warn = "⚠️ ", Hint = "✨", Info = "ℹ️ " }
for type, icon in pairs(signs) do
- local hl = "DiagnosticSign" .. type
- vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
+ local hl = "DiagnosticSign" .. type
+ vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
-local servers = { 'pylsp' }
-for _, lsp in pairs(servers) do
- require('lspconfig')[lsp].setup {
- on_attach = on_attach,
- flags = {
- -- This will be the default in neovim 0.7+
- debounce_text_changes = 150,
- },
- settings = {
+local servers = {
+ -- server_name = settings
+ pylsp = {
pylsp = {
plugins = {
pylsp_mypy = {
@@ -51,6 +45,15 @@ for _, lsp in pairs(servers) do
}
}
}
+ },
+}
+for lsp, settings in pairs(servers) do
+ require('lspconfig')[lsp].setup {
+ on_attach = on_attach,
+ flags = {
+ -- This will be the default in neovim 0.7+
+ debounce_text_changes = 150,
+ },
+ settings = settings,
}
- }
end