|
|
|
@ -2,6 +2,8 @@
|
|
|
|
|
local log = require"navigator.util".log
|
|
|
|
|
local trace = require"navigator.util".trace
|
|
|
|
|
local uv = vim.loop
|
|
|
|
|
|
|
|
|
|
local warn = require'navigator.util'.warn
|
|
|
|
|
_NG_Loaded = {}
|
|
|
|
|
|
|
|
|
|
_LoadedFiletypes = {}
|
|
|
|
@ -156,8 +158,7 @@ local setups = {
|
|
|
|
|
},
|
|
|
|
|
rust_analyzer = {
|
|
|
|
|
root_dir = function(fname)
|
|
|
|
|
return util.root_pattern("Cargo.toml", "rust-project.json", ".git")(fname)
|
|
|
|
|
or util.path.dirname(fname)
|
|
|
|
|
return util.root_pattern("Cargo.toml", "rust-project.json", ".git")(fname) or util.path.dirname(fname)
|
|
|
|
|
end,
|
|
|
|
|
filetypes = {"rust"},
|
|
|
|
|
message_level = vim.lsp.protocol.MessageType.error,
|
|
|
|
@ -268,17 +269,19 @@ local servers = {
|
|
|
|
|
"r_language_server", "rust_analyzer", "terraformls", "svelte"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if config.lspinstall == true then
|
|
|
|
|
local has_lspinst, lspinst = pcall(require, "lspinstall")
|
|
|
|
|
local has_lspinst = false
|
|
|
|
|
|
|
|
|
|
if config.lsp_installer == true then
|
|
|
|
|
has_lspinst, _ = pcall(require, "nvim-lsp-installer")
|
|
|
|
|
if has_lspinst then
|
|
|
|
|
local srvs = lspinst.installed_servers()
|
|
|
|
|
log('lspinstalled servers', srvs)
|
|
|
|
|
local srvs = require'nvim-lsp-installer.servers'.get_installed_servers()
|
|
|
|
|
log('lsp_installered servers', srvs)
|
|
|
|
|
if #srvs > 0 then
|
|
|
|
|
servers = srvs
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
log(servers)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if config.lsp.disable_lsp == 'all' then
|
|
|
|
|
config.lsp.disable_lsp = servers
|
|
|
|
|
end
|
|
|
|
@ -288,6 +291,8 @@ local ng_default_cfg = {
|
|
|
|
|
flags = {allow_incremental_sync = true, debounce_text_changes = 1000}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
local configs = {}
|
|
|
|
|
|
|
|
|
|
-- check and load based on file type
|
|
|
|
|
local function load_cfg(ft, client, cfg, loaded)
|
|
|
|
|
-- if _NG_LSPCfgSetup ~= true then
|
|
|
|
@ -295,6 +300,7 @@ local function load_cfg(ft, client, cfg, loaded)
|
|
|
|
|
-- lspconfig_setup(cfg)
|
|
|
|
|
-- _NG_LSPCfgSetup = true
|
|
|
|
|
-- end
|
|
|
|
|
|
|
|
|
|
log(ft, client, loaded)
|
|
|
|
|
if lspconfig[client] == nil then
|
|
|
|
|
log("not supported by nvim", client)
|
|
|
|
@ -373,6 +379,15 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
end
|
|
|
|
|
for _, lspclient in ipairs(servers) do
|
|
|
|
|
-- check should load lsp
|
|
|
|
|
|
|
|
|
|
if type(lspclient) == 'table' then
|
|
|
|
|
if lspclient.name then
|
|
|
|
|
lspclient = lspclient.name
|
|
|
|
|
else
|
|
|
|
|
warn("incorrect set for lspclient", vim.inspect(lspclient))
|
|
|
|
|
goto continue
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if user_lsp_opts[lspclient] ~= nil and user_lsp_opts[lspclient].filetypes ~= nil then
|
|
|
|
|
if not vim.tbl_contains(user_lsp_opts[lspclient].filetypes, ft) then
|
|
|
|
|
trace("ft", ft, "disabled for", lspclient)
|
|
|
|
@ -390,6 +405,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local default_config = {}
|
|
|
|
|
log(lspclient)
|
|
|
|
|
if lspconfig[lspclient] == nil then
|
|
|
|
|
print("lspclient", lspclient, "no longer support by lspconfig, please submit an issue")
|
|
|
|
|
goto continue
|
|
|
|
@ -464,8 +480,18 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
log('loading', lspclient, 'name', lspconfig[lspclient].name)
|
|
|
|
|
log('loading', lspclient, 'name', lspconfig[lspclient].name, 'has lspinst', has_lspinst)
|
|
|
|
|
-- start up lsp
|
|
|
|
|
if has_lspinst and _NgConfigValues.lsp_installer then
|
|
|
|
|
local installed, installer_cfg = require("nvim-lsp-installer.servers").get_server(lspconfig[lspclient].name)
|
|
|
|
|
|
|
|
|
|
log('lsp server', installer_cfg, lspconfig[lspclient].name)
|
|
|
|
|
if installed and installer_cfg then
|
|
|
|
|
cfg.cmd = installer_cfg:get_default_options().cmd
|
|
|
|
|
log(cfg)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
load_cfg(ft, lspclient, cfg, loaded)
|
|
|
|
|
|
|
|
|
|
_NG_Loaded[lspclient] = true
|
|
|
|
@ -489,8 +515,10 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
lspconfig.efm.setup(cfg)
|
|
|
|
|
log('efm loading')
|
|
|
|
|
_NG_Loaded['efm'] = true
|
|
|
|
|
configs['efm'] = cfg
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if not retry or ft == nil then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|