Stof VS Code Extension
Language support for Stof (.stof files).
Stof is portable, sandboxed logic inside data: JSON with functions, types, units, and tests that you can send anywhere and run safely in Rust, WebAssembly, and Python.
Features
- Highlighting for everything in Stof: fields, functions, types, units, attributes, and template strings.
- Errors and warnings as you type: parse errors, unknown names, and anything else Stof warns about, including
errors in imported files.
- Outline of objects, types, fields, and functions (also used for breadcrumbs and "Go to Symbol").
- Go to definition for
self. and super. paths, functions (including ones from a type), types
(<User>, new User {}), and imports.
- Hover for signatures, field types and values, doc comments, and docs for every library function
(
Num.abs, Str::split, pln).
- Completion for fields and functions after
self. (or any path), library functions after Num. or Num::,
types after <, new, and as, and variables, parameters, libraries, and keywords everywhere else.
- Local variables and parameters: go to definition, hover (shows where it's declared), and references.
- Find all references and rename for fields, functions, types, roots, and local variables, across the
Stof files you have open.
Setup
Everything except highlighting comes from the Stof language server in the Stof CLI:
cargo install stof-cli
The extension runs stof lsp. If stof isn't on your PATH, set stof.server.path to the CLI's full path.
Without the CLI, highlighting still works.
A file in a package (a folder with a pkg.stof, or anywhere under one) is checked as part of the whole package,
so types, fields, and functions from its other files resolve. Unsaved changes in open files are included, and
saving a file rechecks the other open files.
While a file has a syntax error (Ex. halfway through typing), navigation and completion use the last version of it
that parsed. References and rename only see open files, so open the files that use a name before renaming it.
The server parses your documents in a sandbox: no network or environment access, file reads only for imports,
init functions don't run, and code that runs while parsing (field values) stops after 2 seconds.
Issues and contributions are welcome in the GitHub Repository.
| |