Implement :source ex command
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15.2k
- Forks
- 1.5k
- Avg merge
- 3d 18h
- Merged PRs (30d)
- 6
Description
Running :source {file} currently errors with Command :so[urce] is not yet implemented (PRs are welcome!) because the entry at src/vimscript/exCommandParser.ts uses the undefined stub that falls through to UnimplementedCommand.
Proposal
Implement :source by reading the file and, for each non-blank / non-comment line:
- Try the three
vimrcKeyRemappingBuilderpaths (remap, unmap, mapclear) and apply toconfigurationvia the existing publicVimrcImpl.{add,remove,clear}RemapFromConfighelpers. This mirrors whatsrc/configuration/vimrc.tsalready does at startup so:nnoremap/:unmap/:mapclearwork as users expect. - Otherwise feed the line through
ExCommandLine.parser.tryParse(...)and execute the resulting command. This is the same pattern:foldclose/:folddoopenalready use to re-enter the ex-command parser. It naturally supports:set,:edit,:nohl, nested:source, and anything else already implemented.
Path resolution: expand ~ / $HOME, then resolve relatives against the first workspace folder (or the active document's directory when there is no workspace). Cycle detection via a static Set<string> of currently-being-sourced absolute paths, rejecting re-entry with E1092. Missing files report E484.
I have this implemented locally with tests covering basic mapping load, comments/blanks, nested source, cycle detection, missing file, and regular ex-command execution. Full test suite stays green. Will open a PR referencing this issue shortly.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at src/vimscript/exCommandParser.ts and compare startup remapping behavior in src/configuration/vimrc.ts. Trace ExCommandLine.parser.tryParse and the existing :foldclose/:folddoopen re-entry pattern, then inspect the issue’s described local tests for mappings, nested sourcing, cycles, missing files, and regular commands. Done means :source resolves paths, applies supported remaps, executes nested ex commands, and reports E1092 or E484 as specified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100