From 2022e7da390518563388c58e385abe462460b905 Mon Sep 17 00:00:00 2001 From: Tanguy Herbron Date: Thu, 4 Jan 2024 01:46:13 +0100 Subject: [PATCH] refactor(nvim): Dynamicly register capabilities to every LSP server installed --- .config/nvim/lua/plugins/lsp-config.lua | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/.config/nvim/lua/plugins/lsp-config.lua b/.config/nvim/lua/plugins/lsp-config.lua index f9fb5a9..9adae7a 100644 --- a/.config/nvim/lua/plugins/lsp-config.lua +++ b/.config/nvim/lua/plugins/lsp-config.lua @@ -27,24 +27,13 @@ return { local lspconfig = require("lspconfig") - lspconfig.lua_ls.setup({ - capabilities = capabilities - }) - lspconfig.tsserver.setup({ - capabilities = capabilities - }) - lspconfig.svelte.setup({ - capabilities = capabilities - }) - lspconfig.rust_analyzer.setup({ - capabilities = capabilities - }) - lspconfig.docker_compose_language_service.setup({ - capabilities = capabilities - }) - lspconfig.dockerls.setup({ - capabilities = capabilities - }) + local server_list = require("mason-lspconfig").get_installed_servers() + + for _, server in pairs(server_list) do + lspconfig[server].setup({ + capabilities = capabilities + }) + end vim.keymap.set('n', 'K', vim.lsp.buf.hover, {}) vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {})