2024-01-06 15:05:50 +09:00
|
|
|
; Fish highlighting
|
|
|
|
|
; Operators
|
2021-05-01 23:24:34 +01:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"&&"
|
|
|
|
|
"||"
|
|
|
|
|
"|"
|
2024-04-03 19:30:34 +01:00
|
|
|
"&|"
|
|
|
|
|
"2>|"
|
2024-01-06 15:05:50 +09:00
|
|
|
"&"
|
|
|
|
|
".."
|
|
|
|
|
"!"
|
|
|
|
|
(direction)
|
|
|
|
|
(stream_redirect)
|
2021-05-01 23:24:34 +01:00
|
|
|
] @operator
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; match operators of test command
|
2022-11-24 01:23:08 +01:00
|
|
|
(command
|
2024-01-06 15:05:50 +09:00
|
|
|
name: (word) @function.builtin
|
|
|
|
|
(#eq? @function.builtin "test")
|
|
|
|
|
argument: (word) @operator
|
|
|
|
|
(#match? @operator "^(!?\\=|-[a-zA-Z]+)$"))
|
2022-11-24 01:23:08 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; match operators of [ command
|
2023-02-12 22:19:48 +00:00
|
|
|
(command
|
2024-01-06 15:05:50 +09:00
|
|
|
name: (word) @punctuation.bracket
|
|
|
|
|
(#eq? @punctuation.bracket "[")
|
|
|
|
|
argument: (word) @operator
|
|
|
|
|
(#match? @operator "^(!?\\=|-[a-zA-Z]+)$"))
|
2022-11-24 01:23:08 +01:00
|
|
|
|
2021-05-01 23:24:34 +01:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"not"
|
|
|
|
|
"and"
|
|
|
|
|
"or"
|
2021-05-01 23:24:34 +01:00
|
|
|
] @keyword.operator
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Conditionals
|
2021-05-01 23:24:34 +01:00
|
|
|
(if_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"if"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword.conditional)
|
2021-05-01 23:24:34 +01:00
|
|
|
|
|
|
|
|
(switch_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"switch"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword.conditional)
|
2021-05-01 23:24:34 +01:00
|
|
|
|
|
|
|
|
(case_clause
|
2024-01-06 15:05:50 +09:00
|
|
|
"case" @keyword.conditional)
|
2021-05-01 23:24:34 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(else_clause
|
|
|
|
|
"else" @keyword.conditional)
|
2021-05-01 23:24:34 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(else_if_clause
|
|
|
|
|
[
|
|
|
|
|
"else"
|
|
|
|
|
"if"
|
|
|
|
|
] @keyword.conditional)
|
2021-05-01 23:24:34 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Loops/Blocks
|
2021-05-01 23:24:34 +01:00
|
|
|
(while_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"while"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword.repeat)
|
2021-05-01 23:24:34 +01:00
|
|
|
|
|
|
|
|
(for_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"for"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword.repeat)
|
2021-05-01 23:24:34 +01:00
|
|
|
|
|
|
|
|
(begin_statement
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"begin"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword.repeat)
|
2021-05-01 23:24:34 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Keywords
|
2021-05-01 23:24:34 +01:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"in"
|
|
|
|
|
(break)
|
|
|
|
|
(continue)
|
2021-05-01 23:24:34 +01:00
|
|
|
] @keyword
|
|
|
|
|
|
2021-07-04 20:24:25 +03:00
|
|
|
"return" @keyword.return
|
2021-07-04 19:55:59 +03:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Punctuation
|
2021-05-01 23:24:34 +01:00
|
|
|
[
|
2024-01-06 15:05:50 +09:00
|
|
|
"["
|
|
|
|
|
"]"
|
|
|
|
|
"{"
|
|
|
|
|
"}"
|
|
|
|
|
"("
|
|
|
|
|
")"
|
2021-05-01 23:24:34 +01:00
|
|
|
] @punctuation.bracket
|
|
|
|
|
|
|
|
|
|
"," @punctuation.delimiter
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Commands
|
2021-05-01 23:24:34 +01:00
|
|
|
(command
|
2024-03-21 20:44:35 +09:00
|
|
|
argument: [
|
|
|
|
|
(word) @variable.parameter
|
|
|
|
|
(#lua-match? @variable.parameter "^[-]")
|
|
|
|
|
])
|
2021-05-01 23:24:34 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(command_substitution
|
|
|
|
|
"$" @punctuation.bracket)
|
2022-03-14 15:11:55 +00:00
|
|
|
|
2023-02-23 20:30:36 +01:00
|
|
|
; non-builtin command names
|
2024-01-06 15:05:50 +09:00
|
|
|
(command
|
|
|
|
|
name: (word) @function.call)
|
2021-05-01 23:24:34 +01:00
|
|
|
|
|
|
|
|
; derived from builtin -n (fish 3.2.2)
|
|
|
|
|
(command
|
2024-03-21 20:44:35 +09:00
|
|
|
name: [
|
|
|
|
|
(word) @function.builtin
|
|
|
|
|
(#any-of? @function.builtin
|
|
|
|
|
"." ":" "_" "alias" "argparse" "bg" "bind" "block" "breakpoint" "builtin" "cd" "command"
|
|
|
|
|
"commandline" "complete" "contains" "count" "disown" "echo" "emit" "eval" "exec" "exit" "fg"
|
|
|
|
|
"functions" "history" "isatty" "jobs" "math" "printf" "pwd" "random" "read" "realpath" "set"
|
|
|
|
|
"set_color" "source" "status" "string" "test" "time" "type" "ulimit" "wait")
|
|
|
|
|
])
|
2021-05-01 23:24:34 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Functions
|
2021-05-01 23:24:34 +01:00
|
|
|
(function_definition
|
2024-01-06 15:05:50 +09:00
|
|
|
[
|
|
|
|
|
"function"
|
|
|
|
|
"end"
|
|
|
|
|
] @keyword.function)
|
2021-05-01 23:24:34 +01:00
|
|
|
|
|
|
|
|
(function_definition
|
2024-03-21 20:44:35 +09:00
|
|
|
name: [
|
|
|
|
|
(word)
|
|
|
|
|
(concatenation)
|
|
|
|
|
] @function)
|
2021-05-01 23:24:34 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
(function_definition
|
2024-03-21 20:44:35 +09:00
|
|
|
option: [
|
|
|
|
|
(word)
|
|
|
|
|
(concatenation
|
|
|
|
|
(word))
|
|
|
|
|
] @variable.parameter
|
2024-01-06 15:05:50 +09:00
|
|
|
(#lua-match? @variable.parameter "^[-]"))
|
|
|
|
|
|
|
|
|
|
; Strings
|
|
|
|
|
[
|
|
|
|
|
(double_quote_string)
|
|
|
|
|
(single_quote_string)
|
|
|
|
|
] @string
|
2021-05-01 23:24:34 +01:00
|
|
|
|
|
|
|
|
(escape_sequence) @string.escape
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Variables
|
2021-05-01 23:24:34 +01:00
|
|
|
(variable_name) @variable
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2021-05-01 23:24:34 +01:00
|
|
|
(variable_expansion) @constant
|
|
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
; Nodes
|
|
|
|
|
[
|
|
|
|
|
(integer)
|
|
|
|
|
(float)
|
|
|
|
|
] @number
|
2021-05-01 23:24:34 +01:00
|
|
|
|
|
|
|
|
(comment) @comment
|
2024-01-06 15:05:50 +09:00
|
|
|
|
2022-09-11 11:22:29 +01:00
|
|
|
(comment) @spell
|
2021-05-01 23:24:34 +01:00
|
|
|
|
2021-06-06 19:55:38 +01:00
|
|
|
((word) @boolean
|
2024-01-06 15:05:50 +09:00
|
|
|
(#any-of? @boolean "true" "false"))
|
2021-05-01 23:24:34 +01:00
|
|
|
|
2024-01-06 15:05:50 +09:00
|
|
|
((program
|
|
|
|
|
.
|
2024-04-29 14:48:27 +02:00
|
|
|
(comment) @keyword.directive @nospell)
|
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
|
|
|
(#lua-match? @keyword.directive "^#!/"))
|