parity(1): vimwiki per-wiki config keys, table colspan/rowspan,
named link commands, mouse maps
Parity audit Cluster 1 — small wins.
WikiConfig (server) extended with 14 vimwiki globals:
- `index` (`g:vimwiki_index`), wired into `:VimwikiIndex` so users
with a custom index page stem (e.g. `home`) get the right file.
- `diary_frequency`, `diary_start_week_day`, `diary_caption_level`,
`diary_sort`, `diary_header` — diary keys (weekly/monthly/yearly
semantics land in Cluster 4; the keys parse now so config
migration doesn't need to wait).
- `maxhi`, `listsyms`, `listsyms_propagate`, `list_margin`,
`links_space_char`, `nested_syntaxes`, `auto_toc` — list +
highlight knobs the renderer/handlers can consult.
All keys threaded through `RawWiki` → `WikiConfig::from(RawWiki)`,
defaults centralised in `wiki_defaults()` so `empty()`, `from_root()`,
the legacy single-wiki path, and the `RawWiki` impl stay in sync.
Lua front-door (`lua/nuwiki/config.lua`) now documents the multi-wiki
`wikis = {…}` shape with every accepted per-wiki key — users who
prefer Lua tables no longer have to round-trip through
`init_options` raw JSON.
HTML renderer (`crates/nuwiki-core/src/render/html.rs`):
- New `table_spans()` pre-pass resolves vimwiki's `>` (col_span) and
`\\/` (row_span) continuation markers into proper HTML
`colspan="N"` / `rowspan="N"` attributes on the lead cell. Continuation
cells emit nothing, matching what browsers expect.
- The old behaviour (emitting `class="col-span"` / `class="row-span"`
as visual markers) is gone — replaced with real merging so the
rendered HTML matches the source semantics.
Named ex-commands:
- `:VimwikiNextLink` / `:VimwikiPrevLink` — were keymapped only
(`<Tab>`/`<S-Tab>`); now have explicit `:` commands in both editor
paths, dispatching to new `nuwiki.commands.link_next` / `link_prev`
pure-Vim/Lua helpers.
- `:VimwikiBaddLink` — adds the link target's file to the buffer
list without switching focus. Goes through
`textDocument/definition` and runs `:badd <fname>` on the resolved
URI.
Mouse maps (opt-in via `mappings.mouse = true` in Lua or
`g:nuwiki_mouse_mappings = 1` in Vim):
- `<2-LeftMouse>` follows, `<S-2-LeftMouse>` / `<C-2-LeftMouse>`
follow in split/vsplit, `<MiddleMouse>` adds to buflist,
`<RightMouse>` goes back. Mirrors upstream vimwiki's defaults.
Tests: 7 new in `parity_cluster_1.rs` covering the per-wiki config
defaults + raw JSON parse, the legacy-single-wiki path, colspan
folding into a lead cell with no leftover class markers, rowspan
across rows, no-attrs when the table has no spans, and a sanity
paragraph render. Total 421 Rust tests pass; clippy clean; both
keymap harnesses still green (20 nvim + 12 vim).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -94,6 +94,44 @@ function! s:wiki_pick(notification) abort
|
||||
\ function('s:open_uri_from'))
|
||||
endfunction
|
||||
|
||||
" `:VimwikiNextLink` / `:VimwikiPrevLink` — pure-VimL `[[…]]` jumper.
|
||||
function! nuwiki#commands#link_next() abort
|
||||
call search('\[\[', 'W')
|
||||
endfunction
|
||||
function! nuwiki#commands#link_prev() abort
|
||||
call search('\[\[', 'bW')
|
||||
endfunction
|
||||
|
||||
" `:VimwikiBaddLink` — add the link target file to the buffer list
|
||||
" without focus. Routes through vim-lsp's textDocument/definition.
|
||||
function! nuwiki#commands#badd_link() abort
|
||||
if !s:has_vimlsp()
|
||||
echohl ErrorMsg | echom 'nuwiki: vim-lsp not loaded' | echohl None
|
||||
return
|
||||
endif
|
||||
call lsp#send_request(s:server, {
|
||||
\ 'method': 'textDocument/definition',
|
||||
\ 'params': s:cursor_position(),
|
||||
\ 'on_notification': function('s:badd_from_response'),
|
||||
\ })
|
||||
endfunction
|
||||
|
||||
function! s:badd_from_response(notification) abort
|
||||
let l:result = get(get(a:notification, 'response', {}), 'result', {})
|
||||
let l:uri = ''
|
||||
if type(l:result) == type({})
|
||||
let l:uri = get(l:result, 'uri', get(l:result, 'targetUri', ''))
|
||||
elseif type(l:result) == type([]) && !empty(l:result)
|
||||
let l:uri = get(l:result[0], 'uri', get(l:result[0], 'targetUri', ''))
|
||||
endif
|
||||
if l:uri ==# ''
|
||||
return
|
||||
endif
|
||||
let l:path = substitute(l:uri, '^file://', '', '')
|
||||
execute 'badd ' . fnameescape(l:path)
|
||||
echom 'nuwiki: added ' . l:path
|
||||
endfunction
|
||||
|
||||
" ===== Smart <CR>: follow or wrap-then-follow =====
|
||||
|
||||
function! s:cursor_inside_wikilink() abort
|
||||
|
||||
Reference in New Issue
Block a user