aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBaraa Homsi <49784526+bodby@users.noreply.github.com>2025-01-20 03:03:13 +0000
committerGitHub <noreply@github.com>2025-01-19 19:03:13 -0800
commit4d93fae5a3764451dacd94796d0de16a752ae3eb (patch)
tree44c3c0b0294d0e8561868e9c5b1f8d6e49495c28
parentfeat(hyprlang): bash injection for hypridle variables (diff)
downloadnvim-treesitter-4d93fae5a3764451dacd94796d0de16a752ae3eb.tar
nvim-treesitter-4d93fae5a3764451dacd94796d0de16a752ae3eb.tar.gz
nvim-treesitter-4d93fae5a3764451dacd94796d0de16a752ae3eb.tar.bz2
nvim-treesitter-4d93fae5a3764451dacd94796d0de16a752ae3eb.tar.lz
nvim-treesitter-4d93fae5a3764451dacd94796d0de16a752ae3eb.tar.xz
nvim-treesitter-4d93fae5a3764451dacd94796d0de16a752ae3eb.tar.zst
nvim-treesitter-4d93fae5a3764451dacd94796d0de16a752ae3eb.zip
fix(nix): highlight functions when part of a set (#7547)
* feat(nix): Fix function highlights when part of a set * fix(nix): Highlight only the last identifier node in functions * fix(nix): Higher precedence for builtins compared to functions and member vars
-rw-r--r--queries/nix/highlights.scm64
1 files changed, 38 insertions, 26 deletions
diff --git a/queries/nix/highlights.scm b/queries/nix/highlights.scm
index 7cdcc3e1d..785d249b9 100644
--- a/queries/nix/highlights.scm
+++ b/queries/nix/highlights.scm
@@ -90,6 +90,44 @@
name: (identifier) @boolean
(#any-of? @boolean "true" "false"))
+; string interpolation (this was very annoying to get working properly)
+(interpolation
+ "${" @punctuation.special
+ (_)
+ "}" @punctuation.special) @none
+
+(select_expression
+ expression: (_) @_expr
+ attrpath: (attrpath
+ attr: (identifier) @variable.member)
+ (#not-eq? @_expr "builtins"))
+
+(attrset_expression
+ (binding_set
+ (binding
+ .
+ (attrpath
+ (identifier) @variable.member))))
+
+(rec_attrset_expression
+ (binding_set
+ (binding
+ .
+ (attrpath
+ (identifier) @variable.member))))
+
+(apply_expression
+ function: [
+ (select_expression
+ attrpath: (attrpath
+ .
+ attr: (identifier) @function.call .))
+ (select_expression
+ attrpath: (attrpath
+ (_)
+ attr: (identifier) @function.call .))
+ ])
+
; builtin functions (with builtins prefix)
(select_expression
expression: (variable_expression
@@ -138,32 +176,6 @@
; nix eval --impure --expr 'with builtins; filter (x: !(isFunction builtins.${x} || isBool builtins.${x})) (attrNames builtins)'
"builtins" "currentSystem" "currentTime" "langVersion" "nixPath" "nixVersion" "null" "storeDir"))
-; string interpolation (this was very annoying to get working properly)
-(interpolation
- "${" @punctuation.special
- (_)
- "}" @punctuation.special) @none
-
-(select_expression
- expression: (_) @_expr
- attrpath: (attrpath
- attr: (identifier) @variable.member)
- (#not-eq? @_expr "builtins"))
-
-(attrset_expression
- (binding_set
- (binding
- .
- (attrpath
- (identifier) @variable.member))))
-
-(rec_attrset_expression
- (binding_set
- (binding
- .
- (attrpath
- (identifier) @variable.member))))
-
; function definition
(binding
attrpath: (attrpath