diff options
author | kylo252 <[email protected]> | 2021-11-22 08:32:40 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-11-22 08:32:40 +0100 |
commit | 07bcae45fd54ef9b8c2e663dd414b3384435ebe9 (patch) | |
tree | aa03a64ce0f2806e648ada3740c52ec1d9bc5535 /lua/lvim/lsp/manager.lua | |
parent | 109c766809760f7a9aba5dfb467d8299d2996de0 (diff) |
fix(lsp): avoid installing an overridden server (#1981)
Diffstat (limited to 'lua/lvim/lsp/manager.lua')
-rw-r--r-- | lua/lvim/lsp/manager.lua | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/lua/lvim/lsp/manager.lua b/lua/lvim/lsp/manager.lua index dbb7b87f..ca4dc285 100644 --- a/lua/lvim/lsp/manager.lua +++ b/lua/lvim/lsp/manager.lua @@ -54,39 +54,41 @@ function M.setup(server_name, user_config) if lvim_lsp_utils.is_client_active(server_name) then return end - local servers = require "nvim-lsp-installer.servers" local config = resolve_config(server_name, user_config) + + local servers = require "nvim-lsp-installer.servers" local server_available, requested_server = servers.get_server(server_name) - if server_available then - local install_notification = false - - if not requested_server:is_installed() then - if lvim.lsp.automatic_servers_installation then - Log:debug "Automatic server installation detected" - requested_server:install() - install_notification = true - else - Log:debug(requested_server.name .. " is not managed by the automatic installer") - end - end + local is_overridden = vim.tbl_contains(lvim.lsp.override, server_name) - requested_server:on_ready(function() - if install_notification then - vim.notify(string.format("Installation complete for [%s] server", requested_server.name), vim.log.levels.INFO) - end - install_notification = false - requested_server:setup(config) - end) - else - -- since it may not be installed, don't attempt to configure the LSP unless there is a custom provider - local has_custom_provider, _ = pcall(require, "lvim/lsp/providers/" .. server_name) - if has_custom_provider then + if not server_available or is_overridden then + pcall(function() require("lspconfig")[server_name].setup(config) buf_try_add(server_name) + end) + return + end + + local install_notification = false + + if not requested_server:is_installed() then + if lvim.lsp.automatic_servers_installation then + Log:debug "Automatic server installation detected" + requested_server:install() + install_notification = true + else + Log:debug(requested_server.name .. " is not managed by the automatic installer") end end + + requested_server:on_ready(function() + if install_notification then + vim.notify(string.format("Installation complete for [%s] server", requested_server.name), vim.log.levels.INFO) + end + install_notification = false + requested_server:setup(config) + end) end return M |