summaryrefslogtreecommitdiff
path: root/runtime/queries/elvish/highlights.scm
blob: fd70488dfb3da6899407b8e2c722e6951ce813d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
;; SPDX-License-Identifier: 0BSD
;; SPDX-FileCopyrightText: 2022 Tobias Frilling

(comment) @comment

(if "if" @keyword.control.conditional)
(if (elif "elif" @keyword.control.conditional))
(if (else "else" @keyword.control.conditional))

(while "while" @keyword.control.repeat)
(while (else "else" @keyword.control.repeat))
(for "for" @keyword.control.repeat)
(for (else "else" @keyword.control.repeat))

(try "try" @keyword.control.exception)
(try (catch "catch" @keyword.control.exception))
(try (else "else" @keyword.control.exception))
(try (finally "finally" @keyword.control.exception))

(import "use" @keyword.control.import)
(import (bareword) @string.special)

(wildcard ["*" "**" "?"] @string.special)

(command argument: (bareword) @variable.parameter)
(command head: (identifier) @function)
((command head: (identifier) @keyword.control.return)
 (#eq? @keyword.control.return "return"))
((command (identifier) @keyword.operator)
 (#match? @keyword.operator "(and|or|coalesce)"))
((command head: _ @function)
 (#match? @function "([+]|[-]|[*]|[/]|[%]|[<]|[<][=]|[=][=]|[!][=]|[>]|[>][=]|[<][s]|[<][=][s]|[=][=][s]|[!][=][s]|[>][s]|[>][=][s])"))

(pipeline "|" @operator)
(redirection [">" "<" ">>" "<>"] @operator)

(io_port) @constant.numeric

(function_definition
  "fn" @keyword.function
  (identifier) @function)

(parameter_list) @variable.parameter
(parameter_list "|" @punctuation.bracket)

(variable_declaration
  "var" @keyword
  (lhs (identifier) @variable))

(variable_assignment
  "set" @keyword
  (lhs (identifier) @variable))

(temporary_assignment
  "tmp" @keyword
  (lhs (identifier) @variable))

(variable_deletion
  "del" @keyword
  (identifier) @variable)


(number) @constant.numeric
(string) @string

((variable (identifier) @function)
  (#match? @function ".+\\~$"))
((variable (identifier) @constant.builtin.boolean)
 (#match? @constant.builtin.boolean "(true|false)"))
((variable (identifier) @constant.builtin)
 (#match? @constant.builtin "(_|after-chdir|args|before-chdir|buildinfo|nil|notify-bg-job-success|num-bg-jobs|ok|paths|pid|pwd|value-out-indicator|version)"))
(variable (identifier) @variable)

["$" "@"] @punctuation.special
["(" ")" "[" "]" "{" "}"] @punctuation.bracket
";" @punctuation.delimiter