feat(words): add fold_open and set_jump_point config options (#31)

## Description
Added `fold_open` and `set_jump_point` as config options for
`Snacks.words.jump`.
This commit is contained in:
Chris Grieser 2024-11-08 14:18:39 +01:00 committed by GitHub
parent 5ccf72e6d0
commit 5dc749b045
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 0 deletions

View file

@ -11,6 +11,8 @@ local defaults = {
debounce = 200, -- time in ms to wait before updating
notify_jump = false, -- show a notification when jumping
notify_end = true, -- show a notification when reaching the end
foldopen = true, -- open folds after jumping
jumplist = true, -- set jump point before jumping
modes = { "n", "i", "c" }, -- modes to show references
}
@ -104,10 +106,16 @@ function M.jump(count, cycle)
end
local target = words[idx]
if target then
if config.jumplist then
vim.cmd.normal({ "m`", bang = true })
end
vim.api.nvim_win_set_cursor(0, target.from)
if config.notify_jump then
Snacks.notify.info(("Reference [%d/%d]"):format(idx, #words), { id = "snacks.words.jump", title = "Words" })
end
if config.foldopen then
vim.cmd.normal({ "zv", bang = true })
end
elseif config.notify_end then
Snacks.notify.warn("No more references", { id = "snacks.words.jump", title = "Words" })
end