tASTe: The AST Editor
Editing code often involves dealing with low-level textual representations, which can be tedious and error-prone.
tASTe is a vscode extension to edit code based on its structure, allowing you to interact more directly with the elements that make up your language.
For example, when your cursor is inside a for loop, you can invoke a command to select the whole loop at once.
Or, if you have a list of elements, tASTe gives you a command to jump from one element to the next, or expand the current selection from one element to te next. This works equally well with strings in a list as it does with other syntactic elements of many languages; you can for instance jump between code blocks (to jump from one function to the next for example), or select markdown paragraphs one after the other.
The theme of this plugin is to do away with some of the tediousness of editing code by raising the level of abstraction, so as to end up a little closer to manipulating the concepts inherent to your programming language instead of characters. Hopefully resulting in less errors and more fun :)
Commands
Expand and Contract Selection
taste.ExpandSelectiontaste.ContractSelection
Grow and Shrink Selection
taste.SelectForwardtaste.SelectBackward
Move Cursor
taste.MoveCursorBackwardtaste.MoveCursorForward
Select Top Level
taste.selectTopLevel
Raise
taste.Raise
Swap
taste.SwapForwardtaste.SwapBackward
Slurp / Barf
taste.SlurpForwardtaste.BarfForward
Install instructions
- Install from here
- Add the keyboard shortcuts you are interested in to your editor config from the Command Palette (⇧⌘P) with the "Preferences: Open Keyboard Shortcuts (JSON) command." (docs)
Here's some suggested ones:
{
"key": "cmd+e",
"command": "taste.ExpandSelection"
},
{
"key": "cmd+shift+e",
"command": "taste.ContractSelection"
},
{
"key": "shift+cmd+left",
"command": "taste.SelectBackward"
},
{
"key": "shift+cmd+right",
"command": "taste.SelectForward"
},
{
"key": "cmd+right",
"command": "taste.MoveCursorForward"
},
{
"key": "cmd+left",
"command": "taste.MoveCursorBackward"
}Supported languages
- Bash
- C
- C Sharp
- Common Lisp
- C++
- Cap'n Proto
- CSV
- CSS
- Dart
- Dockerfile
- DOT
- Elixir
- Erlang
- Fish
- Go
- Graphql
- Hack
- Haskell
- HCL (Terraform)
- HTML
- Java
- Javascript
- JSON
- Julia
- Kotlin
- Lua
- Markdown
- Matlab
- Nix
- Objective C
- PHP
- Python
- QML
- R
- Racket
- Rust
- Ruby
- Scala
- Scheme
- SCSS
- Scheme
- SQL
- Swift
- Toml
- TSV
- Typescript
- XML
- YAML
- Zig
Troubleshooting
Unrecognized language
If you get the message "The language ... is not yet supported by tASTe" but the language of my file listed as supported in this readme, it could be that vscode cannot auto-detect the language in question. You can verify this by checking that the language is shown correctly in the bottom-right corner of vscode.
In case it's not shown correctly, you might need to install an extension that enables support for your language.
If the language is already recognized correctly and you still get the "language not supported" error, the problem is probably that the languageId assigned by vscode to your language does not coincide with the one used by tree-sitter. Please open an issue!
Credits
Credit for this idea goes to the long lineage of lisp structured editors, with a special shoutout to Emac's paredit and vscode's Calva. A special thank you also to the developers of Tree-sitter and its many parsers, without which this wouldn't be possible.
Dev HOWTOs
Bringup development environment
- Make sure you have installed the following:
- emscripten compiler
- nodejs
- docker (optional)
- gnu parallel (optional)
npm installnpm build-parsersnpm run build-watch- In the "Run and Debug" menu of vscode, Start debugging the "Run Extension" target
Publish
npm run check- Bump version number in
package.json - Write changelog
git commit -m 'Bump'npm run tag-n-pushnpm run cleannpm run build-parsersnpm run publish
Get Personal access token
This only applies if you are the extension publisher (simonacca).
Rebuild parsers
npm build-parsers
Configure a new language
- Check open and closed issues first tagged with
language-support, that's where unsuccessful attempts at adding languages are documented. - Install the parser
npm i tree-sitter-mylanguage - Add a line to the
build_wasm.shscript to generate the grammar - List the language in
languageID2ParserName - Add an entry to
excludeNodeTypescorresponding to the language
A language is installed and built but not recognized
Add an entry in src/languages.ts -> languageIDTranslation mapping the vscode languageID to the wasm name (see build-parsers.sh -> build_parser <node_module_name> <wasm_name>).






