mawww / kakoune

mawww's experiment for a better code editor
http://kakoune.org
The Unlicense
9.7k stars 705 forks source link

[BUG] WhitespaceIndent face overridden by language highlighting #5179

Closed ismay closed 1 month ago

ismay commented 1 month ago

Version of Kakoune

v2024.05.09

Reproducer

Outcome

1715938780

As you see, the WhitespaceIndent face is overridden by the syntax highlighting.

Expectations

I would expect the WhitespaceIndent, when set at a global level, to not be overridden by any other highlighting.

Additional information

I know that I could use face global WhitespaceIndent bright-black+F to prevent the color from being overridden. But, when I tried that, the WhitespaceIndent face overrode my selection colors. So I had to make my selection colors +F as well. But, when I did that, my selections overrode the italics I had set for my comments. Etc. etc. Long story short, it leads to an endless chain of overrides that can't be resolved in a lot of cases. So I don't think using +F is a proper solution here. It would be nice to see the recommended solution applied to the default theme, as an example.

ismay commented 1 month ago

In the end I think my issue was with the way kakoune's cascading font colors & styles work. I managed to make it work with:

# Theme
#######

# Syntax
face global comment bright-black+ia

# UI
face global Error bright-white,red
face global LineNumbers bright-black,default
face global LineNumbersWrapped bright-black,default

# Override other colors for indent
face global Whitespace bright-black,default+f
face global WhitespaceIndent bright-black,default+f

# Cursor and selection overrides
face global PrimaryCursor black,yellow+fg
face global PrimaryCursorEol black,bright-cyan+fg
face global PrimarySelection bright-white,blue+fg
face global SecondaryCursor black,bright-black+fg
face global SecondaryCursorEol black,cyan+fg
face global SecondarySelection black,blue+fg

# Dim inactive
##############

face global InactiveHighlight white,bright-black+fg

hook global WinDisplay .* %{
  face window PrimaryCursor PrimaryCursor
  face window PrimaryCursorEol PrimaryCursorEol
  face window SecondaryCursor SecondaryCursor
  face window SecondaryCursorEol SecondaryCursorEol
  face window LineNumberCursor LineNumberCursor
  face window PrimarySelection PrimarySelection
  face window SecondarySelection SecondarySelection
  face window Information Information
}

hook global FocusIn .* %{
  face window PrimaryCursor PrimaryCursor
  face window PrimaryCursorEol PrimaryCursorEol
  face window SecondaryCursor SecondaryCursor
  face window SecondaryCursorEol SecondaryCursorEol
  face window LineNumberCursor LineNumberCursor
  face window PrimarySelection PrimarySelection
  face window SecondarySelection SecondarySelection
  face window Information Information
}

hook global FocusOut .* %{
  face window PrimaryCursor InactiveHighlight
  face window PrimaryCursorEol InactiveHighlight
  face window SecondaryCursor InactiveHighlight
  face window SecondaryCursorEol InactiveHighlight
  face window LineNumberCursor InactiveHighlight
  face window PrimarySelection InactiveHighlight
  face window SecondarySelection InactiveHighlight
  face window Information InactiveHighlight
}

It's not ideal as for example the markdown trailing whitespace syntax highlighting still overrides it. But I think it's not something that should be qualified as a bug. I'll close it, feel free to reopen or comment if necessary.