Language server and an extension for VS Code and VSCode-based editors with comprehensive support for TON Blockchain languages and technologies including Tolk, FunC, Fift assembly, TL-B, BoC, and Acton.
Features • Installation • Troubleshooting
Tolk support includes:
- Semantic syntax highlighting
- Code completion with auto import, postfix completion, snippets, imports completion
- Go to definition, type definition
- Find all references, workspace symbol search, symbol renaming
- Automatic import updates when renaming and moving files
- Types and documentation on hover
- Inlay hints for types, parameter names, and more
- On-the-fly inspections with quick fixes
- Signature help inside calls
- Build, test, format, lint, and debug projects based on Acton
- Flexible toolchain management
FunC support includes:
- Semantic syntax highlighting
- Code completion, imports completion
- Go to definition
- Find all references, workspace symbol search, symbol renaming
- Automatic import updates when renaming and moving files
- Types and documentation on hover
- Inlay hints for method id
- On-the-fly inspections
- Legacy FunC language support for existing contracts
Fift assembly support includes:
- Basic and semantic syntax highlighting
- Go-to definition
- Inlay hints with instruction gas consumption
- Hover documentation for instructions
TL-B support includes:
- Basic and semantic syntax highlighting
- Go-to definition
- Completion for fields, parameters, and types
- Go-to references for types
- Hover documentation for declarations
BoC support includes:
- Automatic BoC disassembly with syntax highlighting
- Automatic updates on BoC changes
The easiest way to get started with TON development is to use VS Code or editors based on it:
- Install the TON extension in VS Code or in VS Code-based editors
- Open an Acton project with an
Acton.tomlfile, or create one with the Acton CLI - That's it!
The extension automatically detects your Acton and Tolk toolchain installation. See the Acton integration guide for the project workflow. If you need to work with custom Tolk compiler builds, check out the toolchain management guide.
- Get the latest
.vsixfile from releases, from VS Code marketplace, or from Open VSX Registry - In VS Code:
- Open the Command Palette (
Ctrl+Shift+PorCmd+Shift+P) - Type "Install from VSIX"
- Select the downloaded
.vsixfile - Reload VS Code
- Open the Command Palette (
- Get the latest archive from releases:
ton-language-server-*.tar.gzfor Linux/macOSton-language-server-*.zipfor Windows
- Extract it to a convenient location
- Configure your editor to use the language server (see editor-specific instructions below)
If you want to build the language server yourself:
git clone https://github.com/ton-blockchain/ton-language-server
cd ton-language-server
yarn install
yarn buildTo obtain the .vsix package with the VS Code extension, additionally run:
yarn packageThen run either of those to install the extension from the .vsix package:
# VSCode, replace VERSION with the actual version from package.json
code --install-extension vscode-ton-VERSION.vsix
# VSCodium, replace VERSION with the actual version from package.json
codium --install-extension vscode-ton-VERSION.vsix-
Install LSP package:
- Open Command Palette (
Ctrl+Shift+PorCmd+Shift+P) - Select "Package Control: Install Package"
- Search for and select "LSP"
- Open Command Palette (
-
Add the following configuration to your LSP settings (
Preferences > Package Settings > LSP > Settings): -
Create a new file or open an existing file with the
.tolk,.fift, or.tlbextension to verify the setup
Prerequisites:
- nvim-lspconfig
- Neovim 0.5.0 or newer
Setup steps:
-
Add
ton.luato yourlua/lspconfig/server_configurationsdirectory with the following content:local util = require 'lspconfig.util' return { default_config = { cmd = { 'node', '/absolute/path/to/language-server/server.js', '--stdio' }, filetypes = { 'tolk', 'fift', 'tlb' }, root_dir = util.root_pattern('package.json', '.git'), }, docs = { description = [[ TON Language Server https://github.com/ton-blockchain/ton-language-server ]], default_config = { root_dir = [[root_pattern("package.json", ".git")]], }, }, }
-
Add the following to your
init.lua:require'lspconfig'.ton.setup {}
Prerequisites:
- Vim 8 or newer
- Async LSP Client for Vim: vim-lsp
Recommended, but not required:
- Auto-configurations for many language servers: vim-lsp-settings
Setup steps:
- Install the vim-lsp plugin if it isn't already installed. For that,
use vim-plug or the built-in package manager of Vim 8+, see
:help packages.
-
If it wasn't installed before, you should set up basic keybindings with the language client. Add the following to your
~/.vimrc(or~/_vimrcif you're on Windows):function! s:on_lsp_buffer_enabled() abort setlocal omnifunc=lsp#complete setlocal signcolumn=yes if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif nmap <buffer> gd <plug>(lsp-definition) nmap <buffer> gs <plug>(lsp-document-symbol-search) nmap <buffer> gS <plug>(lsp-workspace-symbol-search) nmap <buffer> gr <plug>(lsp-references) nmap <buffer> gi <plug>(lsp-implementation) nmap <buffer> gt <plug>(lsp-type-definition) nmap <buffer> <leader>rn <plug>(lsp-rename) nmap <buffer> [g <plug>(lsp-previous-diagnostic) nmap <buffer> ]g <plug>(lsp-next-diagnostic) nmap <buffer> K <plug>(lsp-hover) nnoremap <buffer> <expr><c-f> lsp#scroll(+4) nnoremap <buffer> <expr><c-d> lsp#scroll(-4) let g:lsp_format_sync_timeout = 1000 autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync') " Refer to the doc to add more commands: " https://github.com/prabirshrestha/vim-lsp#supported-commands endfunction augroup lsp_install au! " call s:on_lsp_buffer_enabled only for languages that have the server registered. autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() augroup END
-
Add the following to your
~/.vimrc(or~/_vimrcif you're on Windows):if executable('node') au User lsp_setup call lsp#register_server({ \ 'name': 'tolk', \ 'cmd': {server_info->['node', '/absolute/path/to/language-server/server.js', '--stdio']}, \ 'allowlist': ['tolk'], \ }) endif
-
Add the following configuration to your
~/.config/helix/languages.toml:[[language]] name = "tolk" language-servers = ["ton-language-server"] [language-server.ton-language-server] command = "node" args = ["/absolute/path/to/language-server/server.js", "--stdio"]
-
Replace
path/to/language-serverwith the actual path where you cloned the repository -
Restart Helix for changes to take effect
See TROUBLESHOOTING.md.
MIT
{ "clients": { "ton": { "enabled": true, "command": ["node", "path/to/language-server/server.js", "--stdio"], "selector": "source.tolk, source.fift, source.tlb", }, }, "inhibit_snippet_completions": true, "semantic_highlighting": true, }