You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When doing diffs of files, (Neo)vim has the behavior of showing the added/deleted lines compared to the other file, BUT in git/github' side-by-side view will instead only show deleted lines on the old file and new lines on the new file (+ changes in both if any).
To make Neovim work this way we can leverage winhighlight to change the diff-related highlight groups for a given window only.
Got the hint at: neovim/neovim#27512 (reply in thread)
And with some tweaks we can go a little further and have this:
❤️
Since this changes the highlights locally to a window, it could give unexpected highlights if changing/swapping buffer in same window, moving windows...
Still it would be nice to have (with hooks to disable the highlight changes to avoid unexpected hl).
Since (Neo)vim doesn't have any knowledge of the old file / current file we'd need to use different commands to mark the old/current file so highlights are changed correctly..
" Set deleted line filler char to a space, to hide themsetlocalfillchars+=diff:\ " On the old file we need:setlocal winhighlight=DiffDelete:Normal,DiffAdd:DiffDelete,DiffText:DiffDelete" => Don't show added lines (use 'Normal' hl)" => Show lines that are not in new/current file as deleted" => Changed text in a line is _old_ text" On the new/current file we need:setlocal winhighlight=DiffDelete:Normal,DiffText:DiffAdd" => Don't show deleted lines (use 'Normal' hl)" => Changed text in a line is _new_ text
NOTE: using Normal hl isn't perfect because it's not 'dynamic' when NormalNC is used to set a different bg color for non-current windows, making the deleted line standout a little on non-current window.
👉 Alternative is to create a dummy hl group like hi Test ctermbg=none ctermfg=none and use it instead of Normal.
The text was updated successfully, but these errors were encountered:
When doing diffs of files, (Neo)vim has the behavior of showing the added/deleted lines compared to the other file, BUT in git/github' side-by-side view will instead only show deleted lines on the old file and new lines on the new file (+ changes in both if any).
To make Neovim work this way we can leverage
winhighlight
to change the diff-related highlight groups for a given window only.Got the hint at:
neovim/neovim#27512 (reply in thread)
And with some tweaks we can go a little further and have this:
❤️
Since this changes the highlights locally to a window, it could give unexpected highlights if changing/swapping buffer in same window, moving windows...
Still it would be nice to have (with hooks to disable the highlight changes to avoid unexpected hl).
Since (Neo)vim doesn't have any knowledge of the old file / current file we'd need to use different commands to mark the old/current file so highlights are changed correctly..
NOTE: using
Normal
hl isn't perfect because it's not 'dynamic' whenNormalNC
is used to set a different bg color for non-current windows, making the deleted line standout a little on non-current window.👉 Alternative is to create a dummy hl group like
hi Test ctermbg=none ctermfg=none
and use it instead ofNormal
.The text was updated successfully, but these errors were encountered: