aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-lsp-installer.lua19
-rw-r--r--lua/nvim-lsp-installer/settings.lua2
2 files changed, 21 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 = {
diff --git a/lua/nvim-lsp-installer/settings.lua b/lua/nvim-lsp-installer/settings.lua
index 87499354..7a36e217 100644
--- a/lua/nvim-lsp-installer/settings.lua
+++ b/lua/nvim-lsp-installer/settings.lua
@@ -4,6 +4,8 @@ local M = {}
---@class LspInstallerSettings
local DEFAULT_SETTINGS = {
+ -- A list of servers to automatically install. Example: { "rust_analyzer", "sumneko_lua" }
+ ensure_installed = {},
ui = {
icons = {
-- The list icon to use for installed servers.