phase 19: editor glue v2
Server-side:
- New `folding.rs` module with `folding_ranges(ast, total_lines)`.
Emits one fold per top-level heading (start → line before the
next same-or-higher-level heading, or EOF) plus one per top-level
list block. Nested headings fold inside their parent thanks to the
level-aware end-line computation; sublists fold implicitly via
their parent item's source span. `FoldingRangeKind::Region` is set
on every fold so collapsing UIs render them as section folds.
- `Backend::folding_range` handler wires the module into
`textDocument/foldingRange`; `ServerCapabilities.folding_range_provider`
advertises it.
- `folding::line_count` exposed for the handler and tests; treats a
trailing newline as a virtual empty line (the line LSP positions
use for EOF).
Editor glue (Neovim primary, Vim minimal):
- `lua/nuwiki/commands.lua` — async `workspace/executeCommand`
wrappers for every server command shipped through Phase 18. The
open-* family handles `{ uri }` responses by opening the file
(with `tab` / `split` variants). `check_links` and `find_orphans`
hand results to `setqflist` + `:copen` for quickfix-style review.
§13.1-deferred commands (`list.changeSymbol`, table rewriters,
`link.pasteWikilink/pasteUrl`, `colorize`) stub out with
`vim.notify` so users get a clear "not yet implemented" signal
instead of an LSP "unknown command" error.
- `lua/nuwiki/keymaps.lua` — buffer-local default mappings. Subgroups
(`list_editing`, `header_nav`, `diary`, `html_export`,
`text_objects`) flip independently via the new
`mappings.<group>` config. Heading promote/demote uses `g=`/`g-`
to avoid clobbering Vim's built-in `=`/`-` operators.
- `lua/nuwiki/textobjects.lua` — `ah`/`ih` (around/inside heading)
using a buffer scan for the heading-block boundary. The four
remaining text objects from SPEC §12.10 wait until §13.1 lands
the table/list rewriters they share infrastructure with.
- `lua/nuwiki/folding.lua` — pure regex `foldexpr` + `foldtext`
fallback for clients without `foldingRange`. Same heading-block
model as the server.
- `lua/nuwiki/ftplugin.lua` — single per-buffer attach entry point.
`folding = 'lsp'` (default) uses Neovim 0.11+'s `vim.lsp.foldexpr`,
falling back to the regex on older versions; `'expr'` forces the
fallback; `'off'` skips folding setup.
- `lua/nuwiki/config.lua` — extends defaults with `mappings = {...}`
(P10 keymap layer) and `folding` (P14 resolved).
- `ftplugin/nuwiki.vim` — declares every `:Vimwiki*` / `:Nuwiki*`
command from SPEC §12.10 by inlining `lua require(...).fn()`
bodies (no script-local function indirection so commands stay
callable after re-source). Plain-Vim users get only the buffer
options; they're expected to drive the LSP via vim-lsp / coc's
built-in commands.
Health check (§12.10 additions):
- `:checkhealth nuwiki` now reports the count of `executeCommand`
entries the server advertises, whether `foldingRange` capability
was negotiated, and whether the configured HTML output directory
exists + is writable. Default keymap subgroup status is also
surfaced.
Tests: 8 new in `phase19_folding.rs` covering empty docs, single
heading → EOF, sibling headings each getting their own fold,
nested heading bounded by parent, top-level list folds, single-line
heading non-fold, fold-kind classification, and `line_count`
semantics. Total 377 tests pass; fmt + clippy clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1382,14 +1382,12 @@ Deferred because the value proposition over the existing
|
||||
`workspace/rename` flow is marginal and the editor-side support is
|
||||
inconsistent across clients.
|
||||
|
||||
### 13.3 v1.1 phase 19
|
||||
### 13.3 v1.1 status
|
||||
|
||||
Tracked in §10 with status `⏳`. Not "missing" from earlier phases —
|
||||
it's future work in the v1.1 roadmap:
|
||||
|
||||
- **Phase 19** — Editor glue v2: `:Vimwiki*` compat layer, default
|
||||
keymaps, text objects, folding (P14 already resolved in favour of
|
||||
LSP `foldingRange` + `foldexpr` fallback).
|
||||
All numbered phases through 19 are shipped. The remaining work is
|
||||
the §13.1 deferred Phase 14 command surface (table/list rewriters,
|
||||
link helpers, colorize) and the small follow-ups noted under §13.2 /
|
||||
§13.4.
|
||||
|
||||
Earlier v1.1 phases now shipped:
|
||||
|
||||
@@ -1409,6 +1407,21 @@ Earlier v1.1 phases now shipped:
|
||||
picker commands: `nuwiki.wiki.listAll`, `nuwiki.wiki.select`,
|
||||
`nuwiki.wiki.openIndex`, `nuwiki.wiki.tabOpenIndex`, plus
|
||||
`nuwiki.wiki.gotoPage` for the `:VimwikiGoto` compat surface.
|
||||
- Phase 19 (editor glue v2) — LSP `textDocument/foldingRange`
|
||||
provider (`folding::folding_ranges`) with heading-block + top-level
|
||||
list semantics; advertised via `folding_range_provider`. A pure
|
||||
Lua `foldexpr` fallback ships in `lua/nuwiki/folding.lua` for
|
||||
clients without `foldingRange` support. `ftplugin/nuwiki.vim`
|
||||
defines the full `:Vimwiki*` compat surface plus `:Nuwiki*`
|
||||
aliases — every command that maps to a server-side `executeCommand`
|
||||
is wired; §13.1-deferred commands stub out with a "not yet
|
||||
implemented" notification so users get a clear signal. Default
|
||||
buffer-local keymaps cover the working subset (checkbox toggle,
|
||||
next task, heading promote/demote via `g=`/`g-`, diary navigation
|
||||
via `<C-Up>`/`<C-Down>`, HTML export under `<Leader>wh*`). A
|
||||
heading text object (`ah`/`ih`) ships now; `aH`/`iH`/`a\`/`i\`/
|
||||
`ac`/`ic`/`al`/`il` land once the §13.1 table/list rewriters
|
||||
arrive.
|
||||
|
||||
### 13.4 §9 syntax checklist status
|
||||
|
||||
|
||||
Reference in New Issue
Block a user