Skip to content

Commit

Permalink
feat: added config.jump.autojump. Fixes #5
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Jun 21, 2023
1 parent f72f3cb commit 1808d3e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ Install the plugin with your preferred package manager:
register = false,
-- clear highlight after jump
nohlsearch = false,
-- automatically jump when there is only one match
autojump = false,
},
highlight = {
label = {
Expand All @@ -151,6 +153,10 @@ Install the plugin with your preferred package manager:
label = "FlashLabel",
},
},
-- action to perform when picking a label.
-- defaults to the jumping logic depending on the mode.
---@type fun(match:Flash.Match, state:Flash.State)|nil
action = nil,
-- You can override the default options for a specific mode.
-- Use it with `require("flash").jump({mode = "forward"})`
---@type table<string, Flash.Config>
Expand Down
4 changes: 4 additions & 0 deletions lua/flash/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ function M.jump(opts)
if #state.results == 0 and not state.pattern:empty() then
break
end
if #state.results == 1 and state.opts.jump.autojump then
state:jump()
break
end
end
state:hide()
return state
Expand Down
2 changes: 2 additions & 0 deletions lua/flash/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ local defaults = {
register = false,
-- clear highlight after jump
nohlsearch = false,
-- automatically jump when there is only one match
autojump = false,
},
highlight = {
label = {
Expand Down

0 comments on commit 1808d3e

Please sign in to comment.