0

I have tried ownsyntax but that does not work. I want do change the background color for only one window? I have tried this but it highlights all the windows.

hi Normal guibg=grey guifg=black

It looks like it is wincolor, not sure if there's another way to change without adding a group. Not sure why my answer of wincolor was deleted.

I am working on an Rgb colors plugin in which I need to be able to look at the random colors. I accomplish by using a popup window with wincolor which seems to to work fine. The colors are not fixed, I just used this dictionary to show as an example. If there are better solutions than mine I would appreciate a response.

let color_keys = keys(s:css_colors)
for index in range(0,len(color_keys) - 1 )
    let color = color_keys[index]
    let popid= Popup(color,60000, index * 4)
    let cmd = 'hi TEMPCOLOR' . color . ' guibg='.color.' | let &wincolor="TEMPCOLOR'. color. '"'
    call win_execute(popid,cmd)
endfor

enter image description here

Here is an example of one buffer in one color and another buffer in another color.

enter image description here

2 Answers 2

3
  1. The answer is different for Vim and Neovim. Vim has :h 'wincolor' to overwrite "Normal" for a given window, while Neovim has :h 'winhighlight' to override any number of highlighting groups.

  2. You can't really assign arbitary colors to anything except a highlighting group. But you're not obliged to create new groups if existing ones are okay. For example, setlocal wincolor=PMenu is quite possible.

  3. Syntax elements are essentially regexes. While "Normal" highlight is something used outside of all possible syntax matches. Sort of default. So even if one can build a regex to cover "Normal" highlight, it doesn't seem like a good idea.

  4. :hi command is always global. :ownsyntax allows for a window to have own set of syntax elements, i.e. regexes. But once all groups are matched, their attributes are taken from the global table (except item (1)).

7
  • so the answer for normal vim is 'wincolor' to highlight the background for only one window ?
    – ritchie
    Commented Feb 9, 2021 at 14:27
  • 1
    @ritchie Vi/Vim was created as a terminal application. And logically it is still about "character cells", not "GUI background". By default character cells in Vim are painted as "Normal" (or "wincolor").
    – Matt
    Commented Feb 9, 2021 at 14:47
  • I added more info to the question with code....."I am working on an Rgb colors plugin in which I need to be able to look at the random colors. I accomplish by using a popup window with wincolor which seems to to work fine. The colors are not fixed, I just used this dictionary to show as an example. If there are better solutions than mine I would appreciate a response."
    – ritchie
    Commented Feb 9, 2021 at 18:09
  • @ritchie Honestly, I just don't understand what's the use of popup windows for you. Open regular window/buffer, create syntax groups and highlights, change it on-the-fly etc. I see no reason to require the whole window to have single color.
    – Matt
    Commented Feb 9, 2021 at 18:29
  • 1
    @user202729 "Anything except highlighting group". Signs get colors by linking them to highlighting groups, like everything else.
    – Matt
    Commented Feb 5 at 6:16
0
let color_keys = keys(s:css_colors)
for index in range(0,len(color_keys) - 1 )
    let color = color_keys[index]
    let popid= Popup(color,60000, index * 4)
    let cmd = 'hi TEMPCOLOR' . color . ' guibg='.color.' | let &wincolor="TEMPCOLOR'. color. '"'
    call win_execute(popid,cmd)
endfor

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.