Brings syntax highlighting for inkle's Ink, in your editor of choice (as long as it supports TextMate grammars).
If you're just looking for the plist-based grammar, head over to the releases!
- Building the grammar
- Limitations
- Building a custom theme
- Availability through NPM
- Contributing
- License
The grammar is written using the YAML-tmLanguage
format, with a couple of
additions borrowed from TypeScript-TmLanguage.
Building the grammar is easy, you need the latest version of node.js and your favourite npm-compatible package manager.
- clone this repository;
- run
npm install
oryarn install
; - run
npm run build
oryarn run build
; - the
Ink.tmLanguage
file should be available ingrammars/
.
There are currently a number of limitations in the grammar.
In Ink, { }
can hold a lot of different things. In particular, the construct can either be an alternative or a conditional substitution. Due to current limitations, expressions will not be properly highlighted in conditionals, as they lead to false-positives for operators, in the first elements of alternatives.
In these constructs, all the items contained in the first expression (x == 0:
) will be named with the same scope.
{ x == 0: Hello }
{ x == 0: Hello | hi }
{ x == 0:
Hello
- else:
Hi
}
This is not the case in the following example, where all items will be named with their own scopes.
{
- x == 0:
Hello
}
~ y = (x == 0)
~ myFunction(x == 0)
Similarly, the following construct will not be highlighted correctly, as there is an ambiguity between an empty alternative item and the logical or operator (they are both written: ||
).
{ window_opts < 2 || learnt(fingerprints_on_glass) || GlassState ? steamed:
I looked away from the dreary glass.
}
In choice constructs, Ink offer the ability to separate the content in up to three sequences using [ ]
. While there can only be one [ ]
per choice, the grammar will still highlight subsequent [ ]
, even if they are treated as regular text by Ink.
* (myChoice) {x == 0}
"Hello John Doe[."], I need to tell you something [special]"
In the example above, only [."]
should be highlighted.
All the captures support the generic scopes recommended by the Sublime Text documentation, narrowed down to .ink
. This means that the grammar will work out of box with existing themes.
Most of the captures are multi-scoped, with the first scope defined by the theme being used. Some of these multi-scoped captures support ink-specific scopes, which can be implemented by your custom theme. They are described below:
string.label.ink
→(label)
string.tag.ink
→#tag
keyword.glue.ink
→<>
keyword.choice.ink
→*
keyword.choice.sticky.ink
→+
keyword.choice.suppression.ink
→[ ]
keyword.logic.ink
→~
keyword.gather.ink
→-
keyword.divert.ink
→->
or<-
keyword.alternative.type.ink
→&
or~
or!
inside{ }
storage.knot.ink
→ Identifier after / between=
As a convenience, the grammar is also available through the npm registry. If you're building an extension for Atom or VS Code, you may want to depend on this package.
Once installed, the grammar can be found in node_modules/ink-tmlanguage/grammars/Ink.tmLanguage
.
If the grammar is missing something, open an issue or fix it and submit a pull request!
When working on the grammar, you may want to use npm run watch
, which will rebuild the plist grammar on every change.
The grammar is released under the MIT license. See LICENSE for details.
This project borrows some code from TypeScript-TmLanguage, licensed under the MIT license.