2020-09-11 10:21:39 +01:00
|
|
|
; Modules
|
|
|
|
|
;--------
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
(module_name)
|
|
|
|
|
(module_type_name)
|
|
|
|
|
] @module
|
2020-09-11 10:21:39 +01:00
|
|
|
|
|
|
|
|
; Types
|
|
|
|
|
;------
|
2024-01-06 15:05:50 +09:00
|
|
|
((type_constructor) @type.builtin
|
2024-02-23 17:42:01 +09:00
|
|
|
(#any-of? @type.builtin
|
|
|
|
|
"int" "char" "bytes" "string" "float" "bool" "unit" "exn" "array" "list" "option" "int32"
|
|
|
|
|
"int64" "nativeint" "format6" "lazy_t"))
|
2020-09-11 10:21:39 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
(class_name)
|
|
|
|
|
(class_type_name)
|
|
|
|
|
(type_constructor)
|
|
|
|
|
] @type
|
2020-09-11 10:21:39 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
(constructor_name)
|
|
|
|
|
(tag)
|
|
|
|
|
] @constructor
|
2020-09-11 10:21:39 +01:00
|
|
|
|
2022-10-24 22:30:35 -07:00
|
|
|
; Variables
|
|
|
|
|
;----------
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
(value_name)
|
|
|
|
|
(type_variable)
|
|
|
|
|
] @variable
|
2022-10-24 22:30:35 -07:00
|
|
|
|
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
|
|
|
(value_pattern) @variable.parameter
|
2022-10-24 22:30:35 -07:00
|
|
|
|
2024-09-19 23:15:01 -07:00
|
|
|
((value_pattern) @character.special
|
|
|
|
|
(#eq? @character.special "_"))
|
|
|
|
|
|
2020-09-11 10:21:39 +01:00
|
|
|
; Functions
|
|
|
|
|
;----------
|
2020-08-16 22:37:02 +02:00
|
|
|
(let_binding
|
2020-09-18 17:36:47 +01:00
|
|
|
pattern: (value_name) @function
|
2020-08-16 22:37:02 +02:00
|
|
|
(parameter))
|
2020-09-11 10:21:39 +01:00
|
|
|
|
2020-08-16 22:37:02 +02:00
|
|
|
(let_binding
|
2020-09-18 17:36:47 +01:00
|
|
|
pattern: (value_name) @function
|
2024-03-21 20:44:35 +09:00
|
|
|
body: [
|
|
|
|
|
(fun_expression)
|
|
|
|
|
(function_expression)
|
|
|
|
|
])
|
2020-09-11 10:21:39 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(value_specification
|
|
|
|
|
(value_name) @function)
|
2020-09-11 10:21:39 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(external
|
|
|
|
|
(value_name) @function)
|
2020-09-11 10:21:39 +01:00
|
|
|
|
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
|
|
|
(method_name) @function.method
|
2020-09-11 10:21:39 +01:00
|
|
|
|
|
|
|
|
; Application
|
|
|
|
|
;------------
|
|
|
|
|
(infix_expression
|
2024-03-21 20:44:35 +09:00
|
|
|
left: (value_path
|
|
|
|
|
(value_name) @function.call)
|
2023-06-01 03:28:00 +02:00
|
|
|
operator: (concat_operator) @_operator
|
|
|
|
|
(#eq? @_operator "@@"))
|
2020-09-11 10:21:39 +01:00
|
|
|
|
|
|
|
|
(infix_expression
|
2023-06-01 03:28:00 +02:00
|
|
|
operator: (rel_operator) @_operator
|
2024-03-21 20:44:35 +09:00
|
|
|
right: (value_path
|
|
|
|
|
(value_name) @function.call)
|
2023-06-01 03:28:00 +02:00
|
|
|
(#eq? @_operator "|>"))
|
2020-09-11 10:21:39 +01:00
|
|
|
|
|
|
|
|
(application_expression
|
2024-03-21 20:44:35 +09:00
|
|
|
function: (value_path
|
|
|
|
|
(value_name) @function.call))
|
2020-09-11 10:21:39 +01:00
|
|
|
|
2023-04-21 04:06:20 -04:00
|
|
|
((value_name) @function.builtin
|
|
|
|
|
(#any-of? @function.builtin "raise" "raise_notrace" "failwith" "invalid_arg"))
|
2020-09-11 10:21:39 +01:00
|
|
|
|
2024-01-10 18:05:37 +02:00
|
|
|
; Fields
|
|
|
|
|
;-------
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
(field_name)
|
|
|
|
|
(instance_variable_name)
|
2024-01-10 18:05:37 +02:00
|
|
|
] @variable.member
|
|
|
|
|
|
|
|
|
|
; Labels
|
|
|
|
|
; ------
|
|
|
|
|
(label_name) @label
|
2020-09-11 10:21:39 +01:00
|
|
|
|
|
|
|
|
; Constants
|
|
|
|
|
;----------
|
2022-04-29 14:14:56 +01:00
|
|
|
; Don't let normal parens take priority over this
|
2024-01-06 15:05:50 +09:00
|
|
|
((unit) @constant.builtin
|
2024-07-27 16:28:19 -07:00
|
|
|
(#set! priority 105))
|
2021-12-01 10:26:42 +01:00
|
|
|
|
|
|
|
|
(boolean) @boolean
|
2020-09-11 10:21:39 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
(number)
|
|
|
|
|
(signed_number)
|
|
|
|
|
] @number
|
2020-08-16 22:37:02 +02:00
|
|
|
|
2020-10-03 14:17:53 +01:00
|
|
|
(character) @character
|
|
|
|
|
|
|
|
|
|
(string) @string
|
2020-09-11 10:21:39 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(quoted_string
|
|
|
|
|
"{" @string
|
|
|
|
|
"}" @string) @string
|
2020-08-16 22:37:02 +02:00
|
|
|
|
2020-09-11 10:47:30 +01:00
|
|
|
(escape_sequence) @string.escape
|
2020-08-16 22:37:02 +02:00
|
|
|
|
2021-02-27 19:25:03 +00:00
|
|
|
[
|
|
|
|
|
(conversion_specification)
|
|
|
|
|
(pretty_printing_indication)
|
2021-12-02 16:28:00 +01:00
|
|
|
] @string.special
|
2020-09-11 10:21:39 +01:00
|
|
|
|
|
|
|
|
; Keywords
|
|
|
|
|
;---------
|
|
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"and"
|
|
|
|
|
"as"
|
|
|
|
|
"assert"
|
|
|
|
|
"begin"
|
|
|
|
|
"constraint"
|
|
|
|
|
"end"
|
|
|
|
|
"external"
|
|
|
|
|
"in"
|
|
|
|
|
"inherit"
|
|
|
|
|
"initializer"
|
|
|
|
|
"let"
|
|
|
|
|
"match"
|
|
|
|
|
"method"
|
|
|
|
|
"module"
|
|
|
|
|
"new"
|
|
|
|
|
"of"
|
|
|
|
|
"sig"
|
|
|
|
|
"val"
|
|
|
|
|
"when"
|
|
|
|
|
"with"
|
2020-09-11 10:21:39 +01:00
|
|
|
] @keyword
|
|
|
|
|
|
2024-04-23 12:23:15 -07:00
|
|
|
[
|
|
|
|
|
"object"
|
|
|
|
|
"class"
|
|
|
|
|
"struct"
|
|
|
|
|
"type"
|
|
|
|
|
] @keyword.type
|
|
|
|
|
|
2022-11-15 18:56:25 +02:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"lazy"
|
|
|
|
|
"mutable"
|
|
|
|
|
"nonrec"
|
|
|
|
|
"rec"
|
|
|
|
|
"private"
|
|
|
|
|
"virtual"
|
2024-03-08 19:09:51 +09:00
|
|
|
] @keyword.modifier
|
2022-11-15 18:56:25 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"fun"
|
|
|
|
|
"function"
|
|
|
|
|
"functor"
|
|
|
|
|
] @keyword.function
|
2021-07-05 15:04:42 -05:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"if"
|
|
|
|
|
"then"
|
|
|
|
|
"else"
|
|
|
|
|
] @keyword.conditional
|
2020-09-11 10:47:30 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"exception"
|
|
|
|
|
"try"
|
|
|
|
|
] @keyword.exception
|
2020-09-11 10:47:30 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"include"
|
|
|
|
|
"open"
|
|
|
|
|
] @keyword.import
|
2020-09-11 10:47:30 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"for"
|
|
|
|
|
"to"
|
|
|
|
|
"downto"
|
|
|
|
|
"while"
|
|
|
|
|
"do"
|
|
|
|
|
"done"
|
|
|
|
|
] @keyword.repeat
|
2020-09-15 13:40:57 +01:00
|
|
|
|
2020-09-11 10:21:39 +01:00
|
|
|
; Punctuation
|
|
|
|
|
;------------
|
2024-01-06 15:05:50 +09:00
|
|
|
(attribute
|
|
|
|
|
[
|
|
|
|
|
"[@"
|
|
|
|
|
"]"
|
|
|
|
|
] @punctuation.special)
|
|
|
|
|
|
|
|
|
|
(item_attribute
|
|
|
|
|
[
|
|
|
|
|
"[@@"
|
|
|
|
|
"]"
|
|
|
|
|
] @punctuation.special)
|
|
|
|
|
|
|
|
|
|
(floating_attribute
|
|
|
|
|
[
|
|
|
|
|
"[@@@"
|
|
|
|
|
"]"
|
|
|
|
|
] @punctuation.special)
|
|
|
|
|
|
|
|
|
|
(extension
|
|
|
|
|
[
|
|
|
|
|
"[%"
|
|
|
|
|
"]"
|
|
|
|
|
] @punctuation.special)
|
|
|
|
|
|
|
|
|
|
(item_extension
|
|
|
|
|
[
|
|
|
|
|
"[%%"
|
|
|
|
|
"]"
|
|
|
|
|
] @punctuation.special)
|
|
|
|
|
|
|
|
|
|
(quoted_extension
|
|
|
|
|
[
|
|
|
|
|
"{%"
|
|
|
|
|
"}"
|
|
|
|
|
] @punctuation.special)
|
|
|
|
|
|
|
|
|
|
(quoted_item_extension
|
|
|
|
|
[
|
|
|
|
|
"{%%"
|
|
|
|
|
"}"
|
|
|
|
|
] @punctuation.special)
|
2020-09-11 10:21:39 +01:00
|
|
|
|
|
|
|
|
"%" @punctuation.special
|
2020-08-16 22:37:02 +02:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"("
|
|
|
|
|
")"
|
|
|
|
|
"["
|
|
|
|
|
"]"
|
|
|
|
|
"{"
|
|
|
|
|
"}"
|
|
|
|
|
"[|"
|
|
|
|
|
"|]"
|
|
|
|
|
"[<"
|
|
|
|
|
"[>"
|
|
|
|
|
] @punctuation.bracket
|
|
|
|
|
|
|
|
|
|
(object_type
|
|
|
|
|
[
|
|
|
|
|
"<"
|
|
|
|
|
">"
|
|
|
|
|
] @punctuation.bracket)
|
2020-09-11 10:21:39 +01:00
|
|
|
|
2020-08-16 22:37:02 +02:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
","
|
|
|
|
|
"."
|
|
|
|
|
";"
|
|
|
|
|
":"
|
|
|
|
|
"="
|
|
|
|
|
"|"
|
|
|
|
|
"~"
|
|
|
|
|
"?"
|
|
|
|
|
"+"
|
|
|
|
|
"-"
|
|
|
|
|
"!"
|
|
|
|
|
">"
|
|
|
|
|
"&"
|
|
|
|
|
"->"
|
|
|
|
|
";;"
|
|
|
|
|
":>"
|
|
|
|
|
"+="
|
|
|
|
|
":="
|
|
|
|
|
".."
|
2020-08-16 22:37:02 +02:00
|
|
|
] @punctuation.delimiter
|
|
|
|
|
|
2024-09-19 23:15:01 -07:00
|
|
|
(range_pattern
|
|
|
|
|
".." @character.special)
|
|
|
|
|
|
2021-02-27 20:11:32 +00:00
|
|
|
; Operators
|
|
|
|
|
;----------
|
|
|
|
|
[
|
|
|
|
|
(prefix_operator)
|
2021-05-08 16:53:15 +01:00
|
|
|
(sign_operator)
|
2023-06-01 03:28:00 +02:00
|
|
|
(pow_operator)
|
|
|
|
|
(mult_operator)
|
|
|
|
|
(add_operator)
|
|
|
|
|
(concat_operator)
|
|
|
|
|
(rel_operator)
|
|
|
|
|
(and_operator)
|
|
|
|
|
(or_operator)
|
|
|
|
|
(assign_operator)
|
2021-05-08 16:53:15 +01:00
|
|
|
(hash_operator)
|
2021-02-27 20:11:32 +00:00
|
|
|
(indexing_operator)
|
|
|
|
|
(let_operator)
|
|
|
|
|
(match_operator)
|
|
|
|
|
] @operator
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(match_expression
|
|
|
|
|
(match_operator) @keyword)
|
2021-02-27 20:11:32 +00:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(value_definition
|
|
|
|
|
[
|
|
|
|
|
(let_operator)
|
|
|
|
|
(let_and_operator)
|
|
|
|
|
] @keyword)
|
2021-02-27 20:11:32 +00:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"*"
|
|
|
|
|
"#"
|
|
|
|
|
"::"
|
|
|
|
|
"<-"
|
|
|
|
|
] @operator
|
2021-02-27 20:11:32 +00:00
|
|
|
|
2020-09-11 10:21:39 +01:00
|
|
|
; Attributes
|
|
|
|
|
;-----------
|
2024-01-10 18:05:37 +02:00
|
|
|
(attribute_id) @attribute
|
2020-09-11 10:21:39 +01:00
|
|
|
|
|
|
|
|
; Comments
|
|
|
|
|
;---------
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
(comment)
|
|
|
|
|
(line_number_directive)
|
|
|
|
|
(directive)
|
|
|
|
|
] @comment @spell
|
2024-01-09 11:50:31 +02:00
|
|
|
|
|
|
|
|
(shebang) @keyword.directive
|