aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/middleware.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-07-06 19:41:43 +0200
committerWilliam Boman <william@redwill.se>2022-07-07 00:39:59 +0200
commit5f634e0c37e723fc0c33e06b4fd5c2180178db40 (patch)
treefa4f09363adefa8259e23e4d1ea036db628b1243 /lua/nvim-lsp-installer/middleware.lua
parentfeat(health): use stderr for java version, also check for JAVA_HOME (#765) (diff)
downloadmason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar
mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar.gz
mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar.bz2
mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar.lz
mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar.xz
mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.tar.zst
mason-5f634e0c37e723fc0c33e06b4fd5c2180178db40.zip
mason.nvim
Diffstat (limited to 'lua/nvim-lsp-installer/middleware.lua')
-rw-r--r--lua/nvim-lsp-installer/middleware.lua76
1 files changed, 0 insertions, 76 deletions
diff --git a/lua/nvim-lsp-installer/middleware.lua b/lua/nvim-lsp-installer/middleware.lua
deleted file mode 100644
index 04ffe2a9..00000000
--- a/lua/nvim-lsp-installer/middleware.lua
+++ /dev/null
@@ -1,76 +0,0 @@
-local util = require "lspconfig.util"
-local _ = require "nvim-lsp-installer.core.functional"
-local notify = require "nvim-lsp-installer.notify"
-local servers = require "nvim-lsp-installer.servers"
-local settings = require "nvim-lsp-installer.settings"
-local functional = require "nvim-lsp-installer.core.functional"
-
-local memoize, set_of = functional.memoize, functional.set_of
-
-local M = {}
-
----@param t1 table
----@param t2 table
-local function merge_in_place(t1, t2)
- for k, v in pairs(t2) do
- if type(v) == "table" then
- if type(t1[k]) == "table" and not vim.tbl_islist(t1[k]) then
- merge_in_place(t1[k], v)
- else
- t1[k] = v
- end
- else
- t1[k] = v
- end
- end
- 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
-
-local registered_server_hooks = {}
-
----@param server_name string
----@param fn fun(config: table)
-function M.register_server_hook(server_name, fn)
- if not registered_server_hooks[server_name] then
- registered_server_hooks[server_name] = {}
- end
- table.insert(registered_server_hooks[server_name], fn)
-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)
- elseif should_auto_install(server.name) then
- notify("(automatic installation) Installing LSP server: " .. server.name)
- server:install()
- end
- end
-
- if registered_server_hooks[config.name] then
- _.each(function(fn)
- local ok, err = pcall(fn, config)
- if not ok then
- notify(err, vim.log.levels.ERROR)
- end
- end, registered_server_hooks[config.name])
- end
- end)
-end
-
-return M