Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: search empty line #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lua/hop/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,14 @@ function M.hint_lines_skip_whitespace(opts)
M.hint_with_regex(jump_regex.regex_by_line_start_skip_whitespace(), opts)
end

---@param opts Options
function M.hint_empty_line(opts)
local jump_regex = require('hop.jump_regex')

opts = override_opts(opts)
M.hint_with_regex(jump_regex.regex_empty_line(), opts)
end

---@param opts Options
function M.hint_anywhere(opts)
local jump_regex = require('hop.jump_regex')
Expand Down
17 changes: 17 additions & 0 deletions lua/hop/jump_regex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,23 @@ function M.regex_by_line_start_skip_whitespace()
}
end

-- Line regex skipping finding the first non-whitespace character on each line.
---@return Regex
function M.regex_empty_line()
local regex = vim.regex('^\\s*$')

return {
oneshot = true,
---@param jctx JumpContext
match = function(s, jctx)
if window.is_active_line(jctx.win_ctx, jctx.line_ctx) then
return
end
return regex:match_str(s)
end,
}
end

-- Anywhere regex.
---@return Regex
function M.regex_by_anywhere()
Expand Down