" syntax/vimwiki.vim — default highlight groups for nuwiki. " " Two responsibilities: " 1. Default `@vimwiki*` highlight groups for the LSP semantic tokens " (SPEC §11 P7). Loaded eagerly so the very first hover/highlight " cycle after server startup already has colours. " 2. A small regex-based fallback so static highlighting works on " buffers where the LSP isn't running yet. " " The `@group.modifier` group names are Neovim's Tree-sitter convention " — plain Vim rejects `@` and `.` with W18, so the LSP-token defaults " are gated behind `has('nvim')`. The static fallback below works " everywhere. if exists('b:current_syntax') finish endif " ===== Semantic-token defaults (Neovim only — uses TS-style @group names) ===== if has('nvim') " Headings — level modifiers map to progressively softer accents. highlight default link @vimwikiHeading Title highlight default link @vimwikiHeading.level1 Title highlight default link @vimwikiHeading.level2 Function highlight default link @vimwikiHeading.level3 Identifier highlight default link @vimwikiHeading.level4 Type highlight default link @vimwikiHeading.level5 Constant highlight default link @vimwikiHeading.level6 PreProc highlight default link @vimwikiHeading.centered Title " Inline text styling. " Use @markup.* (nvim 0.9+ treesitter standard groups, defined by all " colorschemes) instead of markdownBold/Italic which only exist when the " markdown treesitter parser is loaded — never the case in a vimwiki buffer. highlight default link @vimwikiBold @markup.strong highlight default link @vimwikiItalic @markup.italic highlight default link @vimwikiBoldItalic @markup.strong highlight default link @vimwikiStrikethrough @markup.strikethrough highlight default link @vimwikiSuperscript Special highlight default link @vimwikiSubscript Special " Code + math. highlight default link @vimwikiCode @markup.raw.inline highlight default link @vimwikiCodeBlock @markup.raw.block highlight default link @vimwikiMath Number highlight default link @vimwikiMathBlock Number " Links + transclusions. highlight default link @vimwikiWikilink @markup.link highlight default link @vimwikiExternalLink @markup.link.url highlight default link @vimwikiUrl @markup.link.url highlight default link @vimwikiTransclusion Identifier " Misc. highlight default link @vimwikiKeyword Todo highlight default link @vimwikiColor Constant highlight default link @vimwikiComment Comment highlight default link @vimwikiDefinitionTerm Statement endif " ===== Static fallback (no LSP required) ===== syntax case match " 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 syntax region nuwikiPreformatted start=/^{{{/ end=/^}}}/ keepend syntax region nuwikiMathBlock start=/^{{\$/ end=/^}}\$/ keepend syntax match nuwikiPlaceholder /^%\(title\|nohtml\|template\|date\)\>.*$/ syntax match nuwikiBold /\*[^*]\+\*/ contains=nuwikiBoldDelim syntax match nuwikiBoldDelim /\*/ contained conceal syntax match nuwikiItalic /\<_[^_]\+_\>/ contains=nuwikiItalicDelim syntax match nuwikiItalicDelim /_/ contained conceal syntax match nuwikiCode /`[^`]\+`/ contains=nuwikiCodeDelim syntax match nuwikiCodeDelim /`/ contained conceal syntax match nuwikiMathInline /\$[^$]\+\$/ syntax match nuwikiKeyword /\<\(TODO\|DONE\|STARTED\|FIXME\|FIXED\|XXX\)\>/ " Wikilink conceal: hide [[ / ]], and for [[target|desc]] hide target|. syntax region nuwikiWikilink start=/\[\[/ end=/\]\]/ keepend contains=nuwikiWikilinkBracket,nuwikiWikilinkTarget syntax match nuwikiWikilinkBracket /\[\[/ contained conceal syntax match nuwikiWikilinkBracket /\]\]/ contained conceal syntax match nuwikiWikilinkTarget /[^|\]]*|/ contained conceal syntax region nuwikiTransclusion start=/{{[^{]/ end=/}}/ keepend syntax match nuwikiUrl /\<\(https\?\|ftp\|mailto\|file\):\/\?\/\?\S\+/ " 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 highlight default link nuwikiPreformatted String highlight default link nuwikiMathBlock Number highlight default link nuwikiPlaceholder PreProc " Bold / Italic use explicit attributes so they work in plain Vim too (no " dependency on the 'Bold' / 'Italic' groups which are Neovim-only). highlight default nuwikiBold gui=bold cterm=bold term=bold highlight default nuwikiItalic gui=italic cterm=italic term=italic highlight default link nuwikiCode String highlight default link nuwikiMathInline Number highlight default link nuwikiKeyword Todo highlight default link nuwikiWikilink Underlined highlight default link nuwikiTransclusion Identifier highlight default link nuwikiUrl Underlined let b:current_syntax = 'vimwiki'