code action flicker

neovim_0.6^2
ray-x 2 years ago
parent 3f49769abc
commit d0ab595b93

@ -54,6 +54,7 @@ _NgConfigValues = {
severity_sort = { reverse = true },
},
format_on_save = true, -- set to false to disasble lsp code format on save (if you are using prettier/efm/formater etc)
disable_nulls_codeaction_sign = true, -- do not show nulls codeactions (as it will alway has a valid action)
disable_format_cap = {}, -- a list of lsp disable file format (e.g. if you using efm or vim-codeformat etc), empty by default
disable_lsp = {}, -- a list of lsp server disabled for your project, e.g. denols and tsserver you may
-- only want to enable one lsp server

@ -52,20 +52,24 @@ local function _update_sign(line)
if code_action[winid] == nil then
code_action[winid] = {}
end
if code_action[winid].lightbulb_line ~= 0 then
-- only show code action on the current line, remove all others
if code_action[winid].lightbulb_line and code_action[winid].lightbulb_line > 0 then
vim.fn.sign_unplace(sign_group, { id = code_action[winid].lightbulb_line, buffer = '%' })
log('sign removed', line)
end
if line then
-- log("updatasign", line, sign_group, sign_name)
vim.fn.sign_place(
local id = vim.fn.sign_place(
line,
sign_group,
sign_name,
'%',
{ lnum = line + 1, priority = config.lsp.code_action.sign_priority }
)
code_action[winid].lightbulb_line = line
code_action[winid].lightbulb_line = id
log('sign updated', id)
end
end
@ -74,6 +78,14 @@ local need_check_diagnostic = { ['python'] = true }
function code_action:render_action_virtual_text(line, diagnostics)
return function(err, actions, context)
trace(actions, context)
if context and context.client_id then
local cname = vim.lsp.get_active_clients({ id = context.client_id })[1].name
if cname == 'null-ls' and _NgConfigValues.lsp.disable_nulls_codeaction_sign then
return
end
end
-- if nul-ls enabled, some of the lsp may not send valid code action,
if actions == nil or type(actions) ~= 'table' or vim.tbl_isempty(actions) then
-- no actions cleanup
if config.lsp.code_action.virtual_text then
@ -84,12 +96,13 @@ function code_action:render_action_virtual_text(line, diagnostics)
end
else
trace(err, line, diagnostics, actions, context)
if config.lsp.code_action.sign then
if need_check_diagnostic[vim.bo.filetype] then
if next(diagnostics) == nil then
-- no diagnostic, no code action sign..
_update_sign(nil)
else
-- no diagnostic, no code action sign..
_update_sign(line)
end
else

Loading…
Cancel
Save