-
-
Notifications
You must be signed in to change notification settings - Fork 195
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(actions): Automatic inline diff preview on hover #817
base: main
Are you sure you want to change the base?
Conversation
By calling `Gitsigns automatic_hunk_inline` or by enabling `Config.automatic_hunk_inline` when the cursor is on an hunk (added, modified or removed) `preview_hunk_inline` is called automatically. If the cursor moves inside the hunk's bounds the extmark doesn't flicker, if it exits the hunk the extmarks are cleared automatically. It works via an autocommand triggering on CursorMoved. It takes `_inline2` into consideration. `Config.automatic_hunk_inline` is an option to enable the functionality by default on new buffers.
I'm not sure if this is necessary. There is also |
In that case I think you'd be better off opening the full diffview or opening regular preview so you can navigate the hunk. Note that you cannot navigate deleted lines in inline preview. Otherwise we could probably explore other ways to invoke
They still have to call this new function though? I can't imagine anyone having this enabled by default. It's cool eye-candy, but I don't think it's that practical, especially since other features can already achieve roughly the same thing.
This is something that can be fixed. Though I do plan on deprecating Can you not get a similar effect of this by just calling |
This would be cool. Wouldn't it be possible with
I will think about a solution, though I think the cursor movement is the primary reason for wanting to clear the preview. I don't think making the user call the clear themself is a good solution maybe a better idea will come up.
They would only need to do it once per buffer or through the option. (Perhaps nobody would want it enabled by default idk)
This would be interesting for me I think I tried with the vim.api.nvim_create_autocmd("CursorMoved", {
buffer = 0,
command = "Gitsigns preview_hunk_inline"
})
flickering.mp4I understand your concerns against my PR. Thank you once again for considering it, I genuinely enjoy your plugins, have a nice day |
I might be a bit more open to having this as an option to the eventual I think it's mostly the API surface area and generally how the feature is presented is my main concern. If it can integrate better with existing (or future in this case) features, then that's an easier sell. So the answer is not "no", but we'll need to sit on this for a while. And given how I'm stretched across nvim core, it could be a while. Hope that's ok. |
Introducing the ability to preview inline diffs when hovering over a hunk that has been added, modified, or removed.
To activate this functionality, you can either call the
Gitsigns automatic_hunk_inline
function directly to toggle it or have it by default in a new buffer by enablingConfig.automatic_hunk_inline
option.When the cursor is placed on a hunk, the
preview_hunk_inline
function will be triggered automatically. Notably, if the cursor moves within the hunk's boundaries, the extmark (marker) will not flicker. However, if the cursor exits the hunk, the extmarks will be cleared automatically.This behavior is achieved through an autocommand that listens for the
CursorMoved
event. Additionally, the implementation takes into consideration the_inline2
variant.