on master help sign in
feat(lang): Update Nix grammar & improve queries (#2472)
eba8225Timothy DeHerrera
languages.toml+1−1
@@ -439,7 +439,7 @@ indent = { tab-width = 2, unit = " " }
439
439
440[[grammar]]
440[[grammar]]
441name = "nix"
441name = "nix"
442−source = { git = "https://github.com/cstrahan/tree-sitter-nix", rev = "50f38ceab667f9d482640edfee803d74f4edeba5" }
442+source = { git = "https://github.com/cstrahan/tree-sitter-nix", rev = "6b71a810c0acd49b980c50fc79092561f7cee307" }
443
443
444[[language]]
444[[language]]
445name = "ruby"
445name = "ruby"
runtime/queries/nix/highlights.scm+31−23
@@ -1,15 +1,16 @@
1(comment) @comment
1(comment) @comment
2
2
3[
3[
4− "if"
4+ "if"
5 "then"
5 "then"
6 "else"
6 "else"
7 "let"
7 "let"
8 "inherit"
8 "inherit"
9 "in"
9 "in"
10 "rec"
10 "rec"
11− "with"
11+ "with"
12 "assert"
12 "assert"
13+ "or"
13] @keyword
14] @keyword
14
15
15((identifier) @variable.builtin
16((identifier) @variable.builtin
@@ -21,25 +22,25 @@
21 (#is-not? local))
22 (#is-not? local))
22
23
23[
24[
24− (string)
25+ (string_expression)
25− (indented_string)
26+ (indented_string_expression)
26] @string
27] @string
27
28
28[
29[
29− (path)
30+ (path_expression)
30− (hpath)
31+ (hpath_expression)
31− (spath)
32+ (spath_expression)
32] @string.special.path
33] @string.special.path
33
34
34−(uri) @string.special.uri
35+(uri_expression) @string.special.uri
35
36
36; boolean
37; boolean
37((identifier) @constant.builtin.boolean (#match? @constant.builtin.boolean "^(true|false)$")) @constant.builtin.boolean
38((identifier) @constant.builtin.boolean (#match? @constant.builtin.boolean "^(true|false)$")) @constant.builtin.boolean
38; null
39; null
39((identifier) @constant.builtin (#eq? @constant.builtin "null")) @constant.builtin
40((identifier) @constant.builtin (#eq? @constant.builtin "null")) @constant.builtin
40
41
41−(integer) @constant.numeric.integer
42+(integer_expression) @constant.numeric.integer
42−(float) @constant.numeric.float
43+(float_expression) @constant.numeric.float
43
44
44(interpolation
45(interpolation
45 "${" @punctuation.special
46 "${" @punctuation.special
@@ -47,7 +48,7 @@
47
48
48(escape_sequence) @constant.character.escape
49(escape_sequence) @constant.character.escape
49
50
50−(function
51+(function_expression
51 universal: (identifier) @variable.parameter
52 universal: (identifier) @variable.parameter
52)
53)
53
54
@@ -55,27 +56,36 @@
55 name: (identifier) @variable.parameter
56 name: (identifier) @variable.parameter
56 "?"? @punctuation.delimiter)
57 "?"? @punctuation.delimiter)
57
58
58−(app
59+(select_expression
60+ attrpath: (attrpath (identifier)) @variable.other.member)
61+
62+(apply_expression
59 function: [
63 function: [
60− (identifier) @function
64+ (variable_expression (identifier)) @function
61− (select
65+ (select_expression
62 attrpath: (attrpath
66 attrpath: (attrpath
63− attr: (attr_identifier) @function .))])
67+ attr: (identifier) @function .))])
64−
65
68
66−(unary
69+(unary_expression
67 operator: _ @operator)
70 operator: _ @operator)
68
71
69−(binary
72+(binary_expression
70 operator: _ @operator)
73 operator: _ @operator)
71
74
72−(attr_identifier) @variable.other.member
75+(variable_expression (identifier) @variable)
76+
77+(binding
78+ attrpath: (attrpath (identifier)) @variable.other.member)
79+
80+(identifier) @variable.other.member
81+
73−(inherit attrs: (attrs_inherited (identifier) @variable.other.member) )
82+(inherit_from attrs: (inherited_attrs attr: (identifier) @variable.other.member) )
74
83
75[
84[
76 ";"
85 ";"
77 "."
86 "."
78 ","
87 ","
88+ "="
79] @punctuation.delimiter
89] @punctuation.delimiter
80
90
81[
91[
@@ -85,6 +95,4 @@
85 "]"
95 "]"
86 "{"
96 "{"
87 "}"
97 "}"
88−] @punctuation.bracket
98+] @punctuation.bracket
89−
90−(identifier) @variable
runtime/queries/nix/indents.scm+20−13
@@ -1,18 +1,25 @@
1+
1[
2[
2− ; "function",
3+ ; Bracket like
3− (bind)
4− (assert)
5− (with)
6 (let)
4 (let)
7− (if)
8−
9 (attrset)
5 (attrset)
10− (list)
6+ (rec_attrset)
11− (indented_string)
7+ (let_attrset)
12 (parenthesized)
8 (parenthesized)
13−] @indent
9+ (list)
14
10
15−[
11+ ; Binding
16− "}"
12+ (bind)
17− "]"
13+ (inherit)
18−] @outdent
14+ (inherit_from)
15+ (formal)
16+
17+ ; Binary operations
18+ (binary)
19+ (has_attr)
20+ (select)
21+ (app)
22+
23+ ; Conditional
24+ (if)
25+] @indent