diff --git a/autoload/vimwiki/vars.vim b/autoload/vimwiki/vars.vim new file mode 100644 index 0000000..8ed1bc3 --- /dev/null +++ b/autoload/vimwiki/vars.vim @@ -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