fix(compat): add vimwiki#vars shim for vimwiki-sync and vim-zettel
CI / cargo fmt --check (push) Successful in 29s
CI / cargo clippy (push) Successful in 23s
CI / cargo test (push) Successful in 25s
CI / editor keymaps (push) Successful in 1m19s

Third-party plugins such as vimwiki-sync and vim-zettel call
vimwiki#vars#get_wikilocal() — a function only provided by the original
vimwiki plugin. Without it, the after/ftplugin loaded by vimwiki-sync
errors on every wiki buffer open:

  E117: Unknown function: vimwiki#vars#get_wikilocal
  E121: Undefined variable: g:zettel_dir

Add autoload/vimwiki/vars.vim with lightweight stubs for the two keys
vimwiki-sync uses ('path', 'is_temporary_wiki'), reading values from
nuwiki's own g:nuwiki_wiki_root / g:nuwiki_file_extension config so
users don't have to duplicate settings. get_global() is stubbed as a
no-op for completeness.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-21 21:42:09 -03:00
parent 9354e1c176
commit ba5c0002ab
+39
View File
@@ -0,0 +1,39 @@
" autoload/vimwiki/vars.vim — compatibility shim for plugins that depend on
" the original vimwiki API (e.g. vimwiki-sync, vim-zettel).
"
" Only the subset of `vimwiki#vars#get_wikilocal` keys that third-party
" plugins are known to call is implemented here; add entries as needed.
" Values are read from nuwiki's own config variables so users don't have
" to duplicate settings.
" Per-wiki local config values.
"
" Supported keys:
" path — wiki root directory (with trailing slash)
" is_temporary_wiki — always 0 for a configured wiki
" ext / extension — file extension (default '.wiki')
" syntax — syntax name (default 'vimwiki')
function! vimwiki#vars#get_wikilocal(key, ...) abort
if a:key ==# 'path'
let l:root = expand(get(g:, 'nuwiki_wiki_root', '~/vimwiki'))
" Ensure trailing slash to match what the original vimwiki returns.
return l:root =~# '/$' ? l:root : l:root . '/'
elseif a:key ==# 'is_temporary_wiki'
return 0
elseif a:key ==# 'ext' || a:key ==# 'extension'
let l:ext = get(g:, 'nuwiki_file_extension', '.wiki')
return l:ext[0] ==# '.' ? l:ext : '.' . l:ext
elseif a:key ==# 'syntax'
return get(g:, 'nuwiki_syntax', 'vimwiki')
endif
return ''
endfunction
" Global (non-wiki-specific) config values.
function! vimwiki#vars#get_global(key) abort
return ''
endfunction