feat: your own commands complete with Tab and can be shared in the registry
Merged
KI
21d ago+798+798+012345678901234567890123456789-58-58-01234567890123456789
Problem
- Your own
:commands ([commands],:command) couldn't say what they do. - They didn't complete with Tab, which offered only built-ins.
- They couldn't be shared through the registry: a keymap entry may not define commands, and no kind could.
Change
- Descriptions:
- A command can be a table:
[commands.Review]withrun(a string or a list) anddescription. The string and list forms keep working. - Mistakes are warnings in the usual config.toml style: an unknown option, a non-string
description, a missingrun. :commandshowsName = steps · description, and:helphas a YOUR COMMANDS section.- A project command with shell steps that waits for
:trustnow says so when run, instead of E492, and runs after:trust.
- A command can be a table:
- Tab completion:
:re<Tab>offers your commands after the matching built-ins, case-insensitively, each with its description as the hint (using #187's hint support).- Commands from a trusted
.vigent.tomlcomplete normally. Shell commands from an untrusted one complete with(waits for :trust).
- A
commandkind in the registry:registry/command/<name>/entry.tomlholds[commands.<Name>]tables, each needingrunanddescription.- An entry may include
[keys.*]mappings, but only ones that call its own commands. A step may not define commands or mappings, so every shell step is visible. scripts/registry.mjschecks entries with vigent's loader and lists every!step inruns; ex-only commands are data only.vigent addmerges the entry into config.toml. It refuses a command or key you already have unless--force, shows the file and every shell step, and asks first.--list commandandvigent searchwork too.- Starter entries:
land::Landruns the tests, then:pr, with<leader>L.review-flow::Reviewand:Fixfrom the shipped templates.switch::Fastand:Deepset the effort.
- The website, docs/registry.md, registry/README.md, docs/config.md, the README and the config templates are updated.
- The TypeScript app and the Rust binary behave the same.
Verification
Run on this branch, which already contains current main (6ec92a6):
| Suite | Pass | Fail | Skipped |
|---|---|---|---|
npm test | 465 | 0 | 13 |
cargo test (crates/vigent) | 192 | 0 | – |
| full pty suite through the packaged Rust binary | 471 | 0 | 7 |
npm run registry:check: 14 entries ok.cargo build --releasehas no warnings, andwebsite/type-checks.- New tests:
- command tables and their warnings;
:commandand:helpoutput;- completion, including the trust hint;
- a pty test of Tab completion with hints, on both builds;
- validator cases: a bad name, a lowercase command, a missing description, mappings to other commands, steps that define commands, and shell steps listed in
runs; vigent addof a command entry, on both builds.
- Binary size: +13 KB (3,016,344 → 3,029,736 bytes); the archive is still 1.3 MB.
Follow-ups
- Keymap entries: a mapping that runs
:!cmd<CR>is shown as data only today. It should be listed inruns. This was already the case before this PR; it gets its own PR. - A command's hint shows only in the wildmenu, which needs two or more matches, as with #187.