Giter VIP home page Giter VIP logo

ink-tmlanguage's Introduction

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.

ink-tmlanguage's People

Contributors

ephread avatar

Watchers

James Cloos avatar Alex Schmid avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.