{"id":13734690,"url":"https://github.com/tact-lang/tree-sitter-tact","last_synced_at":"2025-10-23T20:32:20.966Z","repository":{"id":219190479,"uuid":"747396955","full_name":"tact-lang/tree-sitter-tact","owner":"tact-lang","description":"🌳 Tree-sitter grammar for the ⚡ Tact contract programming language","archived":false,"fork":false,"pushed_at":"2024-09-26T14:17:32.000Z","size":630,"stargazers_count":18,"open_issues_count":9,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-09-27T10:41:18.433Z","etag":null,"topics":["grammar","highlighting","lexer","parser","tact","the-open-network","ton","tree-sitter","tree-sitter-parser","tree-sitter-tact"],"latest_commit_sha":null,"homepage":"https://tact-lang.org","language":"Scheme","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tact-lang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-23T21:02:46.000Z","updated_at":"2024-09-26T14:15:42.000Z","dependencies_parsed_at":"2024-01-26T00:25:39.129Z","dependency_job_id":"63b0325d-f77d-4a98-b495-c9ec7d641345","html_url":"https://github.com/tact-lang/tree-sitter-tact","commit_stats":null,"previous_names":["tact-lang/tree-sitter-tact"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tact-lang%2Ftree-sitter-tact","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tact-lang%2Ftree-sitter-tact/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tact-lang%2Ftree-sitter-tact/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tact-lang%2Ftree-sitter-tact/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tact-lang","download_url":"https://codeload.github.com/tact-lang/tree-sitter-tact/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219867845,"owners_count":16555812,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["grammar","highlighting","lexer","parser","tact","the-open-network","ton","tree-sitter","tree-sitter-parser","tree-sitter-tact"],"created_at":"2024-08-03T03:00:58.885Z","updated_at":"2025-10-23T20:32:20.959Z","avatar_url":"https://github.com/tact-lang.png","language":"Scheme","funding_links":[],"categories":["Tools and utilities [↑](#contents)"],"sub_categories":["Grammars and highlighting"],"readme":"# tree-sitter-tact\n\n\u003ccenter\u003e\n  \u003cimg src=\".github/BANNER.png\" alt=\"Tree-sitter + Tact = tree-sitter-tact\"/\u003e\n\u003c/center\u003e\n\nA fully-featured 🌳 [Tree-sitter](https://github.com/tree-sitter/tree-sitter) grammar for the ⚡ Tact contract programming language:\n\n- 🍰 Parses whole Tact grammar as defined in [grammar.gg](https://github.com/tact-lang/tact/blob/da4b8d82128cf4b6f9b04d93a93a9382407112c2/src/grammar/next/grammar.gg) (with performance and usability in mind).\n- 🎨 Provides highlighting, scoping and tagging [queries](#-structure).\n- ⚙ Test-covered (including queries), reflects latest Tact language updates.\n- 🚀 See guidelines on usage and integration in editors supporting Tree-sitter [below](#-usage).\n\n## 🚀 Usage\n\n### Neovim\n\nInstallation assumes you're using [`lazy.nvim`](https://github.com/folke/lazy.nvim) as a plugin manager:\n\n\u003cdetails\u003e\n\u003csummary\u003eInstructions\u003c/summary\u003e\n\n1. Clone the repo to any convenient place: `git clone https://github.com/tact-lang/tree-sitter-tact ~/.local/git/tree-sitter-tact` (`~/.local/git` is exemplary, you may choose another directory)\n\n2. Add the following (partly or as a whole) to your `~/.config/nvim/init.lua` (Or `~\\AppData\\Local\\nvim\\init.lua` on Windows):\n\nFor the general Tree-sitter support:\n\n```lua\n-- lazy.nvim package manager\nrequire('lazy').setup({\n  -- ...\n\t{\n    -- Highlight, edit, and navigate code\n    'nvim-treesitter/nvim-treesitter',\n    build = ':TSUpdate',\n\n    -- Optional, may be removed:\n    dependencies = {\n      -- adds syntax aware text-objects, select, move, swap, and peek support\n      -- see: https://github.com/nvim-treesitter/nvim-treesitter-textobjects\n      'nvim-treesitter/nvim-treesitter-textobjects',\n\n      -- adds a sticky context header on top as you scroll through file contents\n      -- see: https://github.com/nvim-treesitter/nvim-treesitter-context\n      'nvim-treesitter/nvim-treesitter-context'\n    },\n  },\n  -- ...\n}, {})\n```\n\nFor the tree-sitter-tact support:\n\n```lua\nlocal parser_config = require \"nvim-treesitter.parsers\".get_parser_configs()\n\n-- Adds tree-sitter-tact support\nparser_config.tact = {\n  install_info = {\n    url = \"~/.local/git/tree-sitter-tact\", -- a path to the cloned repo\n    files = {\"src/parser.c\"},\n    branch = \"main\",\n    generate_requires_npm = false,\n    requires_generate_from_grammar = false,\n  }\n}\n\n-- Adds filetype recognition for .tact files\nvim.filetype.add({\n  extension = {\n    tact = \"tact\",\n  }\n})\n```\n\n3. Create a folder for queries under your Neovim runtime directory, if not exists:\n  * Windows: `mkdir -p ~\\AppData\\Local\\nvim\\queries`\n  * Linux, macOS, *NIX: `mkdir -p ~/.config/nvim/queries`\n\n4. Symlink the `editor_queries/neovim` sub-directory, this will add all the queries:\n  * Windows: `mklink /D ~\\AppData\\Local\\nvim\\queries\\tact ~\\.local\\git\\tree-sitter-tact\\editor_queries\\neovim`\n  * Linux, macOS, *NIX: `ln -s ~/.local/git/tree-sitter-tact/editor_queries/neovim ~/.config/nvim/queries/tact`\n\n5. Finally, run the `:TSInstall tact` inside the Neovim.\n\n6. For further configuration and customization, refer to the following repositories:\n* [nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter)\n* [nvim-treesitter-textobjects](https://github.com/nvim-treesitter/nvim-treesitter-textobjects)\n* [nvim-treesitter-context](https://github.com/nvim-treesitter/nvim-treesitter-context)\n\n\u003c/details\u003e\n\nQueries bundled (see `editor_queries/neovim`):\n* `highlights.scm` — syntax highlighting\n* `locals.scm` — used to extract keyword definitions, scopes, references, etc., but NOT used for highlighting (unlike Generic or Helix queries)\n* `injections.scm` — highlighting of TODO, FIXME and related in single-line comments\n* `folds.scm` — syntax folds (note, that folding has to be enabled in config in order to use those)\n* `indents.scm` — indentation levels\n* `textobjects.scm` — syntax aware text-objects, select, move, swap, and peek support.\n* `context.scm` — shows sticky context on top of the editor as you scroll through file contents\n\n### Helix\n\n\u003c!--\n  TODO: update and simplify instructions — there should be a straightforward\n  way to install parser and relevant queries (git clone on tag?)\n\n  Also specify that 24.03 comes with support for Tact 1.2.0, while one may need\n  support for 1.3.0 or other versions of Tact (git clone on tag?)\n\n  Provide version matrixes? No, just specify what version of Tact latest release supports.\n --\u003e\n\n:rocket: Helix version 24.03 comes bundled with tree-sitter-tact for Tact 1.2.0.\n\nIf you want to always have the latest parser and queries available (which target branches `master` of Helix and `main` of Tact), do the following:\n\n\u003cdetails\u003e\n\u003csummary\u003eInstructions\u003c/summary\u003e\n\n1. Clone the repo to any convenient place: `git clone https://github.com/tact-lang/tree-sitter-tact ~/.local/git/tree-sitter-tact` (`~/.local/git` is exemplary, you may choose another directory)\n\n2. Create a folder for queries under your Helix runtime directory, if not exists:\n  * Windows: `mkdir -p ~\\AppData\\Roaming\\helix\\runtime\\queries`\n  * Linux, macOS, *NIX: `mkdir -p ~/.config/helix/runtime/queries`\n\n3. Symlink the `editor_queries/helix` sub-directory, this will add all the queries:\n  * Windows: `mklink /D ~\\AppData\\Roaming\\helix\\runtime\\queries\\tact ~\\.local\\git\\tree-sitter-tact\\editor_queries\\helix`\n  * Linux, macOS, *NIX: `ln -s ~/.local/git/tree-sitter-tact/editor_queries/helix ~/.config/helix/runtime/queries/tact`\n\n4. Add the following to your `~/.config/helix/languages.toml` (Or `~\\AppData\\Roaming\\helix\\languages.toml` on Windows):\n\n```toml\n[[language]]\nname = \"tact\"\nscope = \"source.tact\"\ninjection-regex = \"tact\"\nfile-types = [\"tact\"]\ncomment-token = \"//\"\nblock-comment-tokens = [{ start = \"/*\", end = \"*/\"}]\nindent = { tab-width = 4, unit = \"    \" }\n\n[language.auto-pairs]\n'\"' = '\"'\n'{' = '}'\n'(' = ')'\n'\u003c' = '\u003e'\n\n[[grammar]]\nname = \"tact\"\nsource = { path = \"/absolute/path/to/your/home/directory/.local/git/tree-sitter-tact\" }  # TODO: replace with your full path to downloaded repo\n```\n\n6. Finally, run the following commands to update all Tree-sitter grammars, including Tact's:\n\n```bash\nhx --grammar fetch\nhx --grammar build\n```\n\n\u003c/details\u003e\n\nQueries bundled (see `editor_queries/helix`):\n* `highlights.scm` — syntax highlighting\n* `injections.scm` — highlighting of TODO, FIXME and related in single-line comments\n* `indents.scm` — indentation levels\n* `textobjects.scm` — syntax aware text-objects\n\n## 💲 CLI Usage\n\nTree-sitter grammars have limited utility on its own and are best used as parsers that can be embedded in other projects. However, [tree-sitter-cli](https://github.com/tree-sitter/tree-sitter/blob/master/cli/README.md) can be used with this grammar to show generated parse trees and syntax highlighting for a given Tact file.\n\nFor a quick demo of tree-sitter-cli usage:\n1. Clone this repo.\n2. Install Node.js dependencies (by `npm ci` (preferred, to re-use `package-lock.json`), `pnpm i`, `bun i` or `yarn`).\n3. Execute relevant commands from the `scripts` tag in `package.json`.\n\nFor a more streamlined experience, you may:\n1. [Install tree-sitter-cli](https://github.com/tree-sitter/tree-sitter/blob/master/cli/README.md#installation).\n2. Create a `tree-sitters` directory in your home directory.\n3. Clone this repository (or symlink it) into the new `~/tree-sitters/` directory.\n4. Run `tree-sitter parse path/to/file.tact` to be shown the parse tree for the file.\n5. Run `tree-sitter highlight path/to/file.tact` to be shown the file with syntax highlighting applied.\n\n## 🎨 Structure\n\nGrammar definition resides in `grammar.js`:\n\n- Actual grammar and bindings are generated from it via Tree-sitter.\n- Queries and tests rely on its namings of nodes and fields.\n\nGeneric queries are structured as follows:\n\n```\nqueries/\n|-- highlights.scm -- syntax highlighting queries (generic, for Tree-sitter \u0026 GitHub)\n|-- locals.scm -- fixed set of capture names to track local scopes and variables (and alike)\n`-- tags.scm -- tagging queries for code navigation systems (as used on GitHub)\n```\n\nTo find highlighting and other queries for specific editors, look in the `editor_queries/` directory. There, all the queries target development upstream branches of the relevant editors, unless the directory has a suffix `-release/`, in such case the queries provided there are targeting the latest releases.\n\n## Contributing\n\nThis section will be a separate file as per https://github.com/tact-lang/tree-sitter-tact/issues/35.\n\nFor now, I just wanted to leave a note to use ABI version 14: `npm run ts -- generate --abi=14`, or by setting `export TREE_SITTER_ABI_VERSION=14` prior to generation command. This is important for Helix, Neovim, and other editors and tools which still use lower versions.\n\n## ⚙ References\n\n- [grammar.gg](https://github.com/tact-lang/tact/blob/da4b8d82128cf4b6f9b04d93a93a9382407112c2/src/grammar/next/grammar.gg) — Official Tact grammar specification.\n- [grammar.ohm](https://github.com/tact-lang/tact/blob/da4b8d82128cf4b6f9b04d93a93a9382407112c2/src/grammar/prev/grammar.ohm) — Previous, now outdated Tact grammar specification in Ohm PEG language.\n- [tact-by-example](https://github.com/tact-lang/tact-by-example) — Many different contract samples.\n\n## Useful ⚡ Tact links\n\n- [Official Website](https://tact-lang.org/)\n- [Documentation](https://docs.tact-lang.org/)\n- Discussion Group in [Telegram](https://t.me/tactlang)\n- [X/Twitter](https://twitter.com/tact_language)\n\n## Credits\n\nBased on [The Open Network](https://ton.org).\n\nBuilt with 🤍 by [Novus Nota](https://github.com/novusnota).\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftact-lang%2Ftree-sitter-tact","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftact-lang%2Ftree-sitter-tact","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftact-lang%2Ftree-sitter-tact/lists"}