fix(vim): gate Neovim TS-style highlight groups + correct bin path lookup
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>
This commit is contained in:
@@ -5,6 +5,11 @@
|
||||
" 2. coc.nvim
|
||||
" 3. Print an error if neither is available.
|
||||
|
||||
" Resolve the plugin root at script-load time. `<sfile>` inside a
|
||||
" function later returns the *calling* script's path, not this file's
|
||||
" — capturing it here is the reliable way.
|
||||
let s:plugin_root = fnamemodify(resolve(expand('<sfile>:p')), ':h:h:h')
|
||||
|
||||
let s:started = 0
|
||||
|
||||
function! nuwiki#lsp#start() abort
|
||||
@@ -60,9 +65,8 @@ function! s:bin_path() abort
|
||||
if exists('g:nuwiki_binary_path') && filereadable(g:nuwiki_binary_path)
|
||||
return g:nuwiki_binary_path
|
||||
endif
|
||||
let l:plugin_dir = fnamemodify(resolve(expand('<sfile>:p')), ':h:h:h')
|
||||
let l:suffix = has('win32') ? '.exe' : ''
|
||||
return l:plugin_dir . '/bin/nuwiki-ls' . l:suffix
|
||||
return s:plugin_root . '/bin/nuwiki-ls' . l:suffix
|
||||
endfunction
|
||||
|
||||
function! s:settings() abort
|
||||
|
||||
+40
-33
@@ -1,4 +1,4 @@
|
||||
" syntax/nuwiki.vim — default highlight groups for nuwiki.
|
||||
" syntax/vimwiki.vim — default highlight groups for nuwiki.
|
||||
"
|
||||
" Two responsibilities:
|
||||
" 1. Default `@vimwiki*` highlight groups for the LSP semantic tokens
|
||||
@@ -6,48 +6,55 @@
|
||||
" 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's TS-style @group names) =====
|
||||
" ===== Semantic-token defaults (Neovim only — uses TS-style @group names) =====
|
||||
|
||||
" 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
|
||||
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
|
||||
" 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
|
||||
" 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
|
||||
" 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
|
||||
" 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) =====
|
||||
|
||||
|
||||
Reference in New Issue
Block a user