Skip to content

Stop editor defaults from leaking into highlight groups - #49

Merged
wadackel merged 1 commit into
mainfrom
fix/highlight-default-leak
Sep 26, 2026
Merged

wadackel merged 1 commit into
mainfrom
fix/highlight-default-leak

Conversation

@wadackel

Copy link
Copy Markdown
Owner

Summary

:hi merges into a group's existing attributes, so every key the generator omitted kept the editor's default instead of meaning "unset". After colorscheme dogrun:

  • Vim 9.2: SpellBad/SpellCap/SpellLocal/SpellRare kept ctermbg=12/9/11/13 (bright red/blue backgrounds on misspelled words in 256-color terminals), Identifier stayed bold, Visual got guifg=LightGrey (syntax colors lost inside a selection), Underlined kept a blue fg, and several message/diff groups stayed bold.
  • Neovim 0.12: Pmenu kept cterm=reverse and Visual kept ctermfg=0 (visible without termguicolors), MatchParen and DiffDelete stayed bold, and every Spell/Diagnostic underline used Neovim's own palette as its underline color.

highlight() now writes all seven keys (guifg ctermfg guibg ctermbg guisp gui cterm) and uses NONE where dogrun sets nothing, which is what the original hand-written colorscheme did.

Related changes:

  • SpellCap and DiagnosticUnderline{Info,Hint,Ok} only had an underline and relied on the leaked defaults to be told apart; they now get a dogrun underline color (yellow / infofg) while keeping the text color.
  • GitSignsChangeDelete / GitGutterChangeDelete used difftextbg, a background color (1.54:1 contrast on mainbg); they now use the Change color. NvimTreeGitDeletedIcon / FylerGitDeleted use pink.
  • Operator was undefined, so legacy syntax in Neovim rendered operators in Neovim's default grey; it now matches @operator (purple).
  • Vim's :terminal now gets the same 16 colors via g:terminal_ansi_colors (used by Vim with termguicolors or in the GUI).
  • Generator cleanup: 16 unused palette entries removed, palette lookup failures name the color and the group, and integration tests run the binary Cargo built (CARGO_BIN_EXE_dogrun) instead of a nested cargo run.

term= attributes are intentionally left alone: dogrun defines none, so the editor defaults remain the only thing that works on monochrome terminals.

Verification

  • just check (fmt, clippy, all tests including the golden byte-compare) passes; new tests assert every hi line carries all seven keys and that the Vim branch sets 16 ANSI colors.
  • Loading the colorscheme and reading back nvim_get_hl() / hlget(): groups holding a value dogrun did not set went from 13 → 0 (Neovim) and 12 → 0 (Vim).
  • Diffing every highlight group between the previous and the new colorscheme under a full Neovim config with plugins: only the intended groups change (plus GitSignsStagedChangedelete, which gitsigns derives from GitSignsChangedelete).

References

  • n/a

🤖 Generated with Claude Code

`:hi` merges into a group's existing attributes, so every key the
generator left out kept the editor's default: Vim's SpellBad kept
ctermbg=12, Identifier stayed bold and Visual got guifg=LightGrey;
Neovim's Pmenu kept cterm=reverse and Visual ctermfg=0. highlight()
now writes every key and uses NONE where dogrun sets nothing, as the
original hand-written colorscheme did.

- Give SpellCap and DiagnosticUnderline{Info,Hint,Ok} a dogrun underline
  color; they relied on the leaked defaults to be told apart
- Use yellow for *ChangeDelete signs and pink for the Deleted icons;
  difftextbg is a background color and was nearly invisible (1.54:1)
- Define Operator so legacy syntax matches @operator
- Emit g:terminal_ansi_colors for Vim's :terminal
- Remove 16 unused palette entries and name the color and group when a
  palette lookup fails
- Run the generator binary Cargo built in integration tests instead of
  a nested `cargo run`

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@wadackel
wadackel merged commit 3ff3601 into main Sep 26, 2026
1 check passed
@wadackel
wadackel deleted the fix/highlight-default-leak branch September 26, 2026 02:09
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

Successfully merging this pull request may close these issues.

1 participant