Skip to content
TextMate grammar files for Ink. (VS Code, Sublime Text, and Atom)
TypeScript
Branch: master
Clone or download
Latest commit f570689 Jun 7, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
build First public release Aug 1, 2018
grammars Improve highlighting when choices are present in gathers Jun 7, 2019
.editorconfig First public release Aug 1, 2018
.gitignore Remove .tmLanguage from gitignore Mar 21, 2019
.travis.yml First public release Aug 1, 2018
LICENSE First public release Aug 1, 2018
README.md
package-lock.json Update depepdencies Jun 7, 2019
package.json Update depepdencies Jun 7, 2019

README.md

Ink TMLanguage

Build Status npm version Licence Dependencies

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!

Table of contents

Building the grammar

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.

  1. clone this repository;
  2. run npm install or yarn install;
  3. run npm run build or yarn run build;
  4. the Ink.tmLanguage file should be available in grammars/.

Limitations

There are currently a number of limitations in the grammar.

Ambiguity of { } constructs

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.
}

Text suppression

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.

Building a custom theme

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 =

Availability through npm

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.

Contributing

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.

License

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.

You can’t perform that action at this time.