-
-
Notifications
You must be signed in to change notification settings - Fork 185
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
Ability to jump to the first and the last hunk #800
Comments
I would do |
Thanks, i already tried that. And it doesn't work correctly, if the first hunk starts from the first line. Similarly, the situation with the last hunk is the same |
I wrote those functions, but i'm not sure that's correct: local gitsigns = require('gitsigns')
local function opts()
return {
buffer = bufnr,
unique = true,
}
end
vim.keymap.set('n', '[G', function()
local hunks = gitsigns.get_hunks()
local hunk = hunks[1]
local line = math.min(hunk.added.start, hunk.removed.start)
vim.api.nvim_win_set_cursor(0, { line, 0 })
end, opts())
vim.keymap.set('n', ']G', function()
local hunks = gitsigns.get_hunks()
local hunk = hunks[#hunks]
local line = math.max(hunk.added.start, hunk.removed.start)
vim.api.nvim_win_set_cursor(0, { line, 0 })
end, opts()) |
It's close. The buffer indices are in Try |
What about |
Done in #976 |
Is your feature request related to a problem? Please describe.
It's pretty common to have the comprehensive navigation through a set of items. Usually it includes:
Many plugins' authors follow that pattern. For instance unimpaired.vim and ale.
Describe the solution you'd like
My suggestion is to add the api functions
first_hunk
andlast_hunk
.Describe alternatives you've considered
To write my own functions
first_hunk
andlast_hunk
.The text was updated successfully, but these errors were encountered: