feat: Jump highlight customizations
Closes #27 - Highlight group 'OutlineJumpHighlight' (links to Visual by default) - Config: outline_window.jump_highlight_duration (integer for milliseconds, or boolean to enable/disable)
This commit is contained in:
@@ -32,6 +32,7 @@ M.defaults = {
|
||||
show_cursorline = true,
|
||||
hide_cursor = false,
|
||||
winhl = "OutlineDetails:Comment,OutlineLineno:LineNr",
|
||||
jump_highlight_duration = 500,
|
||||
},
|
||||
preview_window = {
|
||||
auto_preview = false,
|
||||
|
||||
@@ -105,7 +105,17 @@ function M.__goto_location(change_focus)
|
||||
M.state.code_win,
|
||||
{ node.line + 1, node.character }
|
||||
)
|
||||
utils.flash_highlight(M.state.code_win, node.line + 1, true)
|
||||
|
||||
if vim.fn.hlexists('OutlineJumpHighlight') == 0 then
|
||||
vim.api.nvim_set_hl(0, 'OutlineJumpHighlight', { link = 'Visual' })
|
||||
end
|
||||
utils.flash_highlight(
|
||||
M.state.code_win,
|
||||
node.line + 1,
|
||||
cfg.o.outline_window.jump_highlight_duration,
|
||||
'OutlineJumpHighlight'
|
||||
)
|
||||
|
||||
if change_focus then
|
||||
vim.fn.win_gotoid(M.state.code_win)
|
||||
end
|
||||
|
||||
@@ -111,9 +111,12 @@ function M.merge_items_rec(new_node, old_node, index, parent)
|
||||
end
|
||||
|
||||
function M.flash_highlight(winnr, lnum, durationMs, hl_group)
|
||||
if durationMs == false then
|
||||
return
|
||||
end
|
||||
hl_group = hl_group or "Visual"
|
||||
if durationMs == true or durationMs == 1 then
|
||||
durationMs = 300
|
||||
durationMs = 500
|
||||
end
|
||||
local bufnr = vim.api.nvim_win_get_buf(winnr)
|
||||
local ns = vim.api.nvim_buf_add_highlight(bufnr, 0, hl_group, lnum - 1, 0, -1)
|
||||
|
||||
Reference in New Issue
Block a user