Commit Graph

54 Commits

Author SHA1 Message Date
gffranco d58a34a2d7 feat(vim): close keymap gap with Neovim (47 → 63 maps)
CI / cargo fmt --check (push) Successful in 30s
CI / cargo clippy (push) Successful in 1m8s
CI / cargo test (push) Successful in 1m14s
The previous commit registered the parity surface on Neovim but only
ported ~75% to plain Vim. Filling the remaining 16:

autoload/nuwiki/commands.vim — new functions:
- `wiki_ui_select` — Vim has no `vim.ui.select`, so route through
  `inputlist()` after fetching the wiki list via the LSP.
- `open_below_with_bullet` / `open_above_with_bullet` — port of the
  Lua `o` / `O` continuation that preserves the list marker (and a
  `[ ]` checkbox when present) on the new line.
- `next_header` / `prev_header` / `next_sibling_header` /
  `prev_sibling_header` / `parent_header` — port of the Lua heading
  jumper. Pure VimL, no LSP round-trip.

ftplugin/vimwiki.vim (Vim path) new mappings:
- `<Leader>ws` → `wiki_ui_select`
- `]=` / `[=` → next / prev sibling header
- `]u` / `[u` → parent header
- `o` / `O` → bullet continuation
- `gl<Space>` / `gL<Space>` → :VimwikiRemove*CB stubs
- `gq1` / `gw1` → :VimwikiTableAlignQ1/W1 stubs
- x-mode variants for `+`, `<Leader>wc`, `gln`, `glp`, `glx`

Replaced the regex-based `]]` / `[[` (which just searched `^\s*=\+\s`)
with calls into the new heading nav so they skip non-heading `=`
runs and respect heading levels.

Verified end-to-end: `silent map <buffer>` reports 63 maps on Vim,
matching Neovim's 63. All 377 Rust tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 00:50:49 +00:00
gffranco 9e6faa5554 feat(mappings): vimwiki-parity default keymaps for Vim + Neovim
CI / cargo fmt --check (push) Successful in 17s
CI / cargo clippy (push) Successful in 1m19s
CI / cargo test (push) Successful in 1m22s
The Phase 19 keymap layer only covered the high-value subset and used
`g=`/`g-` instead of vimwiki's `=`/`-` for header levels. Users
reporting "mappings don't seem to be working" were either on the Vim
path (which registered zero keymaps) or hitting bindings that don't
exist (e.g. `<Tab>`, `<S-CR>`, `gll`, `gqq`).

Cross-referenced upstream vimwiki/ftplugin/vimwiki.vim and rewired
both `lua/nuwiki/keymaps.lua` and `ftplugin/vimwiki.vim` (Vim path)
to match its default surface. Mappings backed by commands that exist
on the server dispatch directly; §13.1-deferred mappings register
with the same lhs but stub out to a notification — so users get
parity *signalling*, not silence.

New on Neovim (and matched on Vim where possible):

Links group:
- `<S-CR>` / `<C-CR>` / `<C-S-CR>` — follow in split / vsplit / tab
- `<Tab>` / `<S-Tab>` — jump to next / prev `[[…]]` (pure Lua search)
- `+` (n + x) — :VimwikiNormalizeLink stub
- `<Leader>wc` (n + x) — :VimwikiColorize stub

Lists group:
- `<C-@>` (n + x) — terminal-alt for `<C-Space>`
- `gln` / `glp` increment + decrement (deferred backward; same fn for now)
- `glh` / `gll` / `gLh` / `gLl` — list level stubs
- `glr` / `gLr` — list renumber stubs
- `gl<Space>` / `gL<Space>` — checkbox remove stubs
- `o` / `O` — open below/above and continue the bullet (pure Lua)
- visual-mode variants of `<C-Space>`, `gln`, `glp`, `glx`

Header group (key group, now buffer-local):
- `=` / `-` — promote / demote (was `g=`/`g-`, matched to vimwiki)
- `]]` / `[[` — next / prev header (pure Lua)
- `]=` / `[=` — next / prev sibling header (pure Lua)
- `]u` / `[u` — parent header (pure Lua)

Table group: `gqq`, `gq1`, `gww`, `gw1`, `<A-Left>`, `<A-Right>` stubs.

Wiki prefix: `<Leader>w<Leader>m` (vimwiki's tomorrow), `<Leader>w<Leader>i` (rebuild diary index).

Config schema (`config.options.mappings`) updates to vimwiki's group
names — `links` / `lists` / `headers` / `table_editing` / `diary` /
`html_export` / `text_objects` / `wiki_prefix`. Old names
(`list_editing` / `header_nav`) are retired; rename only — keeps the
opt-out shape intact.

Vim path: same set ported to buffer-local VimL maps. `g:nuwiki_no_default_mappings`
opts out the whole layer for users who prefer their own bindings. Lua
side uses the Neovim 0.11+ `vim.keymap.set` API; both call straight
into the same `nuwiki#commands#…` autoload (Vim) / `nuwiki.commands`
(Lua) layer that drives the LSP.

Total 377 tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 00:46:40 +00:00
gffranco 04df170791 feat(vim): :Vimwiki* / :Nuwiki* commands for plain Vim via vim-lsp
CI / cargo fmt --check (push) Successful in 30s
CI / cargo clippy (push) Successful in 1m16s
CI / cargo test (push) Successful in 1m27s
The Phase 19 ftplugin only registered the command surface on Neovim
and finished early for plain Vim, leaving `start-vim.sh` users with
only commentstring + suffixesadd — exactly the "no commands" report.

`autoload/nuwiki/commands.vim` now ships the Vim-side dispatch:
- `s:exec` sends `workspace/executeCommand` through vim-lsp's
  `lsp#send_request`. Optional callback for commands that return data.
- `s:open_uri_from` reads `{ uri }` out of the LSP response and runs
  `:edit` (or `:tabedit` for the tab variants).
- `s:results_to_qf` lifts `checkLinks` / `findOrphans` / `tags.search`
  arrays into the quickfix list and opens `:copen` — same UX as the
  Neovim path.
- `s:open_browser` fires `open` / `xdg-open` after `export.browse`.
- §13.1 deferred commands stub out with a "not yet implemented"
  notification so users get the same signal as on Neovim.

`ftplugin/vimwiki.vim` defines the same `:Vimwiki*` / `:Nuwiki*`
command set on the plain-Vim path, each delegating to its
`nuwiki#commands#…` autoload counterpart. `:VimwikiFollowLink` /
`:VimwikiBacklinks` map straight to vim-lsp's `:LspDefinition` /
`:LspReferences`. coc.nvim users can still use `:CocCommand` directly
and ignore the aliases entirely.

Verified with `vim -e -s -u .vimrc index.wiki`:
  filetype=vimwiki, did_ftplugin=1,
  :VimwikiTOC, :NuwikiIndex, :VimwikiToggleListItem all defined.

Total 377 tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 22:23:06 +00:00
gffranco 09b9bd98a3 fix(ftplugin): load on .wiki buffers without manual filetype override
CI / cargo fmt --check (push) Successful in 35s
CI / cargo clippy (push) Successful in 1m12s
CI / cargo test (push) Successful in 1m26s
Three reasons the plugin wasn't activating on `nvim --clean -u init.lua
foo.wiki`:

1. **File-name mismatch.** Vim's filetype-plugin runtime looks for
   `ftplugin/<filetype>.vim` matching the *filetype name*. Our
   filetype is `vimwiki` (per `ftdetect`) but the file was named
   `ftplugin/nuwiki.vim` — so `:runtime! ftplugin/vimwiki.vim` from
   the built-in FileType autocmd never found it, and none of the
   `:Vimwiki*` / `:Nuwiki*` commands got defined. Same wart on the
   syntax side. Renamed:
   - `ftplugin/nuwiki.vim`  → `ftplugin/vimwiki.vim`
   - `syntax/nuwiki.vim`    → `syntax/vimwiki.vim`

2. **`setfiletype` deferred to Neovim's bundled rule.** Neovim ships
   a default `*.wiki → mediawiki` rule via `vim.filetype.add`, and
   `:setfiletype vimwiki` is a no-op once a filetype has been set.
   - `ftdetect/nuwiki.vim` now uses `set filetype=vimwiki` (force).
   - `lua/nuwiki/init.lua`'s `setup()` also calls
     `vim.filetype.add({ extension = { wiki = 'vimwiki', ... } })`
     so the modern table-based detection picks us before the
     bundled rule fires. Honours `config.options.file_extension`
     so a user with a custom extension gets covered automatically.

3. **`foldmethod`/`foldexpr` are window-local options.**
   `ftplugin.lua` was setting them with `nvim_set_option_value({ buf
   = bufnr })`, which threw `'buf' cannot be passed for window-local
   option 'foldmethod'` and aborted the rest of the per-buffer
   attach. Switched to `vim.opt_local.*` (window-aware), applied on
   the current window when the ftplugin fires, and re-applied via a
   `BufWinEnter` autocmd so `:split` / `:vsplit` keep the fold mode.

Verified end-to-end with:

  nvim --clean -u init.lua sample.wiki
  → filetype = vimwiki
  → :VimwikiTOC, :NuwikiIndex, … all defined
  → foldmethod = expr, foldexpr = v:lua.vim.lsp.foldexpr()
  → ftdetect, plugin, ftplugin, syntax all in :scriptnames

Total 377 tests still pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 22:16:57 +00:00