VSCodeVim / VSCodeVim/Vim

Implement :source ex command

Open
#9,983 0 comments 0 reactions 0 assignees View on GitHub

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:

  1. Try the three vimrcKeyRemappingBuilder paths (remap, unmap, mapclear) and apply to configuration via the existing public VimrcImpl.{add,remove,clear}RemapFromConfig helpers. This mirrors what src/configuration/vimrc.ts already does at startup so :nnoremap / :unmap / :mapclear work as users expect.
  2. Otherwise feed the line through ExCommandLine.parser.tryParse(...) and execute the resulting command. This is the same pattern :foldclose / :folddoopen already 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.