VSCode TextMate
An interpreter for grammar files as defined by TextMate. Supports loading grammar files from JSON or PLIST format. Cross - grammar injections are currently not supported.
Installing
npm install vscode-textmate
Using
var Registry = Registry;var registry = ;var grammar = registry; var lineTokens = grammar;for var i = 0; i < lineTokenstokenslength; i++ var token = lineTokenstokensi; console;
Using asynchronously
Sometimes, it is necessary to manage the list of known grammars outside of vscode-textmate
. The sample below shows how this works:
var Registry = Registry; var registry = { // Return here the path to the grammar file for `scopeName` if scopeName === 'source.js' return './javascript.tmbundle/Syntaxes/JavaScript.plist'; return null; }; // Load the JavaScript grammar and any other grammars included by it async.registry;
Tokenizing multiple lines
To tokenize multiple lines, you must pass in the previous returned ruleStack
.
var ruleStack = null;for var i = 0; i < lineslength; i++ var r = grammar; console; ruleStack = rruleStack;
API doc
See the main.ts file
Developing
- Clone the repository
- Run
npm install
- Compile in the background with
npm run watch
- Run tests with
npm test
- Run benchmark with
npm run benchmark
- Troubleshoot a grammar with
npm run inspect -- PATH_TO_GRAMMAR PATH_TO_FILE
Code of Conduct
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.