|
|
|
@ -8,7 +8,6 @@ local warn = util.warn
|
|
|
|
|
_NG_Loaded = {}
|
|
|
|
|
|
|
|
|
|
_LoadedFiletypes = {}
|
|
|
|
|
local loader = nil
|
|
|
|
|
packer_plugins = packer_plugins or nil -- suppress warnings
|
|
|
|
|
|
|
|
|
|
-- packer only
|
|
|
|
@ -407,10 +406,7 @@ local function load_cfg(ft, client, cfg, loaded)
|
|
|
|
|
-- need to verify the lsp server is up
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- run setup for lsp clients
|
|
|
|
|
local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
retry = retry or false
|
|
|
|
|
local clients = vim.lsp.get_active_clients() or {}
|
|
|
|
|
local function update_capabilities()
|
|
|
|
|
|
|
|
|
|
trace(ft, 'lsp startup')
|
|
|
|
|
local loaded = {}
|
|
|
|
@ -426,6 +422,17 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
properties = { 'documentation', 'detail', 'additionalTextEdits' },
|
|
|
|
|
}
|
|
|
|
|
capabilities.workspace.configuration = true
|
|
|
|
|
return capabilities
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- run setup for lsp clients
|
|
|
|
|
local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
retry = retry or false
|
|
|
|
|
local clients = vim.lsp.get_active_clients() or {}
|
|
|
|
|
|
|
|
|
|
local loaded = {}
|
|
|
|
|
local capabilities = update_capabilities()
|
|
|
|
|
|
|
|
|
|
for _, client in ipairs(clients) do
|
|
|
|
|
if client ~= nil then
|
|
|
|
@ -493,24 +500,24 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
goto continue
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local disable_fmt = false
|
|
|
|
|
|
|
|
|
|
-- if user provides override values
|
|
|
|
|
cfg.capabilities = capabilities
|
|
|
|
|
log(lspclient, config.lsp.disable_format_cap)
|
|
|
|
|
if vim.tbl_contains(config.lsp.disable_format_cap or {}, lspclient) then
|
|
|
|
|
log('fileformat disabled for ', lspclient)
|
|
|
|
|
disable_fmt = true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local enable_fmt = not disable_fmt
|
|
|
|
|
if user_lsp_opts[lspclient] ~= nil then
|
|
|
|
|
-- log(lsp_opts[lspclient], cfg)
|
|
|
|
|
local disable_fmt = false
|
|
|
|
|
|
|
|
|
|
log(lspclient, config.lsp.disable_format_cap)
|
|
|
|
|
if vim.tbl_contains(config.lsp.disable_format_cap or {}, lspclient) then
|
|
|
|
|
log('fileformat disabled for ', lspclient)
|
|
|
|
|
disable_fmt = true
|
|
|
|
|
end
|
|
|
|
|
cfg = vim.tbl_deep_extend('force', cfg, user_lsp_opts[lspclient])
|
|
|
|
|
if config.combined_attach == nil then
|
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
|
on_attach(client, bufnr)
|
|
|
|
|
if disable_fmt then
|
|
|
|
|
client.resolved_capabilities.document_formatting = false
|
|
|
|
|
end
|
|
|
|
|
client.resolved_capabilities.document_formatting = enable_fmt
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if config.combined_attach == 'mine' then
|
|
|
|
@ -519,9 +526,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
end
|
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
|
config.on_attach(client, bufnr)
|
|
|
|
|
if disable_fmt then
|
|
|
|
|
client.resolved_capabilities.document_formatting = false
|
|
|
|
|
end
|
|
|
|
|
client.resolved_capabilities.document_formatting = enable_fmt
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
if config.combined_attach == 'both' then
|
|
|
|
@ -534,9 +539,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
else
|
|
|
|
|
on_attach(client, bufnr)
|
|
|
|
|
end
|
|
|
|
|
if disable_fmt then
|
|
|
|
|
client.resolved_capabilities.document_formatting = false
|
|
|
|
|
end
|
|
|
|
|
client.resolved_capabilities.document_formatting = enable_fmt
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
cfg.on_init = function(client)
|
|
|
|
@ -548,6 +551,13 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
if disable_fmt then
|
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
|
on_attach(client, bufnr)
|
|
|
|
|
client.resolved_capabilities.document_formatting = enable_fmt
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
log('loading', lspclient, 'name', lspconfig[lspclient].name, 'has lspinst', has_lspinst)
|
|
|
|
@ -717,12 +727,12 @@ local function setup(user_opts)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
-- append lsps to servers
|
|
|
|
|
function add_servers(lsps)
|
|
|
|
|
local function add_servers(lsps)
|
|
|
|
|
vim.validate({ lsps = { lsps, 't' } })
|
|
|
|
|
vim.list_extend(servers, lsps)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function on_filetype()
|
|
|
|
|
local function on_filetype()
|
|
|
|
|
local bufnr = vim.api.nvim_get_current_buf()
|
|
|
|
|
local uri = vim.uri_from_bufnr(bufnr)
|
|
|
|
|
|
|
|
|
|