Sun Language for VS Code
Editor support for the Sun programming language:
a compiled language with Rust-style borrow checking and an LLVM backend.
Features
- Syntax highlighting with C++-style theme scopes: control flow, declarations, primitive types, named types, functions, and variables have separate roles. Constructors and destructors use function highlighting. Semantic tokens refine names without overriding keyword colors. Colors follow your active theme. Includes file icons for
.sun and .moon bundles.
- Diagnostics from the Sun compiler as you type: parse errors, type errors and borrow-checker errors.
- Hover to see the type of a variable, field, function or method.
- Go to definition, including into library sources: symbols from a
.moon bundle open the original .sun file when it is on disk.
- Find references to every use of a symbol across the files of a manifest. Referencing an interface member also lists the class members implementing it, and the other way around.
- Rename symbol across the files of a manifest. An interface member is renamed together with the class members implementing it. Symbols declared in a library cannot be renamed.
- Formatting via "Format Document" and format-on-save.
- Cross-file analysis: files listed in a
manifest block are analyzed together with their entrypoint. Entrypoints are configured with sun.entrypoints or sun.sun_configs.
Syntax highlighting only
Enable Sun: Syntax Only in Settings, or add this to workspace settings:
{
"sun.syntaxOnly": true
}
This keeps syntax highlighting while disabling the language server and Test
Explorer, including diagnostics, semantic tokens, formatting, and navigation.
Use it for screenshots or examples that do not compile. Changes apply immediately;
turn it off to restore language features. No Sun installation is needed in this mode.
Requirements
The extension talks to the Sun language server, sun-lsp, which ships with the Sun compiler.
By default it is looked up on your PATH; set sun.lsp_path to point at it if it lives
elsewhere (for example a local build at build/sun-lsp).
Settings
| Setting |
Description |
sun.syntaxOnly |
Keep only syntax highlighting; disable the language server and Test Explorer. Defaults to false. |
sun.lsp_path |
Path to the sun-lsp executable. Defaults to sun-lsp on PATH. Relative paths resolve against the workspace folder. |
sun.compiler_path |
Path to the sun compiler, used by the Test Explorer to run tests. Defaults to sun on PATH; the binary next to sun-lsp is tried as a fallback. |
sun.sun_configs |
sun-config.json files whose entrypoints lists describe the project. Defaults to the workspace root's. Test discovery and cross-file analysis use their declared entrypoints. |
sun.sun_path |
Extra directories added to SUN_PATH for module resolution. Defaults to the workspace folder. |
sun.entrypoints |
Entrypoint files containing a manifest block. Combined with entrypoints declared by sun.sun_configs. |
sun.path_variables |
Path variables for manifest entries, e.g. {"LIBS": "libs"} for libraries: ["$LIBS/mathlib.moon"]. Equivalent to the compiler's --path-var flag; relative values resolve against the entrypoint's directory. |
A folder can also hold a sun-config.json defining sunPath and
pathVariables for the entrypoints in and below it. Both the compiler and
the language server merge every config from the entrypoint's folder upward
(nearest definitions win; "root": true stops the search), and the merged
definitions override the settings above.
Test Explorer
Test Explorer discovers tests only through configured entrypoints, even when no
files are open. Without configured entrypoints, the tree is empty. Opening a file
never adds a test suite. Config file changes and saved Sun source changes refresh
the tree automatically; config files may be created after the server starts.
Learn more