Masterbelt

masterbelt/masterbelt

Syntax Highlighting

Synced from main@9490864MarkdownSource

#Syntax Highlighting

This document describes the currently implemented Masterbelt syntax highlighting captures.

Highlighting covers every keyword and the language's declarations, bindings, match patterns, type expressions, operators, literals, and comments. Future captures must extend this document before or together with query changes.

#Captures

Keywords:

  • visibility_modifier is captured as @keyword.
  • The const keyword is captured as @keyword.
  • The type keyword is captured as @keyword.
  • The use keyword is captured as @keyword.
  • The from keyword is captured as @keyword.
  • The as keyword is captured as @keyword.
  • field_modifier (readonly, writable, primary) is captured as @keyword.modifier.
  • effect_modifier (asyncable, failable, cancellable) is captured as @keyword.modifier.
  • The fn keyword is captured as @keyword.
  • The enum keyword is captured as @keyword.
  • The return keyword is captured as @keyword.
  • The master, record, and source keywords are captured as @keyword.
  • The filter, include, and exclude keywords are captured as @keyword.
  • The validation, each, all, validate, and assert keywords are captured as @keyword.
  • The static and select keywords are captured as @keyword.
  • The scope context keyword is captured as @keyword; the indexed context keyword is captured as @keyword.modifier.
  • The if, else, match, for, in, let, and fail keywords are captured as @keyword, as are the break and continue statements.

Definitions and identifiers:

  • Const item names are captured as @constant.
  • Type declaration names are captured as @type.definition.
  • Type parameter names on a generic type declaration are captured as @type.parameter.
  • Product type field names are captured as @property.
  • Product literal field names are captured as @property.
  • The type prefix of a typed product literal is captured as @type.
  • Function type parameter names are captured as @variable.parameter.
  • Enum declaration names are captured as @type.definition.
  • Enum variant names are captured as @constant.
  • In a member access expression Target.Member, the target identifier is captured as @type and the member identifier is captured as @constant.
  • Top-level function declaration names are captured as @function.
  • Method names declared inside a product type are captured as @function.method.
  • Master declaration names are captured as @type.definition.
  • The validate rule name of a master validation rule is captured as @function.
  • The scope name of a master scope declaration is captured as @function.
  • The projection name of a master select section is captured as @type.definition.
  • The source-kind identifier of a master source entry is captured as @type.
  • Master source option names are captured as @property.
  • Local const binding names are captured as @constant; let binding names, assignment targets, and for loop binding names are captured as @variable.

Match patterns:

  • An enum pattern Target.Variant captures the target identifier as @type and the variant identifier as @constant.
  • A product pattern's type identifier is captured as @type, its field names as @property, and its as binding as @variable.
  • A type pattern's as binding is captured as @variable.
  • The wildcard pattern _ is captured as @variable.builtin.

Operators:

  • A unary or binary expression's operator token is captured as @operator. The capture uses the expression's operator field, so the < > of a generic type application and the | of a union type — which are the same tokens in type position — are not coloured as operators.
  • The => arrow token and the variadic * prefix are captured as @operator.

Type expressions:

  • named_type is captured as @type.
  • reserved_type_identifier is captured as @type.builtin.
  • The constructor identifier of generic_type is captured as @type.

Literals and comments:

  • null_literal is captured as @constant.builtin.
  • bool_literal is captured as @boolean.
  • integer_literal is captured as @number.
  • string_literal is captured as @string.
  • line_comment is captured as @comment.
  • block_comment is captured as @comment.
  • doc_comment is captured as @comment.documentation.
Specification