Revert "improve launching time"

This reverts commit b08bfd6839.
neovim_0_5
ray-x 3 years ago
parent 0d29116b18
commit f16893fc4f

@ -288,47 +288,49 @@ local function wait_lsp_startup(ft, retry, lsp_opts)
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.textDocument.completion.completionItem.snippetSupport = true capabilities.textDocument.completion.completionItem.snippetSupport = true
for _, client in ipairs(clients) do for _ = 1, 2 do
if client ~= nil then for _, client in ipairs(clients) do
table.insert(loaded, client.name) if client ~= nil then
end table.insert(loaded, client.name)
end
for _, lspclient in ipairs(servers) do
if lsp_opts[lspclient] ~= nil and lsp_opts[lspclient].filetypes ~= nil then
if not vim.tbl_contains(lsp_opts[lspclient].filetypes, ft) then
trace("ft", ft, "disabled for", lspclient)
goto continue
end end
end end
local cfg = setups[lspclient] or default_cfg for _, lspclient in ipairs(servers) do
-- if user provides override values if lsp_opts[lspclient] ~= nil and lsp_opts[lspclient].filetypes ~= nil then
if not vim.tbl_contains(lsp_opts[lspclient].filetypes, ft) then
trace("ft", ft, "disabled for", lspclient)
goto continue
end
end
local cfg = setups[lspclient] or default_cfg
-- if user provides override values
cfg.capabilities = capabilities cfg.capabilities = capabilities
if lsp_opts[lspclient] ~= nil then if lsp_opts[lspclient] ~= nil then
-- log(lsp_opts[lspclient], cfg) -- log(lsp_opts[lspclient], cfg)
cfg = vim.tbl_deep_extend("force", cfg, lsp_opts[lspclient]) cfg = vim.tbl_deep_extend("force", cfg, lsp_opts[lspclient])
end end
load_cfg(ft, lspclient, cfg, loaded) load_cfg(ft, lspclient, cfg, loaded)
::continue:: ::continue::
end end
if not retry or ft == nil then if not retry or ft == nil then
return return
end
--
local timer = vim.loop.new_timer()
local i = 0
timer:start(1000, 200, function()
clients = vim.lsp.get_active_clients() or {}
i = i + 1
if i > 5 or #clients > 0 then
timer:close() -- Always close handles to avoid leaks.
log("active", #clients, i)
_Loading = false
return true
end end
_Loading = false --
end) local timer = vim.loop.new_timer()
local i = 0
vim.wait(1000, function()
clients = vim.lsp.get_active_clients() or {}
i = i + 1
if i > 5 or #clients > 0 then
timer:close() -- Always close handles to avoid leaks.
log("active", #clients, i)
_Loading = false
return true
end
_Loading = false
end, 300)
end
end end
local function setup(user_opts) local function setup(user_opts)

@ -115,11 +115,12 @@ local function set_mapping(user_opts)
end end
if ccls then if ccls then
-- log("override ccls", ccls_mappings) log("override ccls", ccls_mappings)
for _, value in pairs(ccls_mappings) do for _, value in pairs(ccls_mappings) do
f = "<Cmd>lua " .. value.func .. "<CR>" f = "<Cmd>lua " .. value.func .. "<CR>"
local k = value.key local k = value.key
local m = value.mode or "n" local m = value.mode or "n"
log(f, k, m)
set_keymap(m, k, f, opts) set_keymap(m, k, f, opts)
end end
end end

@ -268,7 +268,7 @@ function M.locations_to_items(locations)
item.range = locations[i].range item.range = locations[i].range
if is_win then if is_win then
log(item.uri) -- file:///C:/path/to/file log(item.uri)
log(cwd) log(cwd)
end end
-- only load top 30 file. -- only load top 30 file.

Loading…
Cancel
Save