refactor(flash): update flash plugin keybindings for navigation

This commit is contained in:
Prad Nukala committed 2026-07-12 15:55:48 -04:00
1 parent e9d286d705
commit 6789eab509
1 file changed
+7 -10
+7 -10
View File
@@ -39,25 +39,22 @@ return {
mode = "n", mode = "n",
function() function()
-- Search-style flash: type a regex pattern and labels appear on -- Search-style flash: type a regex pattern and labels appear on
-- every match. While selecting, `n`/`N` cycle to the next/previous -- every match. While selecting, `<C-n>`/`<C-b>` cycle to the
-- result (flash consumes action keys before pattern input, so n/N -- next/previous result, <CR> confirms the selection, a label jumps
-- can't be typed into the pattern -- use `s` for those), <CR> -- directly, <Esc> cancels back to the origin. The pattern is pushed
-- confirms the selection, a label jumps directly, <Esc> cancels -- to search history and the `/` register, so `n`/`N` keep working
-- back to the origin. The pattern is pushed to search history and -- after the jump.
-- the `/` register, so `n`/`N` keep working after the jump.
local current ---@type Flash.Match? local current ---@type Flash.Match?
require("flash").jump { require("flash").jump {
search = { mode = "search" }, search = { mode = "search" },
jump = { history = true, register = true, nohlsearch = true }, jump = { history = true, register = true, nohlsearch = true },
-- n/N are cycle keys, so never assign them as jump labels
label = { exclude = "nN" },
actions = { actions = {
["n"] = function(state) ["<c-n>"] = function(state)
-- first press selects the current target, then cycle forward -- first press selects the current target, then cycle forward
current = current and state:find { match = current, forward = true, wrap = true } or state.target current = current and state:find { match = current, forward = true, wrap = true } or state.target
if current then state:jump(current) end if current then state:jump(current) end
end, end,
["N"] = function(state) ["<c-b>"] = function(state)
current = state:find { match = current or state.target, forward = false, wrap = true } current = state:find { match = current or state.target, forward = false, wrap = true }
if current then state:jump(current) end if current then state:jump(current) end
end, end,