nvim-treesitter/runtime/queries/tlaplus/highlights.scm

381 lines
5 KiB
Scheme
Raw Normal View History

2021-08-18 12:48:01 -04:00
; Keywords
[
"ACTION"
"ASSUME"
"ASSUMPTION"
"AXIOM"
"BY"
"CASE"
"CHOOSE"
"CONSTANT"
"CONSTANTS"
"COROLLARY"
"DEF"
"DEFINE"
"DEFS"
"ELSE"
"EXCEPT"
"EXTENDS"
"HAVE"
"HIDE"
"IF"
"IN"
"INSTANCE"
"LAMBDA"
"LEMMA"
"LET"
"LOCAL"
"MODULE"
"NEW"
"OBVIOUS"
"OMITTED"
"ONLY"
"OTHER"
"PICK"
"PROOF"
"PROPOSITION"
"PROVE"
"QED"
"RECURSIVE"
"SF_"
"STATE"
"SUFFICES"
"TAKE"
"TEMPORAL"
"THEN"
"THEOREM"
"USE"
"VARIABLE"
"VARIABLES"
"WF_"
"WITH"
"WITNESS"
(address)
(all_map_to)
(assign)
(case_arrow)
(case_box)
(def_eq)
2021-08-18 12:48:01 -04:00
(exists)
(forall)
2021-08-18 12:48:01 -04:00
(gets)
(label_as)
(maps_to)
(set_in)
(temporal_exists)
(temporal_forall)
2021-08-29 21:33:46 -07:00
] @keyword
2022-07-13 13:43:50 -04:00
; Pluscal keywords
[
(pcal_algorithm_start)
"algorithm"
"assert"
"begin"
"call"
"define"
"end"
"fair"
"goto"
"macro"
"or"
"procedure"
"process"
(pcal_skip)
"variable"
"variables"
"when"
"with"
] @keyword
2024-01-06 15:05:50 +09:00
"await" @keyword.coroutine
(pcal_with
2024-01-21 22:05:44 +09:00
"=" @keyword)
2024-01-06 15:05:50 +09:00
(pcal_process
2024-01-21 22:05:44 +09:00
"=" @keyword)
2024-01-06 15:05:50 +09:00
[
2024-01-06 15:05:50 +09:00
"if"
"then"
"else"
"elsif"
(pcal_end_if)
"either"
(pcal_end_either)
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
] @keyword.conditional
2024-01-06 15:05:50 +09:00
[
"while"
"do"
(pcal_end_while)
"with"
(pcal_end_with)
feat!: align standard captures with upstream Problem: Sharing highlight queries with upstream tree-sitter and Helix is difficult. Solution: Where reasonable, use capture names in tree-sitter's standard list or Helix's Atom-style hierarchy. Specifically: * tree-sitter "standard capture names" (https://github.com/tree-sitter/tree-sitter/blob/3f44b896852eb7daaa6df4fb778c9bb52c70c815/highlight/src/lib.rs#L20-L72): - `@parameter` -> `@variable.parameter` - `@field` -> `@variable.member` - `@namespace` -> `@module` - `@float` -> `@number.float` - `@symbol` -> `@string.special.symbol` - `@string.regex` -> `@string.regexp` - `@text.*` -> `@markup.*` (`strong`, `italic`, `link`, `strikethrough`; with exceptions; see below) - `@text.title` -> `@markup.heading` - `@text.literal` -> `@markup.raw` - `@text.reference` -> `@markup.link` - `@text.uri` -> `@markup.link.url` (in markup links) - `@string.special` -> `@markup.link.label` (non-url links) - `@punctuation.special` -> `@markup.list` (markdown lists only; move subitems from `@text.todo`) * Helix captures (https://docs.helix-editor.com/master/themes.html#syntax-highlighting): - `@method` -> `@function.method` - `@method.call` -> `@function.method.call` - `@text.{todo,warning,note,danger}` -> `@comment.{error,warning,hint,info,todo}` - `@text.diff.{add,delete,}` -> `@diff.{plus,minus,delta}` - `@text.uri` -> `@string.special.url` (outside markup) - `@preproc` -> `@keyword.directive` - `@define` -> `@keyword.directive`(`.define`?) - `@storageclass` -> `@keyword.storage` - `@conditional` -> `@keyword.conditional` - `@debug` -> `@keyword.debug` - `@exception` -> `@keyword.exception` - `@include` -> `@keyword.import` - `@repeat` -> `@keyword.repeat` * cleanup - remove some redundant `@conceal` (but still allow it for conceal-only patterns) - remove obsolete `@error` (syntax linting is out of scope for this repo) - sort, cleanup capture list in `CONTRIBUTING.md`
2023-12-24 10:00:20 +01:00
] @keyword.repeat
2024-01-06 15:05:50 +09:00
(pcal_return) @keyword.return
2024-01-21 22:05:44 +09:00
"print" @function.macro
2021-08-18 12:48:01 -04:00
; Literals
2024-01-06 15:05:50 +09:00
(binary_number
(format) @keyword)
(binary_number
(value) @number)
2021-08-18 12:48:01 -04:00
(boolean) @boolean
2024-01-06 15:05:50 +09:00
(boolean_set) @type
2024-01-06 15:05:50 +09:00
(hex_number
(format) @keyword)
(hex_number
(value) @number)
(int_number_set) @type
2024-01-06 15:05:50 +09:00
(nat_number) @number
2024-01-06 15:05:50 +09:00
(nat_number_set) @type
2024-01-06 15:05:50 +09:00
(octal_number
(format) @keyword)
(octal_number
(value) @number)
(real_number) @number
2024-01-06 15:05:50 +09:00
(real_number_set) @type
2024-01-06 15:05:50 +09:00
(string) @string
2024-01-06 15:05:50 +09:00
(escape_char) @string.escape
2024-01-06 15:05:50 +09:00
(string_set) @type
2021-08-18 12:48:01 -04:00
2022-07-13 13:43:50 -04:00
; Namespaces
2024-01-06 15:05:50 +09:00
(extends
(identifier_ref) @module)
(instance
(identifier_ref) @module)
(module
name: (identifier) @module)
(pcal_algorithm
name: (identifier) @module)
2021-08-18 12:48:01 -04:00
2022-07-13 13:43:50 -04:00
; Operators, functions, and macros
2024-01-06 15:05:50 +09:00
(bound_infix_op
symbol: (_) @operator)
(bound_nonfix_op
symbol: (_) @operator)
(bound_postfix_op
symbol: (_) @operator)
(bound_prefix_op
symbol: (_) @operator)
2024-01-21 22:05:44 +09:00
(prefix_op_symbol) @operator
2024-01-06 15:05:50 +09:00
2024-01-21 22:05:44 +09:00
(infix_op_symbol) @operator
2024-01-06 15:05:50 +09:00
2024-01-21 22:05:44 +09:00
(postfix_op_symbol) @operator
2024-01-06 15:05:50 +09:00
(function_definition
name: (identifier) @function)
(module_definition
name: (_) @keyword.import)
(operator_definition
name: (_) @function.macro)
(pcal_macro_decl
name: (identifier) @function.macro)
(pcal_macro_call
name: (identifier) @function.macro)
(pcal_proc_decl
name: (identifier) @function.macro)
(pcal_process
name: (identifier) @function)
(recursive_declaration
(identifier) @function.macro)
(recursive_declaration
(operator_declaration
name: (_) @function.macro))
; Constants and variables
2024-01-06 15:05:50 +09:00
(constant_declaration
(identifier) @constant)
(constant_declaration
(operator_declaration
name: (_) @constant))
(pcal_var_decl
(identifier) @variable)
(pcal_with
(identifier) @variable.parameter)
2024-01-21 22:05:44 +09:00
("."
2024-01-06 15:05:50 +09:00
.
(identifier) @attribute)
(record_literal
(identifier) @attribute)
(set_of_records
(identifier) @attribute)
(variable_declaration
(identifier) @variable)
; Parameters
2024-01-06 15:05:50 +09:00
(choose
(identifier) @variable.parameter)
(choose
(tuple_of_identifiers
(identifier) @variable.parameter))
(lambda
(identifier) @variable.parameter)
(module_definition
(operator_declaration
name: (_) @variable.parameter))
(module_definition
parameter: (identifier) @variable.parameter)
(operator_definition
(operator_declaration
name: (_) @variable.parameter))
(operator_definition
parameter: (identifier) @variable.parameter)
(pcal_macro_decl
parameter: (identifier) @variable.parameter)
(pcal_proc_var_decl
(identifier) @variable.parameter)
(quantifier_bound
(identifier) @variable.parameter)
(quantifier_bound
(tuple_of_identifiers
(identifier) @variable.parameter))
(unbounded_quantification
(identifier) @variable.parameter)
; Delimiters
2021-08-29 20:26:37 -07:00
[
(langle_bracket)
(rangle_bracket)
(rangle_bracket_sub)
"{"
"}"
"["
"]"
"]_"
"("
")"
] @punctuation.bracket
2024-01-06 15:05:50 +09:00
2021-08-29 20:26:37 -07:00
[
","
":"
"."
2021-08-29 20:26:37 -07:00
"!"
";"
(bullet_conj)
(bullet_disj)
(prev_func_val)
(placeholder)
2021-08-29 20:26:37 -07:00
] @punctuation.delimiter
2021-08-18 12:48:01 -04:00
; Proofs
2024-01-06 15:05:50 +09:00
(assume_prove
(new
(identifier) @variable.parameter))
(assume_prove
(new
(operator_declaration
name: (_) @variable.parameter)))
(assumption
name: (identifier) @constant)
(pick_proof_step
(identifier) @variable.parameter)
(proof_step_id
"<" @punctuation.bracket)
(proof_step_id
(level) @label)
(proof_step_id
(name) @label)
(proof_step_id
">" @punctuation.bracket)
(proof_step_ref
"<" @punctuation.bracket)
(proof_step_ref
(level) @label)
(proof_step_ref
(name) @label)
(proof_step_ref
">" @punctuation.bracket)
(take_proof_step
(identifier) @variable.parameter)
(theorem
name: (identifier) @constant)
; Comments and tags
2024-01-06 15:05:50 +09:00
(block_comment
"(*" @comment)
(block_comment
"*)" @comment)
2023-09-13 00:25:01 +09:00
(block_comment_text) @comment @spell
2024-01-06 15:05:50 +09:00
2023-09-13 00:25:01 +09:00
(comment) @comment @spell
2024-01-06 15:05:50 +09:00
(single_line) @comment
2024-01-06 15:05:50 +09:00
(_
label: (identifier) @label)
(label
name: (_) @label)
(pcal_goto
statement: (identifier) @label)