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

329 lines
4 KiB
Scheme
Raw Normal View History

; Modules
;--------
2024-01-06 15:05:50 +09:00
[
(module_name)
(module_type_name)
] @module
; Types
;------
2024-01-06 15:05:50 +09:00
((type_constructor) @type.builtin
(#any-of? @type.builtin
"int" "char" "bytes" "string" "float" "bool" "unit" "exn" "array" "list" "option" "int32"
"int64" "nativeint" "format6" "lazy_t"))
2024-01-06 15:05:50 +09:00
[
(class_name)
(class_type_name)
(type_constructor)
] @type
2024-01-06 15:05:50 +09:00
[
(constructor_name)
(tag)
] @constructor
; Variables
;----------
2024-01-06 15:05:50 +09:00
[
(value_name)
(type_variable)
] @variable
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
((value_pattern) @character.special
(#eq? @character.special "_"))
; 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-08-16 22:37:02 +02:00
(let_binding
2020-09-18 17:36:47 +01:00
pattern: (value_name) @function
body: [
(fun_expression)
(function_expression)
])
2024-01-06 15:05:50 +09:00
(value_specification
(value_name) @function)
2024-01-06 15:05:50 +09:00
(external
(value_name) @function)
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
; Application
;------------
(infix_expression
left: (value_path
(value_name) @function.call)
operator: (concat_operator) @_operator
(#eq? @_operator "@@"))
(infix_expression
operator: (rel_operator) @_operator
right: (value_path
(value_name) @function.call)
(#eq? @_operator "|>"))
(application_expression
function: (value_path
(value_name) @function.call))
2023-04-21 04:06:20 -04:00
((value_name) @function.builtin
(#any-of? @function.builtin "raise" "raise_notrace" "failwith" "invalid_arg"))
; Fields
;-------
2024-01-06 15:05:50 +09:00
[
(field_name)
(instance_variable_name)
] @variable.member
; Labels
; ------
(label_name) @label
; Constants
;----------
; Don't let normal parens take priority over this
2024-01-06 15:05:50 +09:00
((unit) @constant.builtin
(#set! priority 105))
(boolean) @boolean
2024-01-06 15:05:50 +09:00
[
(number)
(signed_number)
] @number
2020-08-16 22:37:02 +02:00
(character) @character
(string) @string
2024-01-06 15:05:50 +09:00
(quoted_string
"{" @string
"}" @string) @string
2020-08-16 22:37:02 +02:00
(escape_sequence) @string.escape
2020-08-16 22:37:02 +02:00
[
(conversion_specification)
(pretty_printing_indication)
] @string.special
; 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"
] @keyword
2024-04-23 12:23:15 -07:00
[
"object"
"class"
"struct"
"type"
] @keyword.type
[
2024-01-06 15:05:50 +09:00
"lazy"
"mutable"
"nonrec"
"rec"
"private"
"virtual"
] @keyword.modifier
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
2024-01-06 15:05:50 +09:00
[
"exception"
"try"
] @keyword.exception
2024-01-06 15:05:50 +09:00
[
"include"
"open"
] @keyword.import
2024-01-06 15:05:50 +09:00
[
"for"
"to"
"downto"
"while"
"do"
"done"
] @keyword.repeat
2020-09-15 13:40:57 +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)
"%" @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-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
(range_pattern
".." @character.special)
; Operators
;----------
[
(prefix_operator)
(sign_operator)
(pow_operator)
(mult_operator)
(add_operator)
(concat_operator)
(rel_operator)
(and_operator)
(or_operator)
(assign_operator)
(hash_operator)
(indexing_operator)
(let_operator)
(match_operator)
] @operator
2024-01-06 15:05:50 +09:00
(match_expression
(match_operator) @keyword)
2024-01-06 15:05:50 +09:00
(value_definition
[
(let_operator)
(let_and_operator)
] @keyword)
2024-01-06 15:05:50 +09:00
[
"*"
"#"
"::"
"<-"
] @operator
; Attributes
;-----------
(attribute_id) @attribute
; 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