Skip to content

What do you think about Visual Studio Marketplace? We are looking for feedback from developers like you! Take the survey

| Marketplace
Sign in
Visual Studio Code>Other>HelloWorld 2022New to Visual Studio Code? Get it now.

HelloWorld 2022

Mark Wiemer

|
7 installs
| (0) | Free
Because helloworld was taken??
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Hello, world!

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!

Tests

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

Engineering quality

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

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

Syntax Highlighting support follows the official Syntax Highlight Guide.

This extension...

  1. declares that it contributes languages and grammars in package.json
  2. defines grammar in YAML for readability (see Using YAML to write a grammar)
  3. converts YAML grammar to JSON using npm run compile_grammar

VS Code...

  1. tries to parse relevant files with the grammar using microsoft/vscode-textmate

Next steps

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
  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2023 Microsoft