aboutsummaryrefslogtreecommitdiff
path: root/runtime/queries/nix
diff options
context:
space:
mode:
authorTimothy DeHerrera2022-05-30 18:47:18 +0000
committerGitHub2022-05-30 18:47:18 +0000
commiteba82250bb4403fcb2e3ade74ba7301a680bc561 (patch)
treed308322dec1d35180317918921f21750a48769a4 /runtime/queries/nix
parent370a16d0f00d6146fdeb87cc16fb352e860e2377 (diff)
feat(lang): Update Nix grammar & improve queries (#2472)
Diffstat (limited to 'runtime/queries/nix')
-rw-r--r--runtime/queries/nix/highlights.scm54
-rw-r--r--runtime/queries/nix/indents.scm33
2 files changed, 51 insertions, 36 deletions
diff --git a/runtime/queries/nix/highlights.scm b/runtime/queries/nix/highlights.scm
index f6682065..d5ff4032 100644
--- a/runtime/queries/nix/highlights.scm
+++ b/runtime/queries/nix/highlights.scm
@@ -1,15 +1,16 @@
(comment) @comment
[
- "if"
+ "if"
"then"
"else"
"let"
"inherit"
"in"
"rec"
- "with"
+ "with"
"assert"
+ "or"
] @keyword
((identifier) @variable.builtin
@@ -21,25 +22,25 @@
(#is-not? local))
[
- (string)
- (indented_string)
+ (string_expression)
+ (indented_string_expression)
] @string
[
- (path)
- (hpath)
- (spath)
+ (path_expression)
+ (hpath_expression)
+ (spath_expression)
] @string.special.path
-(uri) @string.special.uri
+(uri_expression) @string.special.uri
; boolean
((identifier) @constant.builtin.boolean (#match? @constant.builtin.boolean "^(true|false)$")) @constant.builtin.boolean
; null
((identifier) @constant.builtin (#eq? @constant.builtin "null")) @constant.builtin
-(integer) @constant.numeric.integer
-(float) @constant.numeric.float
+(integer_expression) @constant.numeric.integer
+(float_expression) @constant.numeric.float
(interpolation
"${" @punctuation.special
@@ -47,7 +48,7 @@
(escape_sequence) @constant.character.escape
-(function
+(function_expression
universal: (identifier) @variable.parameter
)
@@ -55,27 +56,36 @@
name: (identifier) @variable.parameter
"?"? @punctuation.delimiter)
-(app
+(select_expression
+ attrpath: (attrpath (identifier)) @variable.other.member)
+
+(apply_expression
function: [
- (identifier) @function
- (select
+ (variable_expression (identifier)) @function
+ (select_expression
attrpath: (attrpath
- attr: (attr_identifier) @function .))])
-
+ attr: (identifier) @function .))])
-(unary
+(unary_expression
operator: _ @operator)
-(binary
+(binary_expression
operator: _ @operator)
-(attr_identifier) @variable.other.member
-(inherit attrs: (attrs_inherited (identifier) @variable.other.member) )
+(variable_expression (identifier) @variable)
+
+(binding
+ attrpath: (attrpath (identifier)) @variable.other.member)
+
+(identifier) @variable.other.member
+
+(inherit_from attrs: (inherited_attrs attr: (identifier) @variable.other.member) )
[
";"
"."
","
+ "="
] @punctuation.delimiter
[
@@ -85,6 +95,4 @@
"]"
"{"
"}"
-] @punctuation.bracket
-
-(identifier) @variable
+] @punctuation.bracket \ No newline at end of file
diff --git a/runtime/queries/nix/indents.scm b/runtime/queries/nix/indents.scm
index 0790ce29..a12376e7 100644
--- a/runtime/queries/nix/indents.scm
+++ b/runtime/queries/nix/indents.scm
@@ -1,18 +1,25 @@
+
[
- ; "function",
- (bind)
- (assert)
- (with)
+ ; Bracket like
(let)
- (if)
-
(attrset)
- (list)
- (indented_string)
+ (rec_attrset)
+ (let_attrset)
(parenthesized)
-] @indent
+ (list)
-[
- "}"
- "]"
-] @outdent
+ ; Binding
+ (bind)
+ (inherit)
+ (inherit_from)
+ (formal)
+
+ ; Binary operations
+ (binary)
+ (has_attr)
+ (select)
+ (app)
+
+ ; Conditional
+ (if)
+] @indent \ No newline at end of file