Runic on Save
Formats Julia files with Runic.jl every time you save them.
Installing the extension registers Runic as a Julia formatter and sets these defaults for Julia files:
"[julia]": {
"editor.defaultFormatter": "JashAmbaliya.runic-on-save",
"editor.formatOnSave": true
}
"Format Document" and "Format Selection" use Runic too. Formatting a selection runs runic --lines.
Requirements
Runic.jl must be installed. Either of these works:
# Recommended by Runic: a shared environment named @runic
julia --project=@runic -e 'using Pkg; Pkg.add("Runic")'
# Or, on Julia 1.12+, as a Pkg app (installs ~/.julia/bin/runic)
julia -e 'using Pkg; Pkg.Apps.add("Runic")'
The extension looks for Runic in this order:
runic.executablePath, if set.
- A
runic executable on PATH or in ~/.julia/bin.
- Julia (
runic.juliaExecutablePath, then julia.executablePath, then julia on PATH or in ~/.juliaup/bin), run as julia --project=@runic -e 'using Runic; exit(Runic.main(ARGS))'.
If Runic.jl isn't installed in the Julia project, the error notification has an Install Runic.jl button that runs the install command above in a terminal.
Settings
| Setting |
Default |
Description |
runic.executablePath |
"" |
Path to the runic executable. Empty means auto-detect. |
runic.juliaExecutablePath |
"" |
Julia to use when no runic executable is found. |
runic.juliaProject |
"@runic" |
Julia project with Runic.jl installed (--project). Use "@." for the project nearest to the file. |
runic.args |
[] |
Extra Runic arguments, e.g. ["--docstrings"]. |
To keep Runic as the formatter but stop formatting on save:
"[julia]": { "editor.formatOnSave": false }
When something goes wrong
- A file with a syntax error is saved unchanged. The status bar shows the line and column of the error.
- Runic is not found or fails triggers one error notification per session. Details are in Runic: Show Log (the "Runic" output channel), which also records the command used and how long each format took.
- The Runic item in the language status area (the
{} next to "Julia" in the status bar) shows whether Runic is the default formatter, whether format on save is on, and the last error for the current file.
- Nothing happens on save? Check whether another formatter is set in your user settings (
"[julia]": { "editor.defaultFormatter": ... }). VS Code also skips format on save when files.autoSave is afterDelay.
Development
npm install
npm run compile # or: npm run watch
npm run test:unit # needs Runic installed
npm run test:integration # starts a separate VS Code instance with only this extension
npm run package # builds runic-on-save-<version>.vsix
code --install-extension runic-on-save-<version>.vsix
Press F5 in VS Code to start an Extension Development Host with the extension loaded.
npm run test:integration downloads VS Code into .vscode-test/. To use an installed copy instead, set VSCODE_EXECUTABLE_PATH, for example to /Applications/Visual Studio Code.app/Contents/MacOS/Code. When running from a terminal inside VS Code, unset ELECTRON_RUN_AS_NODE first.
The extension ID is JashAmbaliya.runic-on-save. If you change publisher in package.json, update the ID in configurationDefaults, src/extension.ts and src/test/integration/suite.ts to match.