sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
3.92k stars 107 forks source link

[Bug] win options clobbered (`winhl`), not set (`winblend`) #515

Open tmillr opened 3 months ago

tmillr commented 3 months ago

Description

Leaving and coming back to the diffview tab, or simply just revisiting one of the diffs (buffers), resets/clobbers all of my winhl customizations. Is there any reason why this plugin is dynamically changing/resetting options on TabLeave, or, when revisiting a previously-viewed buffer (especially given the fact that the window ids remain the same)? This is silly and unexpected behavior imo. How else can I customize winhl? Right now I'm using a DiffviewDiffBufRead autocmd (because setting win opts or config via this plugin seems to be only supported for "panels"?).

I guess in the meantime I need to choose a different autocmd, or force my highlights with a window namespace.

EDIT: it seems that other window options, like spell, are not reset/clobbered. So I assume the winhl issue is because either:

A. winhl is set by this plugin, while spell isn't B. winhl isn't getting set/reset properly (although it probably shouldn't be reset in the first place, unless there is a good reason to do so)

Expected behavior

Actual behavior

See Description

Steps to reproduce

nvim --clean
DiffviewOpen {somerev}

-- Set winhl without clobbering other mappings.
-- This could even be improved further (but I won't do that here), as hl groups are in fact case-insensitive.
local w = vim.opt_local.winhl
w.DiffChange = 'MyDiffChangeAsDiffDelete'
vim.opt_local.winhl = w

-- Now just trigger issue as explained above

Health check

Likely irrelevant, but here it is:

diffview: require("diffview.health").check()

Checking plugin dependencies ~
- OK nvim-web-devicons installed.

Checking VCS tools ~
- The plugin requires at least one of the supported VCS tools to be valid.
- OK Git found.
- OK Git is up-to-date. (2.45.1)
- WARNING Configured `hg_cmd` is not executable: 'hg'

Log info

n/a

Neovim version

0.10

Operating system and version

macOS 14.2.1

Minimal config

n/a, defaults

Maybe related to: #457, #442

tmillr commented 3 months ago

Idk why (it fires on TabEnter), but I guess adding DiffviewDiffBufWinEnter to the events of my autocmd helps as a workaround.

tmillr commented 3 months ago

This also doesn't work:

nvim --clean +"lua require('diffview').setup { commit_log_panel = { win_config = { winopts = { winblend = 10, } } } }"