ba5c0002ab
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>
40 lines
1.3 KiB
VimL
40 lines
1.3 KiB
VimL
" 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
|