-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
[RFC] allow window specific ui highlighting (currently only window background) #6597
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
Conversation
Nice! However, couldn't this be implemented as some sort of flag to the |
Yes, but that would be a lot more complicated. For ui highlighting there is the The only addition I would consider is support two values for active/inactive window as I guess that is a common usecase. Or maybe people should just use |
Oh, for sure. It was just a thought (main concern is that you are introducing a setting which might become obsolete by b some mechanism like above). Maybe the setting could be extensible so it is similar to the way guicursor works (taking a list of items and their attributes). |
That's a good suggestion, then we can make it clear a few specific groups are overridable, unlike |
7d86b54
to
06d2b8e
Compare
I'm unable to get buffer-local behavior for window option as described in
Is there a checklist somewhere for all the places a new window option, there are quite a few.... |
Indeed. For example, what would |
Why not make it buffer-local? See 7bc37ff for how 'scrollback' was converted from "global" to buffer-local.
Do you mean in the C code? Top of If it's any help, see #6337 (comment) |
Thanks for the pointers. The top of This is now |
Added |
marking RFC. |
would it be much trouble to make matchadd()/matchaddpos() support changing the bgcolor? |
No. Background is not special, it is just the intended usecase. You can override fg color and attributes. It would seem like a big stretch to let |
Right, matchadd() is the wrong mechanism because one cannot "match" non-text. I guess what I'm looking for is a way to decorate cells by XY coordinates. Anyways, that can wait until later. |
and But the main point is that this will be needed for (hopefully future) builtin functionality (floating windows), and such should have a builtin mechanism. |
segfault in https://gist.github.com/2ec9f8d3a442560ca38515dd0927b1aa Steps:
|
Thanks, please try latest commit. |
runtime/doc/options.txt
Outdated
to set window specific background color. | ||
inactive: Highlight applied to the window when inactive. If | ||
not set uses same value as `normal`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could have an example, e.g. :set winhl=inactive:ColorColumn
?!
No, it happens even if NonText doesn't have bg, so it is a bug... |
should work correctly with non-text highlights now. |
@justinmk Should we merge this? There might be more bad interactions, but the best way to find that out is let more people try it. Test errors look quite unrelated. |
lots of ad-hoc logic... For some reason the terminal has its own beyond-end-of-line loop, instead of reusing the existing one. Someone disabled colorcolumn in terminal instead of bothering fixing it proberly, but you can the same breakage using cursorcolumn... |
should work with precedes and extends now. |
@@ -930,6 +932,10 @@ struct window_S { | |||
|
|||
synblock_T *w_s; /* for :ownsyntax */ | |||
|
|||
int w_hl_id; ///< 'winhighlight' id | |||
int w_hl_id_inactive; ///< 'winhighlight' id for inactive window |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To support all builtin hl groups in the future, I suppose this will be some sort of list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, if we do 'highlight'
reform, this should just mimic the global hl_attr()
list. Then we can have hl_attr_w(wp, HLF_XX)
, support a lot of stuff by doing :%s/hl_attr(/hl_attr_w(wp,/gc
in screen.c and as a bonus remove a lot of the ad-hoc logic this PR currently needed to deal with vim's ad-hoc logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I think we shouldn't hesitate to do "'highlight' reform".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not hesitating ,I'm working on it!
end) | ||
|
||
|
||
it('works local to the buffer', function() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's window-local, not buffer-local, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't it decided that when setlocal
was used, it would be buffer-local?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was decided by bram long ago. "window option" means global=per window, local=per buffer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.. after testing, it does seem buffer-specific. Option rules continue to mystify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and as windows proliferate by division, setting it in vimrc will set it for all windows, unless changed later. But there is no true global-global value.
Hey, @blueyed, I was a happy user of vim-diminactive before, and now I'm an even happier user of the snipped you supplied above. Have you noticed, though, that it won't change the background if there isn't a file open, that is to say, if you open vim without supplying a filename? Incidentally, if you do that, open an empty split, then move between them, the original split all of a sudden starts changing background, but the new one doesn't. |
@rafaeln |
Hi, @blueyed, is the snippet still working for you? It was maybe after I upgraded neovim today that it stopped working for me. Specifically, it still works between vim splits, but stopped working between a vim pane and other tmux panes. I tried to understand better what was going on and so far I found that Focus{Gained,Lost} events are still being detected. |
Now the snippet got even weirder... |
@rafaeln |
FEATURES: 0e873a3 Lua(Jit) built-in neovim#4411 5b32bce Windows: `:terminal` neovim#7007 7b0ceb3 UI/API: externalize cmdline neovim#7173 b67f58b UI/API: externalize wildmenu neovim#7454 b23aa1c UI: 'winhighlight' neovim#6597 17531ed UI: command-line coloring (`:help input()-highlight`) neovim#6364 244a1f9 API: execute lua directly from the remote api neovim#6704 45626de API: `get_keymap()` neovim#6236 db99982 API: `nvim_get_hl_by_name()`, `nvim_get_hl_by_id()` neovim#7082 dc68538 menu_get() function neovim#6322 9db42d4 :cquit : take an error code argument neovim#7336 9cc185d job-control: serverstart(): support ipv6 neovim#6680 1b7a9bf job-control: sockopen() neovim#6594 6efe84a clipboard: fallback to tmux clipboard neovim#6894 6016ac2 clipboard: customize clipboard with `g:clipboard` neovim#6030 3a86dd5 ruby: override ruby host via `g:ruby_host_prog` neovim#6841 16cce1a debug: $NVIM_LOG_FILE neovim#6827 0cba3da `:checkhealth` built-in, validates $VIMRUNTIME neovim#7399 FIXES: 105d680 TUI: more terminals, improve scroll/resize neovim#6816 cb912a3 :terminal : handle F1-F12, other keys neovim#7241 619838f inccommand: improve performance neovim#6949 04b3c32 inccommand: Fix matches for zero-width neovim#7487 60b1e8a inccommand: multiline, other fixes neovim#7315 f1f7f3b inccommand: Ignore leading modifiers in the command neovim#6967 1551f71 inccommand: fix 'gdefault' lockup neovim#7262 6338199 API: bufhl: support creating new groups neovim#7414 541dde3 API: allow K_EVENT during operator-pending 8c732f7 terminal: adjust for 'number' neovim#7440 5bec946 UI: preserve wildmenu during jobs/events neovim#7110 c349083 UI: disable 'lazyredraw' during ui_refresh. neovim#6259 51808a2 send FocusGained/FocusLost event instead of pseudokey neovim#7221 133f8bc shada: preserve unnamed register on restart neovim#4700 1b70a1d shada: avoid assertion on corrupt shada file neovim#6958 9f534f3 mksession: Restore tab-local working directory neovim#6859 de1084f fix buf_write() crash neovim#7140 7f76986 syntax: register 'Normal' highlight group neovim#6973 6e7a8c3 RPC: close channel if stream was closed neovim#7081 85f3084 clipboard: disallow recursion; show hint only once neovim#7203 8d1ccb6 clipboard: performance, avoid weird edge-cases neovim#7193 01487d4 'titleold' neovim#7358 01e53a5 Windows: better path-handling, separator (slash) hygiene neovim#7349 0f2873c Windows: multibyte startup arguments neovim#7060 CHANGES: 9ff0cc7 :terminal : start in normal-mode neovim#6808 032b088 lower priority of 'cursorcolumn', 'colorcolumn' neovim#7364 2a3bcd1 RPC: Don't delay notifications when request is pending neovim#6544 023f67c :terminal : Do not change 'number', 'relativenumber' neovim#6796 1ef2d76 socket.c: Disable Nagle's algorithm on TCP sockets neovim#6915 6720fe2 help: `K` tries Vim help instead of manpage neovim#3104 7068370 help, man.vim: change "outline" map to `gO` neovim#7405
While doing stupid experiments with floating windows, I realized they need to be in a different background color. But this might be useful in general. (It was discussed, issue #5302).
set winbg=HighlightGroup
Though it is not currently restricted to background color, any attribute can be set. So maybe the option should have a different name.