From 086455e19b373f22c8fddeba780ad01bc72ff279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Fr=C3=B3es=20Franco?= Date: Sun, 31 May 2026 16:21:49 +0000 Subject: [PATCH] fix(client): P2 diary tab collision + badd-link parity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two upstream-parity keymap fixes (confirmed against upstream ftplugin/vimwiki.vim): 1. wt collision — nuwiki bound both wt and wm to tomorrow's diary. Upstream: wt opens today's diary in a NEW TAB, wm opens tomorrow. w t now calls diary_today_tab; wm stays tomorrow. 2. badd-link — adding a link target to the buffer list was mouse-only () / command-only (:VimwikiBaddLink). Upstream binds -> VimwikiBaddLink. Added normal-mode -> badd_link to the links group of both clients. Both clients (lua/nuwiki/keymaps.lua, ftplugin/vimwiki.vim); README + doc/ nuwiki.txt updated. Tests: map[n]. in both harnesses; diary.leader_t_opens_today_in_tab / diary.leader_m_opens_tomorrow (vim). nvim 270, vim 263+18, all green. Co-Authored-By: Claude Opus 4.8 (1M context) --- README.md | 6 ++++-- development/tests/test-keymaps-vim.vim | 13 +++++++++++++ development/tests/test-keymaps.lua | 1 + development/vimwiki-gap.md | 16 ++++++++++++---- doc/nuwiki.txt | 4 +++- ftplugin/vimwiki.vim | 3 ++- lua/nuwiki/keymaps.lua | 4 +++- 7 files changed, 38 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f3a595d..f13915a 100644 --- a/README.md +++ b/README.md @@ -480,6 +480,7 @@ via `mappings. = false` in Neovim, or | `` | Follow in horizontal split | | `` | Follow in vertical split | | `` | Follow in a tab, reusing an existing tab if the file is already open | +| `` | Add the link target to the buffer list (`:badd`, no jump) | | `` | Jump back (``) | | `` / `` | Next / previous wikilink on or after the cursor | | `+` | Wrap word / visual selection as a wikilink (no follow) | @@ -542,8 +543,9 @@ vimwiki) they fire only after `'timeoutlen'`; type a suffix such as `gln` or | `wt` | Open the wiki index in a new tab | | `ws` | Pick a wiki | | `wi` | Open the diary index | -| `ww` / `wy` / `wt` | Diary today / yesterday / tomorrow | -| `wm` | Diary tomorrow (vimwiki-compat alias of `wt`) | +| `ww` / `wy` | Diary today / yesterday | +| `wt` | Diary today, in a new tab | +| `wm` | Diary tomorrow | | `wi` | Rebuild the diary index page | | `wn` / `wd` / `wr` | Goto / delete / rename page | | `wh` / `whh` | Export the current page to HTML / open in browser | diff --git a/development/tests/test-keymaps-vim.vim b/development/tests/test-keymaps-vim.vim index 45c299d..d44db2c 100644 --- a/development/tests/test-keymaps-vim.vim +++ b/development/tests/test-keymaps-vim.vim @@ -184,6 +184,7 @@ endfunction let s:mapping_surface = [ \ ['', 'n'], ['', 'n'], ['', 'n'], ['', 'n'], + \ ['', 'n'], \ ['', 'n'], ['', 'n'], ['', 'n'], ['+', 'nx'], \ ['', 'nx'], ['', 'nx'], ['', 'nx'], \ ['gnt', 'n'], ['gln', 'nx'], ['glp', 'nx'], ['glx', 'nx'], @@ -221,6 +222,18 @@ for s:entry in s:mapping_surface endfor endfor +" ===== Diary w{t,m} target (collision fix) ===== +" Upstream: wt = today in a new tab, wm = +" tomorrow. nuwiki used to bind both to tomorrow. +call s:record( + \ maparg('wt', 'n') =~# 'diary_today_tab' ? 1 : 0, + \ 'diary.leader_t_opens_today_in_tab', + \ 'rhs=' . maparg('wt', 'n')) +call s:record( + \ maparg('wm', 'n') =~# 'diary_tomorrow' ? 1 : 0, + \ 'diary.leader_m_opens_tomorrow', + \ 'rhs=' . maparg('wm', 'n')) + " ===== Header nav (pure VimL) ===== call s:run('headers.]]_jumps_to_next', { diff --git a/development/tests/test-keymaps.lua b/development/tests/test-keymaps.lua index 153e29c..1b9fbd7 100644 --- a/development/tests/test-keymaps.lua +++ b/development/tests/test-keymaps.lua @@ -206,6 +206,7 @@ vim.defer_fn(function() local mapping_surface = { -- Links { '', 'n' }, { '', 'n' }, { '', 'n' }, { '', 'n' }, + { '', 'n' }, { '', 'n' }, { '', 'n' }, { '', 'n' }, { '+', 'nx' }, -- Lists { '', 'nx' }, { '', 'nx' }, { '', 'nx' }, diff --git a/development/vimwiki-gap.md b/development/vimwiki-gap.md index 26b2bb5..691dc3a 100644 --- a/development/vimwiki-gap.md +++ b/development/vimwiki-gap.md @@ -81,8 +81,12 @@ fix site. ## P2 — Moderate (real users hit these) -- [ ] **`wt` collision** — upstream = today-in-new-tab; nuwiki = - tomorrow's diary. _Fix:_ `lua/nuwiki/keymaps.lua`, `ftplugin/vimwiki.vim`. +- [x] **`wt` collision** — upstream = today-in-new-tab; nuwiki + bound both `wt` and `wm` to tomorrow's diary. + _Fix:_ `wt` now calls `diary_today_tab` (today in a new tab), + `wm` stays tomorrow — exact upstream parity + (`lua/nuwiki/keymaps.lua`, `ftplugin/vimwiki.vim`; docs + README updated). + Covered by `diary.leader_t_opens_today_in_tab` / `diary.leader_m_opens_tomorrow`. - [ ] **Generated-section captions hardcoded** — `toc_header` / `toc_header_level`, `links_header`, `tags_header` (+levels). _Fix:_ `crates/nuwiki-lsp/src/config.rs` + server TOC/generate renderers. @@ -95,8 +99,12 @@ fix site. converter hook + export URL prefix. _Fix:_ `config.rs` `HtmlConfig`. - [ ] **`map_prefix`** — `w` hardcoded across the map layer. _Fix:_ `plugin/nuwiki.vim`, `lua/nuwiki/keymaps.lua`, `ftplugin/vimwiki.vim`. -- [ ] **`` badd-link** — missing (badd is mouse-only via `` / - `:VimwikiBaddLink`). _Fix:_ `lua/nuwiki/keymaps.lua`, `ftplugin/vimwiki.vim`. +- [x] **`` badd-link** — was mouse-only (``) / command-only + (`:VimwikiBaddLink`); upstream binds `` → `VimwikiBaddLink` (confirmed + against upstream `ftplugin/vimwiki.vim`). _Fix:_ added normal-mode `` → + `badd_link` in the links group of both clients (`lua/nuwiki/keymaps.lua`, + `ftplugin/vimwiki.vim`; docs + README updated). Covered by `map[n].` in + both keymap harnesses. - [ ] **`diary_caption_level` default divergence** — nuwiki `1` vs vimwiki `0`. _Fix:_ `config.rs:291` (and defaults in `lua/nuwiki/config.lua`). - [ ] **`diary_start_week_day`** — **wrongly removed** in `c63ec67`. The removal diff --git a/doc/nuwiki.txt b/doc/nuwiki.txt index d965c49..711001b 100644 --- a/doc/nuwiki.txt +++ b/doc/nuwiki.txt @@ -433,6 +433,7 @@ Links (normal mode) ~ Follow in a vertical split. Follow in a tab, reusing an existing tab if the file is already open. + Add the link target to the buffer list (`:badd`, no jump). Jump back (``). Next wikilink on or after the cursor. Previous wikilink. @@ -491,7 +492,8 @@ Wiki / diary / export ~ wi Open the diary index. ww Today. wy Yesterday. - wt Tomorrow. + wt Today, in a new tab. + wm Tomorrow. wi Rebuild the diary index page. wn Goto page (prompts for name). wd Delete the current page. diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index 79f152f..0482835 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -206,7 +206,7 @@ if !has('nvim') nnoremap wi :call nuwiki#commands#diary_index() nnoremap ww :call nuwiki#commands#diary_today() nnoremap wy :call nuwiki#commands#diary_yesterday() - nnoremap wt :call nuwiki#commands#diary_tomorrow() + nnoremap wt :call nuwiki#commands#diary_today_tab() nnoremap wm :call nuwiki#commands#diary_tomorrow() nnoremap wi :call nuwiki#commands#diary_generate_index() endif @@ -217,6 +217,7 @@ if !has('nvim') nnoremap :split:call nuwiki#commands#follow_link_or_create() nnoremap :vsplit:call nuwiki#commands#follow_link_or_create() nnoremap :call nuwiki#commands#follow_link_drop() + nnoremap :call nuwiki#commands#badd_link() nnoremap nnoremap /\[\[:nohlsearch nnoremap ?\[\[:nohlsearch diff --git a/lua/nuwiki/keymaps.lua b/lua/nuwiki/keymaps.lua index 20eda56..c9812dd 100644 --- a/lua/nuwiki/keymaps.lua +++ b/lua/nuwiki/keymaps.lua @@ -151,7 +151,7 @@ function M.attach(bufnr, mappings) map('n', 'wi', cmd.diary_index, { desc = 'nuwiki: open diary index' }, bufnr) map('n', 'ww', cmd.diary_today, { desc = 'nuwiki: today' }, bufnr) map('n', 'wy', cmd.diary_yesterday, { desc = 'nuwiki: yesterday' }, bufnr) - map('n', 'wt', cmd.diary_tomorrow, { desc = 'nuwiki: tomorrow' }, bufnr) + map('n', 'wt', cmd.diary_today_tab, { desc = 'nuwiki: today in a new tab' }, bufnr) map('n', 'wm', cmd.diary_tomorrow, { desc = 'nuwiki: tomorrow (vimwiki wm)' }, bufnr) map('n', 'wi', cmd.diary_generate_index, { desc = 'nuwiki: rebuild diary index' }, bufnr) end @@ -166,6 +166,8 @@ function M.attach(bufnr, mappings) { desc = 'nuwiki: follow link in vsplit' }, bufnr) map('n', '', cmd.follow_link_drop, { desc = 'nuwiki: follow link in tab (reuse existing)' }, bufnr) + map('n', '', cmd.badd_link, + { desc = 'nuwiki: add link target to buffer list' }, bufnr) map('n', '', '', { desc = 'nuwiki: go back', remap = true }, bufnr) map('n', '', link.next, { desc = 'nuwiki: next wikilink' }, bufnr) map('n', '', link.prev, { desc = 'nuwiki: prev wikilink' }, bufnr)