|
|
@ -393,8 +393,8 @@ local ng_default_cfg = {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-- check and load based on file type
|
|
|
|
-- check and load based on file type
|
|
|
|
local function load_cfg(ft, client, cfg, loaded)
|
|
|
|
local function load_cfg(ft, client, cfg, loaded, starting)
|
|
|
|
log(ft, client, loaded)
|
|
|
|
log(ft, client, loaded, starting)
|
|
|
|
trace(cfg)
|
|
|
|
trace(cfg)
|
|
|
|
if lspconfig[client] == nil then
|
|
|
|
if lspconfig[client] == nil then
|
|
|
|
log('not supported by nvim', client)
|
|
|
|
log('not supported by nvim', client)
|
|
|
@ -431,6 +431,22 @@ local function load_cfg(ft, client, cfg, loaded)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local clients = vim.lsp.buf_get_clients(0)
|
|
|
|
|
|
|
|
for _, c in pairs(clients or {}) do
|
|
|
|
|
|
|
|
log("lsp start up in progress client", client, c.name)
|
|
|
|
|
|
|
|
if c.name == client then
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if starting and (starting.cnt or 0) > 0 then
|
|
|
|
|
|
|
|
log("lsp start up in progress", starting)
|
|
|
|
|
|
|
|
return vim.defer_fn(function()
|
|
|
|
|
|
|
|
load_cfg(ft, client, cfg, loaded, { cnt = starting.cnt - 1 })
|
|
|
|
|
|
|
|
end,
|
|
|
|
|
|
|
|
200)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if lspconfig[client] == nil then
|
|
|
|
if lspconfig[client] == nil then
|
|
|
|
error('client ' .. client .. ' not supported')
|
|
|
|
error('client ' .. client .. ' not supported')
|
|
|
|
return
|
|
|
|
return
|
|
|
@ -440,8 +456,18 @@ local function load_cfg(ft, client, cfg, loaded)
|
|
|
|
log('lspconfig setup')
|
|
|
|
log('lspconfig setup')
|
|
|
|
-- log(lspconfig.available_servers())
|
|
|
|
-- log(lspconfig.available_servers())
|
|
|
|
-- force reload with config
|
|
|
|
-- force reload with config
|
|
|
|
|
|
|
|
-- lets have a guard here
|
|
|
|
|
|
|
|
if not _NG_Loaded[client] then
|
|
|
|
|
|
|
|
log(client, 'loading for', ft, cfg)
|
|
|
|
|
|
|
|
log(lspconfig[client])
|
|
|
|
lspconfig[client].setup(cfg)
|
|
|
|
lspconfig[client].setup(cfg)
|
|
|
|
log(client, 'loading for', ft)
|
|
|
|
vim.defer_fn(function()
|
|
|
|
|
|
|
|
vim.cmd([[doautocmd Filetype]])
|
|
|
|
|
|
|
|
end, 40)
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
vim.cmd([[doautocmd Filetype]])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
_NG_Loaded[client] = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- need to verify the lsp server is up
|
|
|
|
-- need to verify the lsp server is up
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -555,7 +581,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
|
|
|
|
|
|
|
log(lspclient)
|
|
|
|
log(lspclient)
|
|
|
|
-- if user provides override values
|
|
|
|
-- if user provides override values
|
|
|
|
cfg.capabilities = capabilities
|
|
|
|
-- cfg.capabilities = capabilities
|
|
|
|
log(lspclient, config.lsp.disable_format_cap)
|
|
|
|
log(lspclient, config.lsp.disable_format_cap)
|
|
|
|
if vim.tbl_contains(config.lsp.disable_format_cap or {}, lspclient) then
|
|
|
|
if vim.tbl_contains(config.lsp.disable_format_cap or {}, lspclient) then
|
|
|
|
log('fileformat disabled for ', lspclient)
|
|
|
|
log('fileformat disabled for ', lspclient)
|
|
|
@ -666,11 +692,14 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
if _NG_Loaded[lspclient] then
|
|
|
|
if _NG_Loaded[lspclient] then
|
|
|
|
log('client loaded ?', lspclient)
|
|
|
|
log('client loaded ?', lspclient, _NG_Loaded[lspclient])
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
local starting = {}
|
|
|
|
|
|
|
|
if _NG_Loaded[lspclient] == true then
|
|
|
|
|
|
|
|
starting = { cnt = 1 }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
load_cfg(ft, lspclient, cfg, loaded)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_NG_Loaded[lspclient] = true
|
|
|
|
load_cfg(ft, lspclient, cfg, loaded, starting)
|
|
|
|
-- load_cfg(ft, lspclient, {}, loaded)
|
|
|
|
-- load_cfg(ft, lspclient, {}, loaded)
|
|
|
|
::continue::
|
|
|
|
::continue::
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -843,6 +872,13 @@ local function on_filetype()
|
|
|
|
return
|
|
|
|
return
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if _NG_Loaded[ft] and _NG_Loaded[ft] > 1 then
|
|
|
|
|
|
|
|
log('navigator was loaded for ft', ft, bufnr)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_NG_Loaded[ft] = _NG_Loaded[ft] and _NG_Loaded[ft] + 1 or 1 -- do not hook and trigger filetype event multiple times
|
|
|
|
|
|
|
|
-- as setup will send filetype event as well
|
|
|
|
log(uri)
|
|
|
|
log(uri)
|
|
|
|
|
|
|
|
|
|
|
|
local wids = vim.fn.win_findbuf(bufnr)
|
|
|
|
local wids = vim.fn.win_findbuf(bufnr)
|
|
|
|