test(keymaps): headless Neovim harness for buffer-local bindings + CI
`scripts/test-keymaps.sh` boots `nvim --headless` against a scratch wiki, sources `scripts/test-keymaps.lua`, and asserts the post-state of each buffer-local mapping registered by `ftplugin/vimwiki.vim` + `lua/nuwiki/keymaps.lua`. The harness covers the bindings that actually have observable effects on the buffer or cursor: - **Lists** (LSP round-trip): `<C-Space>` / `<C-@>` / `<Nul>` toggle, `gln` cycle, `glx` reject, plus a `[X]→[ ]` round-trip. - **Tasks**: `gnt` jumps to the next unfinished `[ ]`. - **Headings** (LSP round-trip): `=` adds a level, `-` removes one, `=` on h6 clamps without growing. - **Header nav** (pure Lua): `]]` next, `[[` prev, `]u` parent. - **Link nav** (pure Lua): `<Tab>` to the next `[[…]]`. - **`<CR>` two-step**: first press wraps a bare word as `[[word]]` and stops (matches vimwiki's review-then-follow). - **Bullet continuation**: `o` / `O` keep the marker, and `o` on a `[ ]` line carries the checkbox forward. Each case sets buffer lines, places the cursor (1-based), fires `nvim_feedkeys` with `replace_termcodes`, waits long enough for the LSP `executeCommand` round-trip (800 ms by default; 100 ms for the pure-client maps), and asserts either the resulting lines, a specific line, the cursor's new line, or the buffer's new name. Output goes via `$NUWIKI_KEYMAP_RESULTS` (env-var IPC keeps it robust to `--clean -u` argument parsing). Exit code mirrors the harness: 0 on green, 1 on any FAIL. Local run yields: SUMMARY: 19 passed, 0 failed CI: new `keymaps` job in `.gitea/workflows/ci.yaml` installs Neovim and runs the script, so a regression in `lua/nuwiki/keymaps.lua`, `autoload/nuwiki/commands.vim`, or the LSP command surface is caught on every push. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -55,3 +55,26 @@ jobs:
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-test-
|
||||
- run: cargo test --workspace --all-targets
|
||||
|
||||
keymaps:
|
||||
name: editor keymaps
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@1.83
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-test-
|
||||
- name: install neovim
|
||||
run: |
|
||||
sudo apt-get update -qq
|
||||
sudo apt-get install -y --no-install-recommends neovim
|
||||
nvim --version | head -1
|
||||
- name: run keymap harness
|
||||
run: ./scripts/test-keymaps.sh
|
||||
|
||||
Reference in New Issue
Block a user