Skip to content

Commit 4c0a6a3

Browse files
author
fidgetingbits
committed
basic name support and tests
1 parent dda1cdd commit 4c0a6a3

File tree

5 files changed

+185
-3
lines changed

5 files changed

+185
-3
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
languageId: nix
2+
command:
3+
version: 6
4+
spokenForm: change name
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: name}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |
15+
{
16+
foo = let
17+
a = b;
18+
c = d;
19+
in
20+
{
21+
output = b;
22+
};
23+
24+
}
25+
selections:
26+
- anchor: {line: 1, character: 11}
27+
active: {line: 1, character: 11}
28+
marks: {}
29+
finalState:
30+
documentContents: |
31+
{
32+
= let
33+
a = b;
34+
c = d;
35+
in
36+
{
37+
output = b;
38+
};
39+
40+
}
41+
selections:
42+
- anchor: {line: 1, character: 2}
43+
active: {line: 1, character: 2}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
languageId: nix
2+
command:
3+
version: 6
4+
spokenForm: change name
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: name}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |
15+
{
16+
foo = let
17+
a = b;
18+
c = d;
19+
in
20+
{
21+
output = b;
22+
};
23+
24+
}
25+
selections:
26+
- anchor: {line: 2, character: 10}
27+
active: {line: 2, character: 10}
28+
marks: {}
29+
finalState:
30+
documentContents: |
31+
{
32+
foo = let
33+
= b;
34+
c = d;
35+
in
36+
{
37+
output = b;
38+
};
39+
40+
}
41+
selections:
42+
- anchor: {line: 2, character: 4}
43+
active: {line: 2, character: 4}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
languageId: nix
2+
command:
3+
version: 6
4+
spokenForm: chuck name
5+
action:
6+
name: remove
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: name}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |
15+
{
16+
foo = let
17+
a = b;
18+
c = d;
19+
in
20+
{
21+
output = b;
22+
};
23+
24+
}
25+
selections:
26+
- anchor: {line: 1, character: 11}
27+
active: {line: 1, character: 11}
28+
marks: {}
29+
finalState:
30+
documentContents: |
31+
{
32+
= let
33+
a = b;
34+
c = d;
35+
in
36+
{
37+
output = b;
38+
};
39+
40+
}
41+
selections:
42+
- anchor: {line: 1, character: 7}
43+
active: {line: 1, character: 7}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
languageId: nix
2+
command:
3+
version: 6
4+
spokenForm: chuck name
5+
action:
6+
name: remove
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: name}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |
15+
{
16+
foo = let
17+
a = b;
18+
c = d;
19+
in
20+
{
21+
output = b;
22+
};
23+
24+
}
25+
selections:
26+
- anchor: {line: 6, character: 17}
27+
active: {line: 6, character: 17}
28+
marks: {}
29+
finalState:
30+
documentContents: |
31+
{
32+
foo = let
33+
a = b;
34+
c = d;
35+
in
36+
{
37+
= b;
38+
};
39+
40+
}
41+
selections:
42+
- anchor: {line: 6, character: 10}
43+
active: {line: 6, character: 10}

queries/nix.scm

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
[
2222
(attrset_expression)
2323
(rec_attrset_expression)
24-
] @map @statement.iteration @value.iteration
24+
] @map @statement.iteration @value.iteration @name.iteration
2525
(binding_set) @map.iteration @list.iteration @ifStatement.iteration
2626

2727
(source_code) @statement.iteration @map.iteration
@@ -34,7 +34,7 @@
3434
;;!! in a + b
3535
(let_expression
3636
"let"
37-
(_) @statement.iteration @value.iteration
37+
(_) @statement.iteration @value.iteration @name.iteration
3838
)
3939

4040
(string_expression
@@ -87,9 +87,19 @@
8787
;;!! a = 25;
8888
;;! ^^
8989
;;! xxxxx
90-
;;! ------
90+
;;! -------
9191
(binding
9292
(_) @_.leading.start.endOf
9393
.
9494
expression: (_) @value @_.leading.end.startOf
9595
) @_.domain
96+
97+
;;!! a = 25;
98+
;;! ^
99+
;;! xx
100+
;;! -------
101+
(binding
102+
(_) @name @_.leading.end.startOf
103+
.
104+
expression: (_)
105+
) @_.domain

0 commit comments

Comments
 (0)