From b7d334539493967163ab26cbd218e6d07cf8e910 Mon Sep 17 00:00:00 2001 From: Sirisak Lueangsaksri <1087399+spywhere@users.noreply.github.com> Date: Tue, 31 Oct 2023 18:17:25 +0700 Subject: [PATCH] fix(nvim): unsupported lsp is not setup --- configs/nvim/lua/lib/lsp.lua | 2 +- configs/nvim/lua/plugin/autocomplete/lspconfig.lua | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/configs/nvim/lua/lib/lsp.lua b/configs/nvim/lua/lib/lsp.lua index 33a85bf..b148258 100644 --- a/configs/nvim/lua/lib/lsp.lua +++ b/configs/nvim/lua/lib/lsp.lua @@ -136,7 +136,7 @@ M.setup = function (name, options) setup_lsp(server, lsps[server], options) end end - name(handler) + name(handler, vim.tbl_keys(lsps)) end) end elseif name == nil then diff --git a/configs/nvim/lua/plugin/autocomplete/lspconfig.lua b/configs/nvim/lua/plugin/autocomplete/lspconfig.lua index 221b33c..afcc601 100644 --- a/configs/nvim/lua/plugin/autocomplete/lspconfig.lua +++ b/configs/nvim/lua/plugin/autocomplete/lspconfig.lua @@ -7,8 +7,18 @@ registry.install { 'williamboman/mason.nvim', 'neovim/nvim-lspconfig' }, - delay = lsp.setup(function (handler) - require('mason-lspconfig').setup { + delay = lsp.setup(function (handler, required_servers) + local mason_lsp = require('mason-lspconfig') + + local available_servers = mason_lsp.get_available_servers() + for _, server in ipairs(required_servers) do + -- setup lsp manually for unsupported servers + if not available_servers[server] then + handler(server) + end + end + + mason_lsp.setup { ensure_installed = { 'bashls', 'emmet_ls', 'eslint', 'graphql', 'lua_ls', 'pyright', 'tsserver', 'vimls', 'yamlls' },