-
Notifications
You must be signed in to change notification settings - Fork 0
4.0 | Syntax highlight
While syntax highlight is not part of the Language Server Protocol, the grammar files are in this repository, so that all extensions can use them from here. The syntax highlight consists of 2 TextMate grammar files: dshl.tmLanguage.json, and hlsl.tmLanguage.json in the grammar folder.
The different rules basically contain 2 things: a regular expression (usually called match), and a name for it. So basically you find certain parts of the source code, and based on conventions, name them. The grammar doesn't define colors or any type of format, it just names different parts of the code. Assigning colors to these names is the responsibility of color themes (and the language server doesn't include one). The comment field doesn't do anything, it's just a short description of the rule. The captures blocks are used for naming individual capture groups, instead of the whole match. With the match property TextMate works in a line-by-line fashion, so you won't match anything if the parts are in different lines (even if you include newline characters in the regular expression). To be able to catch for example multiline comments, you can use begin and end instead of match. Keep in mind, that the order of the rules matters, because the first match will decide the name.
If you want to know which TextMate rule matched at the cursor, press F1, and select Developer: Inspect Editor Tokens and Scopes. If you need more information about what are the steps of TextMate matching, press F1, and select Developer: Start Text Mate Syntax Grammar Logging. By pressing F1, and selecting Preferences: Color Theme, you can try the grammar with different color themes.
- VS Code documentation: Syntax Highlight Guide
- Visual Studio documentation: Add Visual Studio editor support for other languages
- A guide to writing a language grammar (TextMate) in Atom
- TextMate for macOS: Language Grammars
- Writing a TextMate Grammar: Some Lessons Learned
- Regular Expressions Info
- Regexper (regular expression visualization)