nvim-treesitter/queries/haskell/highlights.scm

623 lines
11 KiB
Scheme
Raw Normal View History

2024-01-06 15:05:50 +09:00
; ----------------------------------------------------------------------------
; Parameters and variables
; NOTE: These are at the top, so that they have low priority,
; and don't override destructured parameters
(variable) @variable
2024-01-06 15:05:50 +09:00
(pat_wildcard) @variable
(function
patterns: (patterns
(_) @variable.parameter))
2024-01-06 15:05:50 +09:00
(exp_lambda
(_)+ @variable.parameter
"->")
2024-01-06 15:05:50 +09:00
(function
infix: (infix
lhs: (_) @variable.parameter))
2024-01-06 15:05:50 +09:00
(function
infix: (infix
rhs: (_) @variable.parameter))
2024-01-06 15:05:50 +09:00
; ----------------------------------------------------------------------------
; Literals and comments
2021-04-21 16:05:06 +07:00
(integer) @number
2024-01-06 15:05:50 +09:00
(exp_negation) @number
2024-01-06 15:05:50 +09:00
(exp_literal
(float)) @number.float
2021-04-21 16:05:06 +07:00
(char) @character
2024-01-06 15:05:50 +09:00
2021-04-21 16:05:06 +07:00
(string) @string
2024-01-06 15:05:50 +09:00
(con_unit) @string.special.symbol ; unit, as in ()
2021-04-21 16:05:06 +07:00
(comment) @comment
; FIXME: The below documentation comment queries are inefficient
; and need to be anchored, using something like
; ((comment) @_first . (comment)+ @comment.documentation)
; once https://github.com/neovim/neovim/pull/24738 has been merged.
;
2024-01-06 15:05:50 +09:00
; ((comment) @comment.documentation
; (#lua-match? @comment.documentation "^-- |"))
;
2024-01-06 15:05:50 +09:00
; ((comment) @_first @comment.documentation
; (comment) @comment.documentation
; (#lua-match? @_first "^-- |"))
;
2024-01-06 15:05:50 +09:00
; ((comment) @comment.documentation
; (#lua-match? @comment.documentation "^-- %^"))
;
2024-01-06 15:05:50 +09:00
; ((comment) @_first @comment.documentation
; (comment) @comment.documentation
; (#lua-match? @_first "^-- %^"))
;
2024-01-06 15:05:50 +09:00
; ((comment) @comment.documentation
; (#lua-match? @comment.documentation "^{-"))
;
2024-01-06 15:05:50 +09:00
; ((comment) @_first @comment.documentation
; (comment) @comment.documentation
; (#lua-match? @_first "^{-"))
2024-01-06 15:05:50 +09:00
; ----------------------------------------------------------------------------
; Punctuation
[
"("
")"
"{"
"}"
"["
"]"
] @punctuation.bracket
[
(comma)
";"
] @punctuation.delimiter
2024-01-06 15:05:50 +09:00
; ----------------------------------------------------------------------------
; Keywords, operators, includes
2021-04-21 16:05:06 +07:00
[
"forall"
; "∀" ; utf-8 is not cross-platform safe
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
2021-04-21 16:05:06 +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
(pragma) @keyword.directive
2021-04-21 16:05:06 +07:00
[
"if"
"then"
"else"
"case"
"of"
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
2021-04-21 16:05:06 +07:00
[
"import"
"qualified"
"module"
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.import
2021-04-21 16:05:06 +07:00
[
(operator)
(constructor_operator)
(type_operator)
(tycon_arrow)
2024-01-06 15:05:50 +09:00
(qualified_module) ; grabs the `.` (dot), ex: import System.IO
(qualified_type)
(qualified_variable)
(all_names)
(wildcard)
"."
".."
"="
"|"
2021-04-21 16:05:06 +07:00
"::"
"=>"
"->"
"<-"
"\\"
"`"
"@"
2021-04-21 16:05:06 +07:00
] @operator
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
(module) @module
2024-01-06 15:05:50 +09:00
((qualified_module
(module) @constructor)
.
(module))
(qualified_type
(module) @module)
(qualified_variable
(module) @module)
(import
(module) @module)
(import
(module) @constructor
.
(module))
2021-04-21 16:05:06 +07:00
[
(where)
"let"
"in"
"class"
"instance"
"pattern"
2021-04-21 16:05:06 +07:00
"data"
"newtype"
"family"
"type"
"as"
"hiding"
2021-04-21 16:05:06 +07:00
"deriving"
"via"
"stock"
"anyclass"
"do"
"mdo"
"rec"
2022-01-08 11:12:08 +07:00
"infix"
"infixl"
"infixr"
2021-04-21 16:05:06 +07:00
] @keyword
2024-01-06 15:05:50 +09:00
; ----------------------------------------------------------------------------
; Functions and variables
(signature
name: (variable) @function)
2021-04-21 16:05:06 +07:00
2024-01-06 15:05:50 +09:00
(function
name: (variable) @function)
2024-01-06 15:05:50 +09:00
(function
name: (variable) @variable
rhs: [
(exp_literal)
(exp_apply
(exp_name
[
(constructor)
(variable)
(qualified_variable)
]))
(quasiquote)
((exp_name)
.
(operator))
])
(function
name: (variable) @variable
rhs: (exp_infix
2024-01-06 15:05:50 +09:00
[
(exp_literal)
(exp_apply
(exp_name
[
(constructor)
(variable)
(qualified_variable)
]))
(quasiquote)
((exp_name)
.
(operator))
]))
2024-01-06 15:05:50 +09:00
; Consider signatures (and accompanying functions)
; with only one value on the rhs as variables
(signature
.
(variable) @variable
.
(_) .)
((signature
.
(variable) @_name
.
(_) .)
.
(function
name: (variable) @variable)
(#eq? @_name @variable))
; but consider a type that involves 'IO' a function
(signature
name: (variable) @function
.
(type_apply
(type_name) @_type)
(#eq? @_type "IO"))
((signature
name: (variable) @_name
.
(type_apply
(type_name) @_type)
(#eq? @_type "IO"))
.
(function
name: (variable) @function)
(#eq? @_name @function))
; functions with parameters
; + accompanying signatures
2022-01-08 11:12:08 +07:00
(function
name: (variable) @function
patterns: (patterns))
2024-01-06 15:05:50 +09:00
((signature) @function
2024-01-06 15:05:50 +09:00
.
(function
name: (variable) @function
patterns: (patterns)))
2024-01-06 15:05:50 +09:00
(function
name: (variable) @function
rhs: (exp_lambda))
; view patterns
2024-01-06 15:05:50 +09:00
(pat_view
(exp_name
[
2024-01-21 22:05:44 +09:00
(variable) @function.call
2024-01-06 15:05:50 +09:00
(qualified_variable
(variable) @function.call)
]))
; consider infix functions as operators
2024-01-06 15:05:50 +09:00
(exp_infix
[
(variable) @operator
(qualified_variable
(variable) @operator)
])
; partially applied infix functions (sections) also get highlighted as operators
2024-01-06 15:05:50 +09:00
(exp_section_right
[
2024-01-21 22:05:44 +09:00
(variable) @operator
2024-01-06 15:05:50 +09:00
(qualified_variable
(variable) @operator)
])
(exp_section_left
[
2024-01-21 22:05:44 +09:00
(variable) @operator
2024-01-06 15:05:50 +09:00
(qualified_variable
(variable) @operator)
])
; function calls with an infix operator
; e.g. func <$> a <*> b
2024-01-06 15:05:50 +09:00
(exp_infix
(exp_name
[
2024-01-21 22:05:44 +09:00
(variable) @function.call
2024-01-06 15:05:50 +09:00
(qualified_variable
((module) @module
(variable) @function.call))
])
2024-01-06 15:05:50 +09:00
.
(operator))
; infix operators applied to variables
2024-01-06 15:05:50 +09:00
((exp_name
(variable) @variable)
.
(operator))
((operator)
.
(exp_name
[
2024-01-21 22:05:44 +09:00
(variable) @variable
2024-01-06 15:05:50 +09:00
(qualified_variable
(variable) @variable)
]))
; function calls with infix operators
2024-01-06 15:05:50 +09:00
((exp_name
[
2024-01-21 22:05:44 +09:00
(variable) @function.call
2024-01-06 15:05:50 +09:00
(qualified_variable
(variable) @function.call)
])
.
(operator) @_op
(#any-of? @_op "$" "<$>" ">>=" "=<<"))
; right hand side of infix operator
2024-01-06 15:05:50 +09:00
((exp_infix
[
(operator)
(variable)
] ; infix or `func`
.
(exp_name
[
2024-01-21 22:05:44 +09:00
(variable) @function.call
2024-01-06 15:05:50 +09:00
(qualified_variable
(variable) @function.call)
]))
.
(operator) @_op
(#any-of? @_op "$" "<$>" "=<<"))
; function composition, arrows, monadic composition (lhs)
2024-01-06 15:05:50 +09:00
((exp_name
[
2024-01-21 22:05:44 +09:00
(variable) @function
2024-01-06 15:05:50 +09:00
(qualified_variable
(variable) @function)
])
.
(operator) @_op
(#any-of? @_op "." ">>>" "***" ">=>" "<=<"))
; right hand side of infix operator
2024-01-06 15:05:50 +09:00
((exp_infix
[
(operator)
(variable)
] ; infix or `func`
.
(exp_name
[
2024-01-21 22:05:44 +09:00
(variable) @function
2024-01-06 15:05:50 +09:00
(qualified_variable
(variable) @function)
]))
.
(operator) @_op
(#any-of? @_op "." ">>>" "***" ">=>" "<=<"))
; function composition, arrows, monadic composition (rhs)
2024-01-06 15:05:50 +09:00
((operator) @_op
.
(exp_name
[
2024-01-21 22:05:44 +09:00
(variable) @function
2024-01-06 15:05:50 +09:00
(qualified_variable
(variable) @function)
])
(#any-of? @_op "." ">>>" "***" ">=>" "<=<"))
; function defined in terms of a function composition
2024-01-06 15:05:50 +09:00
(function
name: (variable) @function
rhs: (exp_infix
(_)
.
(operator) @_op
.
(_)
(#any-of? @_op "." ">>>" "***" ">=>" "<=<")))
2024-01-06 15:05:50 +09:00
(exp_apply
(exp_name
[
2024-01-21 22:05:44 +09:00
(variable) @function.call
2024-01-06 15:05:50 +09:00
(qualified_variable
(variable) @function.call)
]))
; function compositions, in parentheses, applied
; lhs
2024-01-06 15:05:50 +09:00
(exp_apply
.
(exp_parens
(exp_infix
(exp_name
[
2024-01-21 22:05:44 +09:00
(variable) @function.call
2024-01-06 15:05:50 +09:00
(qualified_variable
(variable) @function.call)
])
.
(operator))))
; rhs
2024-01-06 15:05:50 +09:00
(exp_apply
.
(exp_parens
(exp_infix
(operator)
.
(exp_name
[
2024-01-21 22:05:44 +09:00
(variable) @function.call
2024-01-06 15:05:50 +09:00
(qualified_variable
(variable) @function.call)
]))))
; variables being passed to a function call
(exp_apply
(_)+
.
(exp_name
[
2024-01-21 22:05:44 +09:00
(variable) @variable
2024-01-06 15:05:50 +09:00
(qualified_variable
(variable) @variable)
]))
2024-01-06 15:05:50 +09:00
; Consider functions with only one value on the rhs
; as variables, e.g. x = Rec {} or x = foo
(function
.
(variable) @variable
.
[
(exp_record)
(exp_name
[
(variable)
(qualified_variable)
])
(exp_list)
(exp_tuple)
(exp_cond)
] .)
; main is always a function
; (this prevents `main = undefined` from being highlighted as a variable)
(function
name: (variable) @function
(#eq? @function "main"))
2024-01-06 15:05:50 +09:00
; scoped function types (func :: a -> b)
(pat_typed
pattern: (pat_name
(variable) @function)
2024-01-06 15:05:50 +09:00
type: (fun))
2024-01-06 15:05:50 +09:00
; signatures that have a function type
; + functions that follow them
2024-01-21 22:05:44 +09:00
(signature
2024-01-06 15:05:50 +09:00
(variable) @function
2024-01-21 22:05:44 +09:00
(fun))
2024-01-06 15:05:50 +09:00
((signature
(variable) @_type
(fun))
.
(function
(variable) @function)
(#eq? @function @_type))
2024-01-21 22:05:44 +09:00
(signature
2024-01-06 15:05:50 +09:00
(variable) @function
(context
2024-01-21 22:05:44 +09:00
(fun)))
2024-01-06 15:05:50 +09:00
((signature
(variable) @_type
(context
(fun)))
.
(function
(variable) @function)
(#eq? @function @_type))
((signature
(variable) @function
(forall
(context
(fun))))
.
(function
(variable)))
((signature
(variable) @_type
(forall
(context
(fun))))
.
(function
(variable) @function)
(#eq? @function @_type))
; ----------------------------------------------------------------------------
; Types
(type) @type
2024-01-06 15:05:50 +09:00
(type_star) @type
2024-01-06 15:05:50 +09:00
2022-01-08 11:12:08 +07:00
(type_variable) @type
(constructor) @constructor
; True or False
2024-01-06 15:05:50 +09:00
((constructor) @boolean
(#any-of? @boolean "True" "False"))
; otherwise (= True)
((variable) @boolean
(#eq? @boolean "otherwise"))
2024-01-06 15:05:50 +09:00
; ----------------------------------------------------------------------------
; Quasi-quotes
(quoter) @function.call
2024-01-06 15:05:50 +09:00
(quasiquote
[
2024-01-06 15:05:50 +09:00
(quoter) @_name
(_
(variable) @_name)
]
(#eq? @_name "qq")
(quasiquote_body) @string)
2024-01-06 15:05:50 +09:00
(quasiquote
2024-01-21 22:05:44 +09:00
(_
(variable) @_name)
2024-01-06 15:05:50 +09:00
(#eq? @_name "qq")
(quasiquote_body) @string)
2024-01-06 15:05:50 +09:00
; namespaced quasi-quoter
(quasiquote
(_
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
(module) @module
2024-01-06 15:05:50 +09:00
.
(variable) @function.call))
; Highlighting of quasiquote_body for other languages is handled by injections.scm
2024-01-06 15:05:50 +09:00
; ----------------------------------------------------------------------------
; Exceptions/error handling
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
((variable) @keyword.exception
(#any-of? @keyword.exception
"error" "undefined" "try" "tryJust" "tryAny" "catch" "catches" "catchJust" "handle" "handleJust"
"throw" "throwIO" "throwTo" "throwError" "ioError" "mask" "mask_" "uninterruptibleMask"
"uninterruptibleMask_" "bracket" "bracket_" "bracketOnErrorSource" "finally" "fail"
"onException" "expectationFailure"))
2024-01-06 15:05:50 +09:00
; ----------------------------------------------------------------------------
; Debugging
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
((variable) @keyword.debug
(#any-of? @keyword.debug
"trace" "traceId" "traceShow" "traceShowId" "traceWith" "traceShowWith" "traceStack" "traceIO"
"traceM" "traceShowM" "traceEvent" "traceEventWith" "traceEventIO" "flushEventLog" "traceMarker"
"traceMarkerIO"))
2024-01-06 15:05:50 +09:00
; ----------------------------------------------------------------------------
; Fields
(field
(variable) @variable.member)
(pat_field
(variable) @variable.member)
(exp_projection
field: (variable) @variable.member)
(import_item
(type)
.
(import_con_names
(variable) @variable.member))
(exp_field
field: [
(variable) @variable.member
(qualified_variable
(variable) @variable.member)
])
2022-09-07 11:33:02 +02:00
2024-01-06 15:05:50 +09:00
; ----------------------------------------------------------------------------
; Spell checking
2022-09-07 11:33:02 +02:00
(comment) @spell