From 04cbe6788268b2b728611a2143f57f7e1fb233b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Fr=C3=B3es=20Franco?= Date: Tue, 26 May 2026 22:03:51 -0300 Subject: [PATCH] fix(syntax): per-level heading groups so colorschemes differentiate H1-H6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The single `nuwikiHeading` group linked all six levels to `Title`. Many popular colorschemes (codedark, gruvbox-light, etc.) define `Title` as bold-only with no foreground colour, so every heading rendered as bold text in the Normal colour — H1 and H3 were visually identical. Split into nuwikiHeading1..6 and link each to a different accent (Title / Function / Identifier / Type / Constant / PreProc), matching the per-level Tree-sitter mapping the Neovim semantic-token side already uses. The patterns are mutually exclusive: each requires whitespace immediately after the equals run, so `=` won't match `==`. Co-Authored-By: Claude Sonnet 4.6 --- syntax/vimwiki.vim | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/syntax/vimwiki.vim b/syntax/vimwiki.vim index 2553536..98b23b1 100644 --- a/syntax/vimwiki.vim +++ b/syntax/vimwiki.vim @@ -63,7 +63,15 @@ endif syntax case match -syntax match nuwikiHeading /^\s*=\{1,6}\s.\{-}\s=\{1,6}\s*$/ +" One match per heading level so colorschemes can style each differently. +" Each pattern requires whitespace immediately after the equals run, which +" makes the levels mutually exclusive (`==` won't match `===`). +syntax match nuwikiHeading1 /^\s*=\s.\{-}\s=\s*$/ +syntax match nuwikiHeading2 /^\s*==\s.\{-}\s==\s*$/ +syntax match nuwikiHeading3 /^\s*===\s.\{-}\s===\s*$/ +syntax match nuwikiHeading4 /^\s*====\s.\{-}\s====\s*$/ +syntax match nuwikiHeading5 /^\s*=====\s.\{-}\s=====\s*$/ +syntax match nuwikiHeading6 /^\s*======\s.\{-}\s======\s*$/ syntax match nuwikiHorizontal /^-\{4,}\s*$/ syntax match nuwikiCommentLine /^%%.*$/ syntax region nuwikiCommentBlock start=/^%%+/ end=/+%%/ keepend @@ -92,7 +100,16 @@ syntax match nuwikiWikilinkTarget /[^|\]]*|/ contained conceal syntax region nuwikiTransclusion start=/{{[^{]/ end=/}}/ keepend syntax match nuwikiUrl /\<\(https\?\|ftp\|mailto\|file\):\/\?\/\?\S\+/ -highlight default link nuwikiHeading Title +" Heading levels map to progressively softer accents — matches the Neovim +" semantic-token mapping above so static fallback and LSP-driven highlights +" agree. Colorschemes that don't differentiate Title vs Function vs etc. +" will still show all six as the same colour, but most do. +highlight default link nuwikiHeading1 Title +highlight default link nuwikiHeading2 Function +highlight default link nuwikiHeading3 Identifier +highlight default link nuwikiHeading4 Type +highlight default link nuwikiHeading5 Constant +highlight default link nuwikiHeading6 PreProc highlight default link nuwikiHorizontal Comment highlight default link nuwikiCommentLine Comment highlight default link nuwikiCommentBlock Comment