Skip to content

Commit 5dcb732

Browse files
author
fidgetingbits
committed
minor fixes and add condition
1 parent 506569d commit 5dcb732

File tree

2 files changed

+48
-13
lines changed

2 files changed

+48
-13
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
languageId: nix
2+
command:
3+
version: 6
4+
spokenForm: change condition
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: condition}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |
15+
{
16+
key =
17+
if a > b
18+
then b
19+
else c;
20+
}
21+
selections:
22+
- anchor: {line: 3, character: 9}
23+
active: {line: 3, character: 9}
24+
marks: {}
25+
finalState:
26+
documentContents: |
27+
{
28+
key =
29+
if
30+
then b
31+
else c;
32+
}
33+
selections:
34+
- anchor: {line: 2, character: 7}
35+
active: {line: 2, character: 7}

queries/nix.scm

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424
;;!! in a + b
2525
(let_expression
2626
"let"
27-
(_) @statement.iteration @value.iteration @name.iteration @condition.iteration
27+
(_) @statement.iteration @value.iteration @name.iteration
2828
)
2929

3030
;; Conditionals
3131

3232
;;!! key = if a then b else c;
3333
;;! ^^^^^^^^^^^^^^^^^^
34-
(if_expression) @ifStatement @branch.iteration
34+
(if_expression) @ifStatement @branch.iteration @condition.iteration
3535
;;!! key = if a then b else c;
3636
;;! ^^^^
3737
(if_expression
@@ -51,6 +51,12 @@
5151
alternative: (_) @branch.end
5252
)
5353

54+
;;!! key = if a > 10 then b else c;
55+
;;! ^^^^^^
56+
(if_expression
57+
condition: (_) @condition
58+
) @_.domain
59+
5460
;; Lists and maps
5561

5662
;;!! foo = [ a b c ];
@@ -77,17 +83,11 @@
7783
;;! ^^^^^
7884
(comment) @comment @textFragment
7985

80-
(string_expression
81-
_ @textFragment.start.endOf
82-
(string_fragment)
83-
_ @textFragment.end.startOf
84-
) @string
85-
86-
(indented_string_expression
87-
"''" @textFragment.start.endOf
88-
(string_fragment)
89-
"''" @textFragment.end.startOf
90-
) @string
86+
[
87+
(string_expression)
88+
(indented_string_expression)
89+
] @string
90+
(string_fragment) @textFragment
9191

9292
;; Functions
9393

0 commit comments

Comments
 (0)