2

I'm building an extension providing a syntax highlighting for the 'Jack' language used in an online course I am taking (Nand2Tetris at Coursera - it is not a part of the course assignment). I have the syntax highlighting rules ready, but I would like to add custom formatting for some language elements. In particular, I would like type definitions to appear in italic.

I know how to change the user settings to get the desired result on my VS Code installation, but I would like that formatting to be the default behavior for anyone using the extension.

I've tried to create a new theme extension and then copy paste the 'themes' folder from it to the 'syntax' extension and reference the file from that folder in package.json, but it didn't work. I also tried adding the 'configuration' setting in the 'contributes' section of package.json, without success. I browsed numerous VC Code extensions on GitHub and couldn't find one providing similar functionality.

Is it even possible to provide syntax definition and 'theming' in one extension? If so how?

Amade
  • 3,665
  • 2
  • 26
  • 54

1 Answers1

0

Based on VS Code Semantic Highlight Guide, besides syntax highlighting rules, you'll also need

  1. Implement and register a Semantic token provider in your extension.
  2. Declare Enablement of semantic highlighting in settings.json.
  3. Customize tokens in Theming.

VS Code team kindly provides a Semantic tokens sample. Note that this example skips step 3 and customizes tokens directly in settings.json.

Wenhan Kong
  • 71
  • 1
  • 3