aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/middleware.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-04-30 15:44:37 +0200
committerGitHub <noreply@github.com>2022-04-30 15:44:37 +0200
commitcd4dac02a3bb5431979b0812a80dadf6ee088f5e (patch)
tree17eef2c3f9a11818accc93e98029ded1baf92998 /lua/nvim-lsp-installer/middleware.lua
parentUpdate CUSTOM_SERVERS.md (diff)
downloadmason-cd4dac02a3bb5431979b0812a80dadf6ee088f5e.tar
mason-cd4dac02a3bb5431979b0812a80dadf6ee088f5e.tar.gz
mason-cd4dac02a3bb5431979b0812a80dadf6ee088f5e.tar.bz2
mason-cd4dac02a3bb5431979b0812a80dadf6ee088f5e.tar.lz
mason-cd4dac02a3bb5431979b0812a80dadf6ee088f5e.tar.xz
mason-cd4dac02a3bb5431979b0812a80dadf6ee088f5e.tar.zst
mason-cd4dac02a3bb5431979b0812a80dadf6ee088f5e.zip
feat: allow excluding servers from automatic installation (#643)
Diffstat (limited to 'lua/nvim-lsp-installer/middleware.lua')
-rw-r--r--lua/nvim-lsp-installer/middleware.lua19
1 files changed, 17 insertions, 2 deletions
diff --git a/lua/nvim-lsp-installer/middleware.lua b/lua/nvim-lsp-installer/middleware.lua
index 7def4276..b09b51ac 100644
--- a/lua/nvim-lsp-installer/middleware.lua
+++ b/lua/nvim-lsp-installer/middleware.lua
@@ -1,6 +1,9 @@
local util = require "lspconfig.util"
local servers = require "nvim-lsp-installer.servers"
local settings = require "nvim-lsp-installer.settings"
+local Data = require "nvim-lsp-installer.data"
+
+local memoize, set_of = Data.memoize, Data.set_of
local M = {}
@@ -21,14 +24,26 @@ local function merge_in_place(t1, t2)
return t1
end
+local memoized_set = memoize(set_of)
+
+---@param server_name string
+local function should_auto_install(server_name)
+ if settings.current.automatic_installation == true then
+ return true
+ end
+ if type(settings.current.automatic_installation) == "table" then
+ return not memoized_set(settings.current.automatic_installation.exclude)[server_name]
+ end
+ return false
+end
+
function M.register_lspconfig_hook()
util.on_setup = util.add_hook_before(util.on_setup, function(config)
local ok, server = servers.get_server(config.name)
if ok then
if server:is_installed() then
merge_in_place(config, server._default_options)
- end
- if settings.current.automatic_installation and not server:is_installed() then
+ elseif should_auto_install(server.name) then
server:install()
end
end