This is my first VS Code extension from the ground up! It's my sandbox, not really meant for public consumption :)
It follows the guide at Visual Studio Code - Your First Extension.
I'll try to leave extensive comments for reference to those writing their first VS Code extension :) feel free to open an issue if you have any questions about first time extension development!
Test-driven development is a major priority of this project. All code will be thoroughly tested before being committed.
All tests run using the standard npm run test
, documented in package.json
.
Unit tests focus on miscellaneous functionality of the app. They're written following the official Testing Extensions guide.
Grammar tests focus on the tokenization via the TextMate grammar detailed in Syntax Highlight Guide
Another main goal is to create a project that's very easy to maintain.
- Make use of automation whenever possible
- Automated checks at PR time
- Pre-commit hooks for formatting and linting
Pre-commit hooks are setup using husky
and lint-staged
. When a commit is attempted, lint-staged
validates the staged files for correctness (compilation errors, lint problems, and formatting). If anything is wrong, the commit will fail.
To test that pre-commit hooks have been set up correctly, introduce compilation, lint, or formatting issues to a file. Save the file without fixing these issues. Then stage it and try to commit. The relevant check should fail, the commit should be aborted, and the filesystem should not be changed.
Syntax highlighting support follows VS Code's syntax highlighting guide.
This extension...
- declares that it
contributes
languages
andgrammars
inpackage.json
- defines grammar in YAML for readability (see Using YAML to write a grammar)
- converts YAML grammar to JSON using
npm run compile_grammar
VS Code...
- tries to parse relevant files with the grammar using microsoft/vscode-textmate
I want to improve AutoHotkey Plus Plus. Right now, I'm focusing on syntax- and semantic-highlighting.
The Semantic Token Provider mentioned in the Tokenization section of the Syntax Highlight Guide looks like a promising way to provide detailed tokens as well.
Resources:
- Syntax Highlight Guide
- microsoft/vscode-textmate is the library that tokenizes code via TextMate grammars
- PanAeon/vscode-tmgrammar-test is recommended by Microsoft to write unit tests for TextMate grammars
See the /docs
folder for additional documentation.