Provides V language support for Visual Studio Code.
- syntax highlighting
- code snippets for quick coding
- completion, diagnostics, navigation, inlay hints, and other language features via VLS
- runnable CodeLens actions for
mainand tests - workspace build, run, and test tasks
- test coverage highlighting and a status bar summary
Install VLS and ensure the vls
executable is in PATH. Alternatively, set v.vls.command to its
absolute path. The extension starts VLS over stdio when a V workspace
is opened.
The available VLS settings are:
v.vls.enable: enable or disable VLSv.vls.command: path or command name for the VLS executablev.vls.args: additional command-line argumentsv.vls.inlayHints.enabled: enable or disable inlay hintsv.vls.diagnostics: enable or disable live diagnosticsv.vls.coverage.enabled: collect coverage during test tasks and highlight covered and uncovered executable linesv.executablePath: V compiler used by VLS and tasks; supports absolute paths,~,${env:NAME}, and${workspaceFolder}
Settings from the former VLS extension (vls.command, vls.args,
vls.vCommand, and its inlay hint, diagnostics, and coverage toggles) remain
effective until replaced by the corresponding v.* settings.
Use V: Build, V: Run, or V: Test in the Command Palette, or select a V
task from Tasks: Run Task. Build, Run, and Test operate on the workspace;
Run uses the active V module or script when one is open, and Test uses the
active _test.v file. The extension saves modified V files in the target
before running.
V: Run current file uses the same run task. For a .v file, it runs the
containing module; for a .vsh file, it runs the script.
VLS CodeLens actions such as Run Main, Run File, and Run Test use the
same tasks. Test runs collect coverage by default. Covered executable lines
are highlighted green and uncovered lines red. Click the coverage status
item or run V: Clear Test Coverage to remove the highlights.
To create a test file from a source file, run V: Generate Test File. It
creates the _test.v file beside the source with one test_ function per public
function, each with a placeholder assertion to replace. It refuses to overwrite
an existing test file.
Known gaps and what would close them, cheapest first — the missing Test Explorer integration, the absent debugger, and the parts of the test suite that fail on Windows. See ROADMAP.md; please read it before opening a pull request so we do not duplicate each other.
First you will need to install Visual Studio Code >= 1.105.
In the command palette (Cmd+Shift+P) select Install Extensions and choose V.
Alternatively you can install the extension from the Marketplace.
Now open any .v, .vsh, .vh, or .vv file in VS Code.
Note: It is recommended to turn Auto Save on
in Visual Studio Code (File -> Auto Save) when using this extension.
V: Run current fileV: Format current fileV: Build an optimized executable from current fileV: Generate Test FileV: Show V versionV: Update VLSV: Restart VLSV: Build,V: Run, andV: TestV: Clear Test Coverage
You can access all of the above commands from the command palette (Cmd+Shift+P).
Clone this repository and run npm install to install the dependencies.
Then press F5 to open a new VS Code window with the extension loaded.
Open the output console (Cmd+Shift+U) to see the debug output from the extension.
Run Cmd+Shift+P and select Preferences: Open User Settings to update settings.
Run npm test for logic checks and npm run test:vscode for an extension-host
check. The latter uses ~/code/vls/vls and ~/code/v/v by default and downloads
a local VS Code test build if CODE_EXECUTABLE is unset. Set VLS_BINARY and
V_BINARY to use other binaries. After npm run package, set
TEST_PACKAGED=1 when running npm run test:vscode to install and test the
VSIX in an isolated VS Code profile.
The extension is distributed under GPL-2.0-only because its task and coverage implementation comes from the VLS VS Code extension. Existing files covered by the MIT license retain that license.
