Skip to content
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

Prevent overriding/cancelling of backgrounds #153

Open
John-Colvin opened this issue Sep 15, 2024 · 3 comments
Open

Prevent overriding/cancelling of backgrounds #153

John-Colvin opened this issue Sep 15, 2024 · 3 comments

Comments

@John-Colvin
Copy link

E.g. is there any way to avoid the gaps in the background for if, return & nullptr while still being able to style them in general?
Screenshot 2024-09-15 at 23 14 49

It would be manageable to only have one background possible, e.g. if I set a background on Statement then it would always take precedence, but it seems that I can't even express something like "Statements should be bold & have the background of whatever they are part of".

@rktjmp
Copy link
Owner

rktjmp commented Sep 16, 2024

If you don't set a bg for Statement, Vim should show whatever the background is for the "previous/surrounding" highlight group, eg Normal, CursorLine, etc.

eg
image

Or do I misunderstand the question? Vim can't embed any logic in the actual groups, so you can't have conditional stuff outside of actually altering what groups are applied via treesitter/the syntax file.

@John-Colvin
Copy link
Author

John-Colvin commented Sep 16, 2024

That isn't what I'm seeing, I must be doing something wrong.

Config:

local lush = require('lush')
local hsl = lush.hsl

local theme = lush(function(injected_functions)
  local sym = injected_functions.sym
  return {
    Statement      { gui = "bold" }, -- (*) Any statement
    PreProc        { bg = hsl("#ff0000") }, -- (*) Generic Preprocessor
  }
end)

return theme

Result:

Screenshot 2024-09-16 at 03 34 14

@rktjmp
Copy link
Owner

rktjmp commented Sep 16, 2024

Ah I see. I missed that the target group was PreProc in the first post. I guess it's not possible, something specific to how PreProc is applied? It seems that the default PreProc group for neovim only applies a fg color, perhaps for this reason.

You can see here where Statement's background correctly "falls through" for CursorLine (return, nullptr) vs Normal (if).

image

You can see the raw lines lua/vimscript lines that lush would generate via those lushwright lines if you want to try and debug/reproduce outside of Lush (check :messages, each element in the table is a line, so for the lua output they're elements of a table, for vimscript each is its own command. Dont forget to include a :hi clear.).

{ 'Normal = {bg = "#996666"},', 'CursorLine = {bg = "#669999"},', 'PreProc = {bg = "#FF0000"},', "Statement = {bold = true}," }
{ "highlight Normal guifg=NONE guibg=#996666 guisp=NONE blend=NONE gui=NONE", "highlight CursorLine guifg=NONE guibg=#669999 guisp=NONE blend=NONE gui=NONE", "highlight PreProc guifg=NONE guibg=#FF0000 guisp=NONE blend=NONE gui=NONE", "highlight Statement guifg=NONE guibg=NONE guisp=NONE blend=NONE gui=bold" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants