Skip to content

wldmr/tree-sitter-ink

Repository files navigation

Tree-Sitter-Ink

This is a Tree-sitter grammar for the Ink interactive fiction scripting language. It supports all syntax up to version 1.2.0.

showcase.webm

Caution

It's still early days. Things are likely to behave in strange, unintuitive ways. Or be plain buggy. Please get in touch (by filing an issue, or by starting a discussion) so we can iron out the kinks.

Editor Support

See the queries/editors directory. If your editor is supported, the corresponding subfolder should contain everything you need.

Note

If you'd like to see your editor supported, feel free to open a PR.

  • Vim

  • Neovim

  • Emacs

  • Helix

    Put languages.toml and the *.scm files in your Helix user config (e.g. ~/.config/helix/).

    For details see the Helix guides.

  • VSCode

  • [… your editor here …]

Why?

Inkle themselves provide syntax files for Sublime 3, but tree-sitter is more powerful. Notably, this grammar allows distinguishing between an expression in conditional text, and similar-looking normal text in alternatives:

// Conditional text:
{blofeld and old: I saw that old git,|Dunno,} I said.
/*       ^^^ `and` is an operator, therefore
 |-------------| <- all this is an expression
|-------------------------------------------| <- and this is conditional text */

// Alternative text:
{blofeld is old: and that's a fact,|I already told you about his age,} I said.
/*       ^^ `is` is *not* an operator, therefore
 |--------------------------------| <- all this is just text
|--------------------------------------------------------------------| <- and this is a _sequence_ (a type of alternative text) */

In addition, tree-sitter allows for not just highlighting, but also source code navigation, indenting, etc. With this, advanced editor support is possible for multiple editors.