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
Use escape to close hunk preview #385
Comments
Is moving the cursor not sufficient? |
This isn't big issue but I caught myself trying to close hunk preview with Esc many tines, it just feels natural. I then immediately realise I have to move cursor, so it's fine, but I personally think it would be a good addition. (While I am here, thanks for all your work on gitsigns and impatient plugins, very appreciated! ❤️) |
Ok we can consider doing this then. |
Exactly this. |
So, had a stab at implementing this and turns out to be a little tricky. The main issue is the preview windows don't automatically get focus when they are shown, which means the mapping would need to be applied to the main buffer. We obviously don't want this mapping to persist, so it needs to be a one-shot mapping, like a @gegoune any ideas? |
I don't know nvim internals enough to suggest anything meaningful, but can you maybe get window id when creating preview window, then create mapping that would close that window and delete mapping on window deletion? If not, that's fine, I am used to moving cursor now so it's not really a deal breaker at all. Just nice to have. Thanks for the plugin, it's amazing! ❤️ |
I think implementing this will be more trouble than it's worth. Will accept any PR's that implement this well. |
Bind something like this this in vim.keymap.set('n', '<esc>', function ()
for _, id in ipairs(vim.api.nvim_list_wins()) do
if vim.api.nvim_win_get_config(id).relative ~= "" then
vim.api.nvim_win_close(id, false)
end
end
end, { buffer = buffer }) |
Thanks this worked! |
gitgutter has an option to close hunk preview windows on escape. See here : https://github.com/airblade/vim-gitgutter/blob/256702dd1432894b3607d3de6cd660863b331818/doc/gitgutter.txt#L351
Would it be possible to implement it in gitsigns?
The text was updated successfully, but these errors were encountered: