Added
vim.keymap.setleader bindings appear in which-key — leader-prefixed keymaps registered viavim.keymap.setwith adescoption now automatically appear in the which-key overlay, matchingvim.obsidian.leader.addbehavior. Group labels fromvim.obsidian.whichkey.add()work with bothvim.keymap.setandvim.obsidian.leader.addbindings. Buffer-local keymaps (buffer = 0) are excluded from global which-key. (#27)- Plugin:
src/lua/api.ts(leader prefix auto-detection invim.keymap.set),src/main.ts(consumeluaResult.leaderBindingsin LeaderRegistry)
- Plugin:
- Synthetic
BufEnterfor initial file —BufEnterautocmds now fire for the file already open when the plugin loads, matching Neovim behavior. Previously,BufEnteronly fired on subsequent file opens.- Plugin:
src/lua/autocmd.ts(activate()acceptsinitialFilePath),src/lua/loader.ts(passes current file path)
- Plugin:
Fixed
vim.cmd()broken at runtime —vim.cmd()called from function-mapped keymaps, autocmd callbacks, timer callbacks, and user commands silently failed because commands were queued but never executed after initial load. Fixed with aruntimeExHandlerthat executes commands immediately viavim.handleEx(). Cleanup on plugin unload prevents stale callbacks. (#49, #27)- Plugin:
src/lua/loader.ts(runtimeExHandler,activateRuntimeExHandler,deactivateRuntimeExHandler),src/main.ts(wire runtime handler, cleanup inonunload)
- Plugin:
- Function-callback keymaps lost after feature reload —
vim.keymap.setwith function callbacks registered keymaps that were silently destroyed whenreloadFeatures()calledvim.resetKeymap(). String-RHS keymaps survived but function callbacks did not. Fixed by movingapplyLuaMaps()to run afterreloadFeatures()and clearingluaActionNamesinloadLuaConfigForTest().- Plugin:
src/main.ts(applyLuaMapsordering,loadLuaConfigForTestcleanup)
- Plugin:
- Space as leader key breaks which-key —
vim.g.mapleader = " "with which-key in "all" mode now works correctly: space doesn't move the cursor, bindings execute, and grouped which-key displays. The "leader-only" mode still has a known limitation (see KNOWN_LIMITATIONS.md). (#49) - Surround nvim-surround parity (19 golden test fixes) — comprehensive alignment with nvim-surround semantics. Golden comparison tests passing: 54 → 73 out of 74. (#41)
ds}/ds]/ds)/ds>now preserve inner spaces (only opening bracket formsds{/ds[/ds(/ds<strip spaces)csbBysaBbchain —_surroundTypegating prevents stale replacement leaking across different surround operation typescsba..dot-repeat — search position offset by replacement delimiter width for correct nested pair iterationdsbon multiline content — cursor clamped to valid line length after bracket deletion- Count-prefixed
ds/cs(2dsb,3dsb,2csbB,3csbr) — changed from "find Nth pair" to "apply N times" semantics, matching nvim-surround yswith line-crossing motions (ysjb,ys2jB) — linewise motions now expand range to full linesySS/VSB/cS/yS/gSnewline indentation — single-line content no longer gets extra 2-space indent, matching nvim-surroundVS(linewise visual surround) — selection expanded to full lines, uses newline wrapping mode- Visual block
Ctrl-V $ S}— each line wrapped individually instead of entire block dsf— new operator: delete surrounding function call (some_func(args)→args), with nested call support- Fork:
src/vim.js—deleteSurroundPairspace/cursor,findSurroundingFunction, count loops, linewise/block visual handling,_surroundTypedot-repeat isolation - Fork:
src/types.ts—_surroundTypefield onInputStateInterface
Documentation
docs/configuration/lua-config.md: added leader key subsection withvim.g.mapleaderexamples and ordering warning; added tip callout comparingvim.cmd()vsvim.obsidian.leader.add()for leader bindingsdocs/configuration/which-key.md: added "Automatic labels from vim.keymap.set" section documentingdescoption integration with which-key and group label composition withwk.add()KNOWN_LIMITATIONS.md: added 7 Lua runtime entries (4 fixed, 3 open); updated test coverage (9 → 43 e2e tests); updated surround parity section- 34 new e2e tests across 4 suites —
lua-runtime.e2e.ts(8 tests: runtime vim.cmd execution from all callback contexts),lua-leader-whichkey.e2e.ts(9 tests: leader binding registration and which-key integration),lua-space-leader.e2e.ts(7 tests: space as leader key with regression coverage),lua-doc-examples.e2e.ts(10 tests: every documented Lua runtime callback example) - Shared test helpers extracted —
loadLuaConfig,focusEditor,setWhichKeyMode,hasWhichKeyOverlay,waitForWhichKey,getWhichKeyKeys,getWhichKeyDescriptions,getWhichKeyGroups,getLeaderBindings,getLeaderKey,getPluginSettingmoved totest/helpers.tsfrom local definitions
Full Changelog: 0.39.0...0.40.0