Skip to content

Commit

Permalink
nix: fix highlighting rules
Browse files Browse the repository at this point in the history
* avoid coloring `identifier`s globally
* fix function application when not part of `select_expression`
* add `has_attribute_expression` highlighting
* fix precendence for interpolation, which should be after select
* highlight `@` as delimiter
  • Loading branch information
nrdxp authored and jdrst committed Sep 13, 2022
1 parent 434267b commit 4cb4553
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions runtime/queries/nix/highlights.scm
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
(comment) @comment

"assert" @keyword.control.exception
"or" @keyword.operator
"rec" @keyword.control.repeat

[
"if"
"then"
"else"
] @keyword.control.conditional

[
"let"
"inherit"
"in"
"rec"
"with"
"assert"
"or"
] @keyword

((identifier) @variable.builtin
Expand Down Expand Up @@ -42,26 +46,27 @@
(integer_expression) @constant.numeric.integer
(float_expression) @constant.numeric.float

(interpolation
"${" @punctuation.special
"}" @punctuation.special) @embedded

(escape_sequence) @constant.character.escape

(function_expression
universal: (identifier) @variable.parameter
"@"? @punctuation.delimiter
)

(formal
name: (identifier) @variable.parameter
"?"? @punctuation.delimiter)

(select_expression
attrpath: (attrpath (identifier)) @variable.other.member)
attrpath: (attrpath attr: (identifier)) @variable.other.member)

(interpolation
"${" @punctuation.special
"}" @punctuation.special) @embedded

(apply_expression
function: [
(variable_expression (identifier)) @function
(variable_expression name: (identifier) @function)
(select_expression
attrpath: (attrpath
attr: (identifier) @function .))])
Expand All @@ -72,14 +77,18 @@
(binary_expression
operator: _ @operator)

(variable_expression (identifier) @variable)
(variable_expression name: (identifier) @variable)

(binding
attrpath: (attrpath (identifier)) @variable.other.member)
attrpath: (attrpath attr: (identifier)) @variable.other.member)

(identifier) @variable.other.member
(inherit_from attrs: (inherited_attrs attr: (identifier) @variable))

(inherit_from attrs: (inherited_attrs attr: (identifier) @variable.other.member) )
(has_attr_expression
expression: (_)
"?" @operator
attrpath: (attrpath
attr: (identifier) @variable.other.member))

[
";"
Expand Down

0 comments on commit 4cb4553

Please sign in to comment.