Tolk is a new language for writing smart contracts in TON. Think of Tolk as the "next‑generation FunC". Tolk compiler is literally a fork of FunC compiler, introducing familiar syntax similar to TypeScript, but leaving all low-level optimizations untouched.
This extension fully covers Tolk grammar and will be kept up to date with Tolk evolution.
Just search for "Tolk" in VS Code Marketplace. Here is a direct link.
- Syntax highlighting
- Auto-completion of global symbols and local variables
- Go to definition
- Brief info on symbol hover
- Code formatting
- Rename local variables
- Diagnostics of using undefined symbols ("Enable experimental diagnostics in settings)
- Auto-detect stdlib functions from
node_modules
(common for blueprint) and default system paths
Most missing features are "find usages" and auto-inserting imports. I hope to have enough time for implementation soon.
Watch a short video of how it looks like:
tolk_vscode_1.mp4
Tolk offers many standard functions, like beginCell()
, createEmptyTuple()
, and others.
They are listed in common.tolk
and related files, automatically discovered by Tolk compiler.
This extension automatically also discovers them automatically (to provide auto-completion and so on).
Most likely, you don't have to do anything — it just works. Below is an explanation.
For example, if you use blueprint,
it automatically installs tolk-js,
and therefore, folder node_modules/@ton/tolk-js/
exists in your file structure.
Inside, there are common.tolk
, tvm-dicts.tolk
, and others.
If you don't use blueprint, this extension searches for default system paths.
For example, on Linux, having installed a fresh TON package via apt
,
Tolk standard library was also installed inside /usr/share/ton
.
Anyway, you can open disable auto-detection in extension settings for a current workspace
and manually specify tolkCompilerVersion
and stdlibFolder
.
So, the algorithm is as follows:
- if auto-detection is disabled in settings, use manual settings
- look in
node_modules/@ton/tolk-js
- look in default system paths (apt, homebrew, Chocolatey)
- can't detect, diagnostics are disabled and a warning is shown
Invoke "Show detected Tolk SDK" from the command palette to view current values.
This command also clears cache (helpful in corner cases, e.g. you opened an empty project, detection failed,
then you did npm install
, use this command to re-detect).
Historically, this extension has been cloned from vscode-func and completely refactored.
It's implemented via LSP (Language Server Protocol). Parsing is implemented via tree-sitter-tolk. Unparsed nodes are treated as syntax errors. All symbols are kept in memory, assuming that Tolk projects are small enough.
There is a lot to improve both in functionality and implementation, but anyway, basic everyday needs are definitely satisfied.
yarn install
yarn watch
(makesdist/
folder)- Open this project in VSCode (even if you develop in JetBrains :)), tab "Run and Debug", button "Launch Extension"