disable all lsp #49 by setting disable_lsp='all'

neovim_0_5
ray-x 3 years ago
parent dd4b04159d
commit d39cf20903

@ -226,6 +226,8 @@ require'navigator'.setup({
disable_format_ft = {"sqls", "sumneko_lua", "gopls"}, -- a list of lsp not enable auto-format (e.g. if you using efm or vim-codeformat etc), empty by default
disable_lsp = {'pylsd', 'sqlls'}, -- a list of lsp server disabled for your project, e.g. denols and tsserver you may
-- only want to enable one lsp server
-- to disable all default config and use your own lsp setup set
-- disable_lsp = 'all'
diagnostic_scroll_bar_sign = {'▃', '█'}, -- experimental: diagnostic status in scroll bar area; set to nil to disable the diagnostic sign,
-- for other style, set to {'╍', 'ﮆ'} or {'-', '='}
diagnostic_virtual_text = true, -- show virtual for diagnostic message

@ -24,6 +24,8 @@ if packer_plugins ~= nil then -- packer install
if _NgConfigValues.lspinstall == true then
local has_lspinst, lspinst = pcall(require, "lspinstall")
lspinst.setup()
if has_lspinst then
lspinst.setup()
end
end
end

@ -67,11 +67,11 @@ library[vim.fn.expand("$VIMRUNTIME/lua/vim/lsp")] = true
local path_sep = require"navigator.util".path_sep()
local strip_dir_pat = path_sep .. "([^" .. path_sep .. "]+)$"
local strip_sep_pat = path_sep .. "$"
local dirname = function(path)
if not path or #path == 0 then
local dirname = function(pathname)
if not pathname or #pathname == 0 then
return
end
local result = path:gsub(strip_sep_pat, ""):gsub(strip_dir_pat, "")
local result = pathname:gsub(strip_sep_pat, ""):gsub(strip_dir_pat, "")
if #result == 0 then
return "/"
end
@ -241,7 +241,7 @@ local servers = {
"r_language_server", "rust_analyzer", "terraformls"
}
if _NgConfigValues.lspinstall == true then
if config.lspinstall == true then
local has_lspinst, lspinst = pcall(require, "lspinstall")
if has_lspinst then
local srvs = lspinst.installed_servers()
@ -252,6 +252,10 @@ if _NgConfigValues.lspinstall == true then
end
end
if config.lsp.disable_lsp == 'all' then
config.lsp.disable_lsp = servers
end
local default_cfg = {
on_attach = on_attach,
flags = {allow_incremental_sync = true, debounce_text_changes = 500}
@ -297,6 +301,7 @@ local function load_cfg(ft, client, cfg, loaded)
return
end
log("load cfg", cfg)
lspconfig[client].setup(cfg)
-- dont know why but 1st lsp client setup may fail.. could be a upstream defect
lspconfig[client].setup(cfg)
@ -333,8 +338,7 @@ local function wait_lsp_startup(ft, retry, user_lsp_opts)
goto continue
end
end
if vim.tbl_contains(_NgConfigValues.lsp.disable_lsp or {}, lspclient) then
if vim.tbl_contains(config.lsp.disable_lsp or {}, lspclient) then
log("disable lsp", lspconfig)
goto continue
end
@ -352,10 +356,9 @@ local function wait_lsp_startup(ft, retry, user_lsp_opts)
end
default_config = vim.tbl_deep_extend("force", default_config, default_cfg)
local cfg = setups[lspclient] or {}
cfg = vim.tbl_deep_extend("keep", cfg, default_config)
if not vim.tbl_contains(cfg.filetypes, ft) then
if not vim.tbl_contains(cfg.filetypes or {}, ft) then
trace("ft", ft, "disabled for", lspclient)
goto continue
end
@ -366,13 +369,13 @@ local function wait_lsp_startup(ft, retry, user_lsp_opts)
-- log(lsp_opts[lspclient], cfg)
local disable_fmt = false
log(lspclient, _NgConfigValues.lsp.disable_format_ft)
if vim.tbl_contains(_NgConfigValues.lsp.disable_format_ft or {}, lspclient) then
log(lspclient, config.lsp.disable_format_ft)
if vim.tbl_contains(config.lsp.disable_format_ft or {}, lspclient) then
log("fileformat disabled for ", lspclient)
disable_fmt = true
end
cfg = vim.tbl_deep_extend("force", cfg, user_lsp_opts[lspclient])
if _NgConfigValues.combined_attach == nil then
if config.combined_attach == nil then
cfg.on_attach = function(client, bufnr)
on_attach(client, bufnr)
if disable_fmt then
@ -380,21 +383,21 @@ local function wait_lsp_startup(ft, retry, user_lsp_opts)
end
end
end
if _NgConfigValues.combined_attach == "mine" then
if _NgConfigValues.on_attach == nil then
if config.combined_attach == "mine" then
if config.on_attach == nil then
error("on attach not provided")
end
cfg.on_attach = function(client, bufnr)
_NgConfigValues.on_attach(client, bufnr)
config.on_attach(client, bufnr)
if disable_fmt then
client.resolved_capabilities.document_formatting = false
end
end
end
if _NgConfigValues.combined_attach == "both" then
if config.combined_attach == "both" then
cfg.on_attach = function(client, bufnr)
if _NgConfigValues.on_attach then
_NgConfigValues.on_attach(client, bufnr)
if config.on_attach then
config.on_attach(client, bufnr)
end
if setups[lspclient] and setups[lspclient].on_attach then
setups[lspclient].on_attach(client, bufnr)
@ -409,6 +412,7 @@ local function wait_lsp_startup(ft, retry, user_lsp_opts)
end
load_cfg(ft, lspclient, cfg, loaded)
-- load_cfg(ft, lspclient, {}, loaded)
::continue::
end
@ -439,14 +443,14 @@ end
local function setup(user_opts)
local ft = vim.bo.filetype
if _LoadedClients[ft] then
log("navigator is loaded for ft", ft)
-- log("navigator is loaded for ft", ft)
return
end
if user_opts ~= nil then
log("navigator setup", user_opts)
end
trace(debug.traceback())
user_opts = user_opts or _NgConfigValues -- incase setup was triggered from autocmd
user_opts = user_opts or config -- incase setup was triggered from autocmd
if _NG_Loading == true then
return
@ -507,9 +511,5 @@ local function setup(user_opts)
_NG_Loading = false
-- if not _NgConfigValues.loaded then
-- vim.cmd([[autocmd FileType * lua require'navigator.lspclient.clients'.setup()]]) -- BufWinEnter BufNewFile,BufRead ?
-- _NgConfigValues.loaded = true
-- end
end
return {setup = setup}

@ -477,7 +477,7 @@ local function node_in_range(parser, range)
if child:contains(range) then
local result = node_in_range(child, range)
if not vim.tbl_contains({vim.bo.filetype}, result:lang()) then
log("not correct tree embedded or comment?", result:lang())
-- log("not correct tree embedded or comment?", result:lang())
return parser
end
return result

Loading…
Cancel
Save