2026-05-21 21:42:09 -03:00
|
|
|
" 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')
|
2026-06-03 14:13:55 +00:00
|
|
|
"
|
|
|
|
|
" LIMITATION: the optional second argument (upstream's wiki index) is
|
|
|
|
|
" ignored — values always come from the scalar `g:nuwiki_*` vars, i.e.
|
|
|
|
|
" the first/shorthand wiki. Third-party plugins that query a specific
|
|
|
|
|
" wiki by index in a multi-wiki setup will get the first wiki's values.
|
|
|
|
|
" The shim exists for single-wiki compatibility (vimwiki-sync, vim-zettel);
|
|
|
|
|
" extend here with `g:nuwiki_wikis[a:1]` lookups if multi-wiki support is
|
|
|
|
|
" needed.
|
2026-05-21 21:42:09 -03:00
|
|
|
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
|