f1bf70d448
Plain Vim spat a wall of `W18: Invalid character in group name` on
every buffer load because `syntax/vimwiki.vim` declared the
LSP-token highlight defaults with Tree-sitter-style names
(`@vimwikiHeading.level1`, `@vimwikiBold`, …). Those work on Neovim
but Vim rejects `@` and `.` in group names.
- `syntax/vimwiki.vim` now guards the `@vimwiki*` block with
`has('nvim')`. The static regex fallback below it (which uses
Vim-compatible `nuwiki*` group names) keeps highlighting working
on plain Vim.
While reproducing, also noticed `autoload/nuwiki/lsp.vim`'s
`s:bin_path` reported the binary at `/home/gfranco/bin/nuwiki-ls`
(only two dirs under `$HOME`) instead of
`/home/gfranco/git-repositories/nuwiki/bin/nuwiki-ls`. Cause:
`expand('<sfile>:p')` inside a function resolves to the *calling*
script at invocation time, not this autoload file. Captured the
plugin root via `<sfile>` at script-load time into a new
`s:plugin_root` and used it in `bin_path()`.
Verified with `vim -u .vimrc index.wiki`:
- `:messages` is empty of W18 warnings.
- The "binary not found" path (when no built binary exists) now
prints the correct repo-relative path.
Total 377 Rust tests still pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
97 lines
4.2 KiB
VimL
97 lines
4.2 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 /\*[^*]\+\*/
|
|
syntax match nuwikiItalic /\<_[^_]\+_\>/
|
|
syntax match nuwikiCode /`[^`]\+`/
|
|
syntax match nuwikiMathInline /\$[^$]\+\$/
|
|
syntax match nuwikiKeyword /\<\(TODO\|DONE\|STARTED\|FIXME\|FIXED\|XXX\)\>/
|
|
syntax region nuwikiWikilink start=/\[\[/ end=/\]\]/ keepend
|
|
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'
|