on master help sign in
feat(lang): Update Nix grammar & improve queries (#2472)
commiteba82250bb4403fcb2e3ade74ba7301a680bc561 authorTimothy DeHerrera <tim@nrdxp.dev> dateMon 30 May 2022, 12:47 (4 years ago) parent370a16d
3 files changed+52−37
languages.toml+1−1 runtime/queries/nix/highlights.scm+31−23 runtime/queries/nix/indents.scm+20−13
languages.toml+1−1
@@ -439,7 +439,7 @@ indent = { tab-width = 2, unit = " " }
439439
440440[[grammar]]
441441name = "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" }
443443
444444[[language]]
445445name = "ruby"
runtime/queries/nix/highlights.scm+31−23
@@ -1,15 +1,16 @@
11(comment) @comment
22
33[
4− "if"
4+ "if"
55 "then"
66 "else"
77 "let"
88 "inherit"
99 "in"
1010 "rec"
11− "with"
11+ "with"
1212 "assert"
13+ "or"
1314] @keyword
1415
1516((identifier) @variable.builtin
@@ -21,25 +22,25 @@
2122 (#is-not? local))
2223
2324[
24− (string)
25− (indented_string)
25+ (string_expression)
26+ (indented_string_expression)
2627] @string
2728
2829[
29− (path)
30− (hpath)
31− (spath)
30+ (path_expression)
31+ (hpath_expression)
32+ (spath_expression)
3233] @string.special.path
3334
34−(uri) @string.special.uri
35+(uri_expression) @string.special.uri
3536
3637; boolean
3738((identifier) @constant.builtin.boolean (#match? @constant.builtin.boolean "^(true|false)$")) @constant.builtin.boolean
3839; null
3940((identifier) @constant.builtin (#eq? @constant.builtin "null")) @constant.builtin
4041
41−(integer) @constant.numeric.integer
42−(float) @constant.numeric.float
42+(integer_expression) @constant.numeric.integer
43+(float_expression) @constant.numeric.float
4344
4445(interpolation
4546 "${" @punctuation.special
@@ -47,7 +48,7 @@
4748
4849(escape_sequence) @constant.character.escape
4950
50−(function
51+(function_expression
5152 universal: (identifier) @variable.parameter
5253)
5354
@@ -55,27 +56,36 @@
5556 name: (identifier) @variable.parameter
5657 "?"? @punctuation.delimiter)
5758
58−(app
59+(select_expression
60+ attrpath: (attrpath (identifier)) @variable.other.member)
61+
62+(apply_expression
5963 function: [
60− (identifier) @function
61− (select
64+ (variable_expression (identifier)) @function
65+ (select_expression
6266 attrpath: (attrpath
63− attr: (attr_identifier) @function .))])
64−
67+ attr: (identifier) @function .))])
6568
66−(unary
69+(unary_expression
6770 operator: _ @operator)
6871
69−(binary
72+(binary_expression
7073 operator: _ @operator)
7174
72−(attr_identifier) @variable.other.member
73−(inherit attrs: (attrs_inherited (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+
82+(inherit_from attrs: (inherited_attrs attr: (identifier) @variable.other.member) )
7483
7584[
7685 ";"
7786 "."
7887 ","
88+ "="
7989] @punctuation.delimiter
8090
8191[
@@ -85,6 +95,4 @@
8595 "]"
8696 "{"
8797 "}"
88−] @punctuation.bracket
89−
90−(identifier) @variable
98+] @punctuation.bracket
runtime/queries/nix/indents.scm+20−13
@@ -1,18 +1,25 @@
1+
12[
2− ; "function",
3− (bind)
4− (assert)
5− (with)
3+ ; Bracket like
64 (let)
7− (if)
8−
95 (attrset)
10− (list)
11− (indented_string)
6+ (rec_attrset)
7+ (let_attrset)
128 (parenthesized)
13−] @indent
9+ (list)
1410
15−[
16− "}"
17− "]"
18−] @outdent
11+ ; Binding
12+ (bind)
13+ (inherit)
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