gitsigns.nvim
gitsigns.nvim copied to clipboard
Toggle stage hunk
Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
When I accidentally stage the hunk my cursor is under, it's frustrating that I can't use the same keybind / command to toggle the staged status of the hunk. I know that undo_stage exists, but it's on a separate keybind, and I couldn't find a way to make a custom mapping which performs one of the actions based on whether the current hunk is staged or not.
Describe the solution you'd like A clear and concise description of what you want to happen.
A hunk_toggle_staged action which stages the hunk under the cursor if unstaged, and vice versa.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Registering a custom command; using the cmdline to find out whether the current line is staged.
Additional context Add any other context or screenshots about the feature request here.
Great idea! I would change it a bit to a line_toggle_staged, not whole hunk
It's gonna be tricky to implement. Git doesn't keep track of hunks staged. It's a pile fo staged hunks for a given file only.
Gitsigns can already track staged hunks if you set _signs_staged_enable = true in setup(). It works by running an extra diff against HEAD and subtracting the hunks.
@lewis6991 Is there any particular reason for this option to not be documented?
Because it isn't finished.
Fair enough!
Done in #1039