From dccd511bf7ca8a4be9b437dfc12163f4acc63545 Mon Sep 17 00:00:00 2001 From: Felipe Contreras Salinas Date: Tue, 28 Mar 2023 02:07:12 -0300 Subject: [PATCH] lsp: Refactor to allow server settings --- init.lua | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/init.lua b/init.lua index 7e2a948..0644e97 100644 --- a/init.lua +++ b/init.lua @@ -139,16 +139,16 @@ end -- Use a loop to conveniently call 'setup' on multiple servers and -- map buffer local keybindings when the language server attaches local servers = { - 'clangd', - 'gopls', - 'jsonls', - 'kotlin_language_server', - 'marksman', - 'rust_analyzer', - 'texlab', - 'tflint', - 'tsserver', - 'pylsp' + clangd, + gopls, + jsonls, + kotlin_language_server, + marksman, + pylsp, + rust_analyzer, + texlab, + tflint, + tsserver, } -- Setup loop moved to the cmp section, since calling setup multiple times -- overrides the previous calls. @@ -216,13 +216,23 @@ cmp.setup({ local capabilities = vim.lsp.protocol.make_client_capabilities() lsp.util.default_config = vim.tbl_deep_extend( 'force', lsp.util.default_config, { capabilities = capabilities, }) -for _, server in pairs(servers) do - lsp[server].setup { - on_attach = on_lsp_attach, - flags = { - debounce_text_changes = 150, - } - } +for server, settings in pairs(servers) do + if settings then + lsp[server].setup({ + on_attach = on_lsp_attach, + flags = { + debounce_text_changes = 150, + }, + settings = settings, + }) + else + lsp[server].setup({ + on_attach = on_lsp_attach, + flags = { + debounce_text_changes = 150, + }, + }) + end end ---- git-blame.nvim g.gitblame_enabled = 0