8f8c2884a9
Set conceallevel=2 and concealcursor=nc on .wiki buffers and add contained `conceal` matches for the bold/italic/code delimiters and wikilink brackets/targets. The static-fallback rendering now mirrors what the Neovim semantic-token path produced: *bold* shows as bold without the asterisks, [[target|desc]] shows just "desc", etc. The wikilink region uses an inline `contains=` (no line continuation) because some Vim builds (notably Homebrew Vim 9.2) raise E10 on the leading `\\ contains=...` form even though the surrounding region parses fine. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
109 lines
4.8 KiB
VimL
109 lines
4.8 KiB
VimL
" 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.
|
|
highlight default link @vimwikiBold markdownBold
|
|
highlight default link @vimwikiItalic markdownItalic
|
|
highlight default link @vimwikiBoldItalic markdownBoldItalic
|
|
highlight default link @vimwikiStrikethrough Comment
|
|
highlight default link @vimwikiSuperscript Number
|
|
highlight default link @vimwikiSubscript Number
|
|
|
|
" Code + math.
|
|
highlight default link @vimwikiCode String
|
|
highlight default link @vimwikiCodeBlock String
|
|
highlight default link @vimwikiMath Number
|
|
highlight default link @vimwikiMathBlock Number
|
|
|
|
" Links + transclusions.
|
|
highlight default link @vimwikiWikilink Underlined
|
|
highlight default link @vimwikiExternalLink Underlined
|
|
highlight default link @vimwikiUrl Underlined
|
|
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
|
|
|
|
syntax match nuwikiHeading /^\s*=\{1,6}\s.\{-}\s=\{1,6}\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\+/
|
|
|
|
highlight default link nuwikiHeading Title
|
|
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
|
|
highlight default link nuwikiBold Bold
|
|
highlight default link nuwikiItalic 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'
|