Skip to content

Commit c7ef9b5

Browse files
author
fidgetingbits
committed
Additional condition and better name/value domains
1 parent 9ab1e41 commit c7ef9b5

File tree

7 files changed

+200
-2
lines changed

7 files changed

+200
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: lua
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: local max = x > y and x or y
15+
selections:
16+
- anchor: {line: 0, character: 12}
17+
active: {line: 0, character: 12}
18+
marks: {}
19+
finalState:
20+
documentContents: local max = and x or y
21+
selections:
22+
- anchor: {line: 0, character: 12}
23+
active: {line: 0, character: 12}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
languageId: lua
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+
local i = 1
16+
while i <= 5 do
17+
print("While loop iteration: " .. i)
18+
i = i + 1
19+
end
20+
selections:
21+
- anchor: {line: 1, character: 7}
22+
active: {line: 1, character: 7}
23+
marks: {}
24+
finalState:
25+
documentContents: |-
26+
local i = 1
27+
while do
28+
print("While loop iteration: " .. i)
29+
i = i + 1
30+
end
31+
selections:
32+
- anchor: {line: 1, character: 6}
33+
active: {line: 1, character: 6}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
languageId: lua
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+
i = 1
16+
repeat
17+
print("Repeat-Until loop iteration: " .. i)
18+
i = i + 1
19+
until i > 5
20+
selections:
21+
- anchor: {line: 4, character: 6}
22+
active: {line: 4, character: 6}
23+
marks: {}
24+
finalState:
25+
documentContents: |
26+
i = 1
27+
repeat
28+
print("Repeat-Until loop iteration: " .. i)
29+
i = i + 1
30+
until
31+
selections:
32+
- anchor: {line: 4, character: 6}
33+
active: {line: 4, character: 6}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: lua
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: local i = 1
15+
selections:
16+
- anchor: {line: 0, character: 2}
17+
active: {line: 0, character: 2}
18+
marks: {}
19+
finalState:
20+
documentContents: local = 1
21+
selections:
22+
- anchor: {line: 0, character: 6}
23+
active: {line: 0, character: 6}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
languageId: lua
2+
command:
3+
version: 6
4+
spokenForm: change value
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: value}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |-
15+
function makeCounter()
16+
local count = 0
17+
return function()
18+
count = count + 1
19+
return count
20+
end
21+
end
22+
selections:
23+
- anchor: {line: 2, character: 8}
24+
active: {line: 2, character: 8}
25+
marks: {}
26+
finalState:
27+
documentContents: |-
28+
function makeCounter()
29+
local count = 0
30+
return
31+
end
32+
selections:
33+
- anchor: {line: 2, character: 11}
34+
active: {line: 2, character: 11}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: lua
2+
command:
3+
version: 6
4+
spokenForm: change value
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: value}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: local i = 1
15+
selections:
16+
- anchor: {line: 0, character: 2}
17+
active: {line: 0, character: 2}
18+
marks: {}
19+
finalState:
20+
documentContents: "local i = "
21+
selections:
22+
- anchor: {line: 0, character: 10}
23+
active: {line: 0, character: 10}

queries/lua.scm

+31-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
;; Conditionals
4141
(_
4242
condition: (_) @condition
43-
)
43+
) @_.domain
4444

4545
(if_statement
4646
"if" @branch.start
@@ -51,6 +51,8 @@
5151
(else_statement)
5252
] @branch
5353

54+
(binary_expression) @condition @condition.domain
55+
5456
;; Lists and maps
5557
(table_constructor) @map @collectionKey.iteration
5658
(field
@@ -115,7 +117,17 @@
115117
(#allow-multiple! @name)
116118
) @_.leading.end.startOf
117119
) @_.domain
118-
120+
(variable_declaration
121+
(assignment_statement
122+
(variable_list
123+
name: (_) @name
124+
;; Handle multiple variable declarators in one statement, eg
125+
;;!! local b, c = "Hello", "World"
126+
;;! ------^--^-------------------
127+
(#allow-multiple! @name)
128+
) @_.leading.end.startOf
129+
)
130+
) @_.domain
119131
(assignment_statement
120132
(_) @_.leading.start.endOf
121133
.
@@ -127,3 +139,20 @@
127139
(#allow-multiple! @value)
128140
) @_.leading.end.startOf
129141
) @_.domain
142+
(variable_declaration
143+
(assignment_statement
144+
(_) @_.leading.start.endOf
145+
.
146+
(expression_list
147+
value: (_) @value
148+
;; Handle multiple variable declarators in one statement, eg
149+
;;!! local b, c = "Hello", "World"
150+
;;! -------------^^^^^^^--^^^^^^^
151+
(#allow-multiple! @value)
152+
) @_.leading.end.startOf
153+
)
154+
) @_.domain
155+
156+
(return_statement
157+
(_) @value
158+
) @_.domain

0 commit comments

Comments
 (0)