|
|
|
@ -432,8 +432,25 @@ local function load_cfg(ft, client, cfg, loaded)
|
|
|
|
|
-- need to verify the lsp server is up
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function setup_fmt(client, enabled)
|
|
|
|
|
if not require('navigator.util').nvim_0_8() then
|
|
|
|
|
if enabled == false then
|
|
|
|
|
client.resolved_capabilities.document_formatting = enabled
|
|
|
|
|
else
|
|
|
|
|
client.resolved_capabilities.document_formatting = client.resolved_capabilities.document_formatting or enabled
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if enabled == false then
|
|
|
|
|
client.server_capabilities.documentFormattingProvider = false
|
|
|
|
|
else
|
|
|
|
|
client.server_capabilities.documentFormattingProvider = client.server_capabilities.documentFormattingProvider
|
|
|
|
|
or enabled
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local function update_capabilities()
|
|
|
|
|
trace(ft, 'lsp startup')
|
|
|
|
|
trace(vim.o.ft, 'lsp startup')
|
|
|
|
|
local loaded = {}
|
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
|
|
|
@ -521,6 +538,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
-- filetype disabled
|
|
|
|
|
if not vim.tbl_contains(cfg.filetypes or {}, ft) then
|
|
|
|
|
trace('ft', ft, 'disabled for', lspclient)
|
|
|
|
|
|
|
|
|
|
goto continue
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -539,15 +557,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
-- log(lsp_opts[lspclient], cfg)
|
|
|
|
|
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 enable_fmt then
|
|
|
|
|
client.server_capabilities.documentFormattingProvider = client.server_capabilities.documentFormattingProvider
|
|
|
|
|
or enable_fmt
|
|
|
|
|
else
|
|
|
|
|
client.server_capabilities.documentFormattingProvider = false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
setup_fmt(client, enable_fmt)
|
|
|
|
|
end
|
|
|
|
|
if config.combined_attach == 'mine' then
|
|
|
|
|
if config.on_attach == nil then
|
|
|
|
@ -555,12 +565,8 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
end
|
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
|
config.on_attach(client, bufnr)
|
|
|
|
|
if enable_fmt then
|
|
|
|
|
client.server_capabilities.documentFormattingProvider = client.server_capabilities.documentFormattingProvider
|
|
|
|
|
or enable_fmt
|
|
|
|
|
else
|
|
|
|
|
client.server_capabilities.documentFormattingProvider = false
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
setup_fmt(client, enable_fmt)
|
|
|
|
|
require('navigator.lspclient.mapping').setup({
|
|
|
|
|
client = client,
|
|
|
|
|
bufnr = bufnr,
|
|
|
|
@ -572,12 +578,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
|
on_attach(client, bufnr)
|
|
|
|
|
config.on_attach(client, bufnr)
|
|
|
|
|
if enable_fmt then
|
|
|
|
|
client.server_capabilities.documentFormattingProvider = client.server_capabilities.documentFormattingProvider
|
|
|
|
|
or enable_fmt
|
|
|
|
|
else
|
|
|
|
|
client.server_capabilities.documentFormattingProvider = false
|
|
|
|
|
end
|
|
|
|
|
setup_fmt(client, enable_fmt)
|
|
|
|
|
require('navigator.lspclient.mapping').setup({
|
|
|
|
|
client = client,
|
|
|
|
|
bufnr = bufnr,
|
|
|
|
@ -587,12 +588,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
end
|
|
|
|
|
if config.combined_attach == 'both' then
|
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
|
if enable_fmt then
|
|
|
|
|
client.server_capabilities.documentFormattingProvider = client.server_capabilities.documentFormattingProvider
|
|
|
|
|
or enable_fmt
|
|
|
|
|
else
|
|
|
|
|
client.server_capabilities.documentFormattingProvider = false
|
|
|
|
|
end
|
|
|
|
|
setup_fmt(client, enable_fmt)
|
|
|
|
|
|
|
|
|
|
if config.on_attach and type(config.on_attach) == 'function' then
|
|
|
|
|
config.on_attach(client, bufnr)
|
|
|
|
@ -622,12 +618,7 @@ local function lsp_startup(ft, retry, user_lsp_opts)
|
|
|
|
|
cfg.on_attach = function(client, bufnr)
|
|
|
|
|
on_attach(client, bufnr)
|
|
|
|
|
|
|
|
|
|
if enable_fmt then
|
|
|
|
|
client.server_capabilities.documentFormattingProvider = client.server_capabilities.documentFormattingProvider
|
|
|
|
|
or enable_fmt
|
|
|
|
|
else
|
|
|
|
|
client.server_capabilities.documentFormattingProvider = false
|
|
|
|
|
end
|
|
|
|
|
setup_fmt(client, enable_fmt)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|