feat(config): P3 config batch — group 2 (create_link, dir_link, auto_header)
- create_link (default true): server resolve_target_uri now only synthesises a missing-page URI when create_link is set; when off, following a link to a non-existent page returns no location (no-op). - dir_link: a [[dir/]] link now resolves to <dir>/<dir_link><ext> when dir_link is set, else opens the directory itself. Uses the already-parsed LinkTarget.is_directory. - auto_header (default off): new wiki pages get a `= Stem =` header derived from the filename, skipping the wiki index + diary index. Client-side BufNewFile autocmd in both clients (init.lua + plugin/nuwiki.vim), with auto_header handlers in both command layers (trailing-slash-robust root matching). Tests: cmd.auto_header_inserts + cmd.auto_header_skips_diary_index (nvim) / cmd.auto_header_skips_index (vim). Full rust suite + both harnesses green (Neovim 307, Vim 301/18/21). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -190,6 +190,30 @@ function! nuwiki#commands#auto_chdir() abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" vimwiki `auto_header`: on a new wiki page, insert a level-1 header derived
|
||||
" from the filename. Skips the wiki index + diary index pages; only acts on an
|
||||
" empty new buffer. Wired from a BufNewFile autocmd.
|
||||
function! nuwiki#commands#auto_header() abort
|
||||
if line('$') > 1 || getline(1) !=# ''
|
||||
return
|
||||
endif
|
||||
let l:file = expand('%:p')
|
||||
for l:c in nuwiki#commands#wiki_list()
|
||||
let l:root = fnamemodify(expand(l:c.root), ':p')
|
||||
if l:root[len(l:root) - 1:] !=# '/' | let l:root .= '/' | endif
|
||||
if l:file[: len(l:root) - 1] ==# l:root
|
||||
let l:index_path = l:root . l:c.idx . l:c.ext
|
||||
let l:diary_index_path = l:root . l:c.diary_rel . '/' . l:c.diary_idx . l:c.ext
|
||||
if l:file ==# l:index_path || l:file ==# l:diary_index_path
|
||||
return
|
||||
endif
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
call setline(1, '= ' . expand('%:t:r') . ' =')
|
||||
call append(1, '')
|
||||
endfunction
|
||||
|
||||
" :VimwikiShowVersion / :NuwikiShowVersion — echo the nuwiki version and the
|
||||
" host editor, mirroring upstream's version banner.
|
||||
function! nuwiki#commands#show_version() abort
|
||||
|
||||
Reference in New Issue
Block a user