2024-01-06 15:05:50 +09:00
|
|
|
; A highlight query can override the highlights queries before it.
|
|
|
|
|
; So the order is important.
|
|
|
|
|
; We should highlight general rules, then highlight special forms.
|
2022-04-07 22:34:50 +08:00
|
|
|
(number) @number
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2022-04-07 22:34:50 +08:00
|
|
|
(character) @character
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2022-04-07 22:34:50 +08:00
|
|
|
(boolean) @boolean
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2023-08-07 15:20:09 +02:00
|
|
|
(string) @string
|
2022-04-07 22:34:50 +08:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
(comment)
|
|
|
|
|
(block_comment)
|
|
|
|
|
] @comment @spell
|
2022-04-07 22:34:50 +08:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; highlight for datum comment
|
|
|
|
|
; copied from ../clojure/highlights.scm
|
|
|
|
|
([
|
|
|
|
|
(comment)
|
|
|
|
|
(directive)
|
|
|
|
|
] @comment
|
2024-07-27 16:28:19 -07:00
|
|
|
(#set! priority 105))
|
2022-04-07 22:34:50 +08:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(escape_sequence) @string.escape
|
2022-04-07 22:34:50 +08:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"("
|
|
|
|
|
")"
|
|
|
|
|
"["
|
|
|
|
|
"]"
|
|
|
|
|
"{"
|
|
|
|
|
"}"
|
|
|
|
|
] @punctuation.bracket
|
2022-04-07 22:34:50 +08:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; variables
|
2022-04-07 22:34:50 +08:00
|
|
|
(symbol) @variable
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
((symbol) @variable.builtin
|
|
|
|
|
(#any-of? @variable.builtin "..." "."))
|
2022-04-07 22:34:50 +08:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; procedure
|
2022-04-07 22:34:50 +08:00
|
|
|
(list
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
(symbol) @function)
|
2022-04-07 22:34:50 +08:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; special forms
|
2022-04-07 22:34:50 +08:00
|
|
|
(list
|
2024-01-06 15:05:50 +09:00
|
|
|
"["
|
|
|
|
|
(symbol)+ @variable
|
|
|
|
|
"]")
|
2022-04-07 22:34:50 +08:00
|
|
|
|
|
|
|
|
(list
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
(symbol) @_f
|
|
|
|
|
.
|
|
|
|
|
(list
|
|
|
|
|
(symbol) @variable)
|
|
|
|
|
(#any-of? @_f "lambda" "λ"))
|
2022-04-07 22:34:50 +08:00
|
|
|
|
|
|
|
|
(list
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
(symbol) @_f
|
|
|
|
|
.
|
|
|
|
|
(list
|
|
|
|
|
(list
|
|
|
|
|
(symbol) @variable))
|
2024-02-23 17:42:01 +09:00
|
|
|
(#any-of? @_f
|
|
|
|
|
"let" "let*" "let-syntax" "let-values" "let*-values" "letrec" "letrec*" "letrec-syntax"))
|
2024-01-06 15:05:50 +09:00
|
|
|
|
|
|
|
|
; operators
|
2022-04-07 22:34:50 +08:00
|
|
|
((symbol) @operator
|
2024-01-06 15:05:50 +09:00
|
|
|
(#any-of? @operator "+" "-" "*" "/" "=" "<=" ">=" "<" ">"))
|
2022-04-07 22:34:50 +08:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; keyword
|
2022-04-07 22:34:50 +08:00
|
|
|
((symbol) @keyword
|
2024-02-23 17:42:01 +09:00
|
|
|
(#any-of? @keyword
|
|
|
|
|
"define" "lambda" "λ" "begin" "do" "define-syntax" "and" "or" "if" "cond" "case" "when"
|
|
|
|
|
"unless" "else" "=>" "let" "let*" "let-syntax" "let-values" "let*-values" "letrec" "letrec*"
|
|
|
|
|
"letrec-syntax" "set!" "syntax-rules" "identifier-syntax" "quote" "unquote" "quote-splicing"
|
|
|
|
|
"quasiquote" "unquote-splicing" "delay" "assert" "library" "export" "import" "rename" "only"
|
|
|
|
|
"except" "prefix"))
|
2022-04-07 22:34:50 +08: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
|
|
|
((symbol) @keyword.conditional
|
2024-01-06 15:05:50 +09:00
|
|
|
(#any-of? @keyword.conditional "if" "cond" "case" "when" "unless"))
|
2022-04-07 22:34:50 +08:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; quote
|
2022-11-06 11:26:54 +01:00
|
|
|
(quote
|
2024-01-06 15:05:50 +09:00
|
|
|
"'"
|
|
|
|
|
(symbol)) @string.special.symbol
|
2022-04-07 22:34:50 +08:00
|
|
|
|
|
|
|
|
(list
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
(symbol) @_f
|
|
|
|
|
(#eq? @_f "quote")) @string.special.symbol
|
2022-04-07 22:34:50 +08:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; library
|
2022-04-07 22:34:50 +08:00
|
|
|
(list
|
2024-01-06 15:05:50 +09:00
|
|
|
.
|
|
|
|
|
(symbol) @_lib
|
|
|
|
|
.
|
|
|
|
|
(symbol) @module
|
|
|
|
|
(#eq? @_lib "library"))
|
|
|
|
|
|
|
|
|
|
; builtin procedures
|
|
|
|
|
; procedures in R5RS and R6RS but not in R6RS-lib
|
2022-04-07 22:34:50 +08:00
|
|
|
((symbol) @function.builtin
|
2024-01-05 03:19:54 +09:00
|
|
|
(#any-of? @function.builtin
|
|
|
|
|
; eq
|
|
|
|
|
"eqv?" "eq?" "equal?"
|
|
|
|
|
; number
|
2024-02-23 17:42:01 +09:00
|
|
|
"number?" "complex?" "real?" "rational?" "integer?" "exact?" "inexact?" "zero?" "positive?"
|
|
|
|
|
"negative?" "odd?" "even?" "finite?" "infinite?" "nan?" "max" "min" "abs" "quotient" "remainder"
|
|
|
|
|
"modulo" "div" "div0" "mod" "mod0" "div-and-mod" "div0-and-mod0" "gcd" "lcm" "numerator"
|
|
|
|
|
"denominator" "floor" "ceiling" "truncate" "round" "rationalize" "exp" "log" "sin" "cos" "tan"
|
|
|
|
|
"asin" "acos" "atan" "sqrt" "expt" "exact-integer-sqrt" "make-rectangular" "make-polar"
|
|
|
|
|
"real-part" "imag-part" "magnitude" "angle" "real-valued" "rational-valued?" "integer-valued?"
|
|
|
|
|
"exact" "inexact" "exact->inexact" "inexact->exact" "number->string" "string->number"
|
2024-01-05 03:19:54 +09:00
|
|
|
; boolean
|
|
|
|
|
"boolean?" "not" "boolean=?"
|
|
|
|
|
; pair
|
2024-02-23 17:42:01 +09:00
|
|
|
"pair?" "cons" "car" "cdr" "caar" "cadr" "cdar" "cddr" "caaar" "caadr" "cadar" "caddr" "cdaar"
|
|
|
|
|
"cdadr" "cddar" "cdddr" "caaaar" "caaadr" "caadar" "caaddr" "cadaar" "cadadr" "caddar" "cadddr"
|
|
|
|
|
"cdaaar" "cdaadr" "cdadar" "cdaddr" "cddaar" "cddadr" "cdddar" "cddddr" "set-car!" "set-cdr!"
|
2024-01-05 03:19:54 +09:00
|
|
|
; list
|
2024-02-23 17:42:01 +09:00
|
|
|
"null?" "list?" "list" "length" "append" "reverse" "list-tail" "list-ref" "map" "for-each"
|
2024-01-05 03:19:54 +09:00
|
|
|
"memq" "memv" "member" "assq" "assv" "assoc"
|
|
|
|
|
; symbol
|
|
|
|
|
"symbol?" "symbol->string" "string->symbol" "symbol=?"
|
|
|
|
|
; char
|
2024-02-23 17:42:01 +09:00
|
|
|
"char?" "char=?" "char<?" "char>?" "char<=?" "char>=?" "char-ci=?" "char-ci<?" "char-ci>?"
|
|
|
|
|
"char-ci<=?" "char-ci>=?" "char-alphabetic?" "char-numeric?" "char-whitespace?"
|
|
|
|
|
"char-upper-case?" "char-lower-case?" "char->integer" "integer->char" "char-upcase"
|
|
|
|
|
"char-downcase"
|
2024-01-05 03:19:54 +09:00
|
|
|
; string
|
2024-02-23 17:42:01 +09:00
|
|
|
"string?" "make-string" "string" "string-length" "string-ref" "string-set!" "string=?"
|
|
|
|
|
"string-ci=?" "string<?" "string>?" "string<=?" "string>=?" "string-ci<?" "string-ci>?"
|
|
|
|
|
"string-ci<=?" "string-ci>=?" "substring" "string-append" "string->list" "list->string"
|
|
|
|
|
"string-for-each" "string-copy" "string-fill!" "string-upcase" "string-downcase"
|
2024-01-05 03:19:54 +09:00
|
|
|
; vector
|
2024-02-23 17:42:01 +09:00
|
|
|
"vector?" "make-vector" "vector" "vector-length" "vector-ref" "vector-set!" "vector->list"
|
|
|
|
|
"list->vector" "vector-fill!" "vector-map" "vector-for-each"
|
2024-01-05 03:19:54 +09:00
|
|
|
; bytevector
|
2024-02-23 17:42:01 +09:00
|
|
|
"bytevector?" "native-endianness" "make-bytevector" "bytevector-length" "bytevector=?"
|
|
|
|
|
"bytevector-fill!" "bytevector-copy!" "bytevector-copy"
|
2024-01-05 03:19:54 +09:00
|
|
|
; error
|
|
|
|
|
"error" "assertion-violation"
|
|
|
|
|
; control
|
2024-02-23 17:42:01 +09:00
|
|
|
"procedure?" "apply" "force" "call-with-current-continuation" "call/cc" "values"
|
|
|
|
|
"call-with-values" "dynamic-wind" "eval" "scheme-report-environment" "null-environment"
|
|
|
|
|
"interaction-environment"
|
2024-01-05 03:19:54 +09:00
|
|
|
; IO
|
2024-02-23 17:42:01 +09:00
|
|
|
"call-with-input-file" "call-with-output-file" "input-port?" "output-port?" "current-input-port"
|
|
|
|
|
"current-output-port" "with-input-from-file" "with-output-to-file" "open-input-file"
|
|
|
|
|
"open-output-file" "close-input-port" "close-output-port"
|
2024-01-05 03:19:54 +09:00
|
|
|
; input
|
|
|
|
|
"read" "read-char" "peek-char" "eof-object?" "char-ready?"
|
|
|
|
|
; output
|
|
|
|
|
"write" "display" "newline" "write-char"
|
|
|
|
|
; system
|
|
|
|
|
"load" "transcript-on" "transcript-off"))
|