aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/nvim-lsp-installer.lua')
-rw-r--r--lua/nvim-lsp-installer.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer.lua b/lua/nvim-lsp-installer.lua
index a910440e..ab566551 100644
--- a/lua/nvim-lsp-installer.lua
+++ b/lua/nvim-lsp-installer.lua
@@ -14,6 +14,22 @@ local M = {}
M.settings = settings.set
+---@param server_identifiers string[]
+local function ensure_installed(server_identifiers)
+ local candidates = {}
+ for _, server_identifier in ipairs(server_identifiers) do
+ local server_name, version = servers.parse_server_identifier(server_identifier)
+ local ok, server = servers.get_server(server_name)
+ if ok and not server:is_installed() then
+ table.insert(candidates, server_name)
+ server:install(version)
+ end
+ end
+ if #candidates > 0 then
+ notify("Installing LSP servers: " .. table.concat(candidates, ", "))
+ end
+end
+
---@param config table
function M.setup(config)
if config then
@@ -21,6 +37,9 @@ function M.setup(config)
end
settings.uses_new_setup = true
require("nvim-lsp-installer.middleware").register_lspconfig_hook()
+ vim.schedule(function()
+ ensure_installed(settings.current.ensure_installed)
+ end)
end
M.info_window = {