Skip to content

Commit f9e8af3

Browse files
author
fidgetingbits
committed
Fix arg and condition and add more tests
1 parent 0c140f5 commit f9e8af3

File tree

8 files changed

+270
-6
lines changed

8 files changed

+270
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
languageId: lua
2+
command:
3+
version: 6
4+
spokenForm: bring arg air after bat
5+
action:
6+
name: replaceWithTarget
7+
source:
8+
type: primitive
9+
mark: {type: decoratedSymbol, symbolColor: default, character: a}
10+
modifiers:
11+
- type: containingScope
12+
scopeType: {type: argumentOrParameter}
13+
destination:
14+
type: primitive
15+
insertionMode: after
16+
target:
17+
type: primitive
18+
mark: {type: decoratedSymbol, symbolColor: default, character: b}
19+
usePrePhraseSnapshot: true
20+
initialState:
21+
documentContents: |-
22+
function makeCounter(a, b)
23+
local count = 0
24+
return function()
25+
count = count + 1
26+
return count
27+
end
28+
end
29+
selections:
30+
- anchor: {line: 0, character: 21}
31+
active: {line: 0, character: 21}
32+
marks:
33+
default.a:
34+
start: {line: 0, character: 21}
35+
end: {line: 0, character: 22}
36+
default.b:
37+
start: {line: 0, character: 24}
38+
end: {line: 0, character: 25}
39+
finalState:
40+
documentContents: |-
41+
function makeCounter(a, b, a)
42+
local count = 0
43+
return function()
44+
count = count + 1
45+
return count
46+
end
47+
end
48+
selections:
49+
- anchor: {line: 0, character: 21}
50+
active: {line: 0, character: 21}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
languageId: lua
2+
command:
3+
version: 6
4+
spokenForm: change inside funk
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- {type: interiorOnly}
11+
- type: containingScope
12+
scopeType: {type: namedFunction}
13+
usePrePhraseSnapshot: true
14+
initialState:
15+
documentContents: |-
16+
function makeCounter()
17+
local count = 0
18+
return function()
19+
count = count + 1
20+
return count
21+
end
22+
end
23+
selections:
24+
- anchor: {line: 1, character: 19}
25+
active: {line: 1, character: 19}
26+
marks: {}
27+
finalState:
28+
documentContents: |-
29+
function makeCounter()
30+
31+
end
32+
selections:
33+
- anchor: {line: 1, character: 4}
34+
active: {line: 1, character: 4}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
languageId: lua
2+
command:
3+
version: 6
4+
spokenForm: change inside lambda
5+
action:
6+
name: clearAndSetSelection
7+
target:
8+
type: primitive
9+
modifiers:
10+
- {type: interiorOnly}
11+
- type: containingScope
12+
scopeType: {type: anonymousFunction}
13+
usePrePhraseSnapshot: true
14+
initialState:
15+
documentContents: |-
16+
function makeCounter()
17+
local count = 0
18+
return function()
19+
count = count + 1
20+
return count
21+
end
22+
end
23+
selections:
24+
- anchor: {line: 3, character: 19}
25+
active: {line: 3, character: 19}
26+
marks: {}
27+
finalState:
28+
documentContents: |-
29+
function makeCounter()
30+
local count = 0
31+
return function()
32+
33+
end
34+
end
35+
selections:
36+
- anchor: {line: 3, character: 8}
37+
active: {line: 3, character: 8}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
languageId: lua
2+
command:
3+
version: 6
4+
spokenForm: chuck arg
5+
action:
6+
name: remove
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: argumentOrParameter}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |-
15+
function makeCounter(a, b)
16+
local count = 0
17+
return function()
18+
count = count + 1
19+
return count
20+
end
21+
end
22+
selections:
23+
- anchor: {line: 0, character: 22}
24+
active: {line: 0, character: 22}
25+
marks: {}
26+
finalState:
27+
documentContents: |-
28+
function makeCounter(b)
29+
local count = 0
30+
return function()
31+
count = count + 1
32+
return count
33+
end
34+
end
35+
selections:
36+
- anchor: {line: 0, character: 21}
37+
active: {line: 0, character: 21}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
languageId: lua
2+
command:
3+
version: 6
4+
spokenForm: chuck arg
5+
action:
6+
name: remove
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: argumentOrParameter}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |-
15+
function makeCounter(a)
16+
local count = 0
17+
return function()
18+
count = count + 1
19+
return count
20+
end
21+
end
22+
selections:
23+
- anchor: {line: 0, character: 22}
24+
active: {line: 0, character: 22}
25+
marks: {}
26+
finalState:
27+
documentContents: |-
28+
function makeCounter()
29+
local count = 0
30+
return function()
31+
count = count + 1
32+
return count
33+
end
34+
end
35+
selections:
36+
- anchor: {line: 0, character: 21}
37+
active: {line: 0, character: 21}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
languageId: lua
2+
command:
3+
version: 6
4+
spokenForm: chuck item
5+
action:
6+
name: remove
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: collectionItem}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: |-
15+
local person = {
16+
name = "John",
17+
age = 30,
18+
hobbies = {"reading", "gaming", "programming"},
19+
address = {
20+
street = "123 Main St",
21+
city = "Example City"
22+
}
23+
}
24+
selections:
25+
- anchor: {line: 4, character: 6}
26+
active: {line: 4, character: 6}
27+
marks: {}
28+
finalState:
29+
documentContents: |-
30+
local person = {
31+
name = "John",
32+
age = 30,
33+
hobbies = {"reading", "gaming", "programming"}
34+
}
35+
selections:
36+
- anchor: {line: 3, character: 50}
37+
active: {line: 3, character: 50}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
languageId: lua
2+
command:
3+
version: 6
4+
spokenForm: chuck item
5+
action:
6+
name: remove
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: collectionItem}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: hobbies = {"reading"}
15+
selections:
16+
- anchor: {line: 0, character: 19}
17+
active: {line: 0, character: 19}
18+
marks: {}
19+
finalState:
20+
documentContents: hobbies = {}
21+
selections:
22+
- anchor: {line: 0, character: 11}
23+
active: {line: 0, character: 11}

queries/lua.scm

+15-6
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@
3838
)
3939

4040
;; Conditionals
41-
(
42-
(_
43-
condition: (_) @condition
44-
)
41+
(_
42+
condition: (_) @condition
4543
)
44+
4645
(if_statement
4746
"if" @branch.start
4847
consequence: (_) @branch.end
@@ -80,10 +79,20 @@
8079
) @_.domain @functionCall
8180

8281
(arguments
83-
(_) @argumentOrParameter
82+
(_)? @_.leading.start.endOf
83+
.
84+
(_) @argumentOrParameter @_.leading.end.startOf @_.trailing.start.endOf
85+
.
86+
(_)? @_.trailing.end.startOf
87+
(#insertion-delimiter! @argumentOrParameter ", ")
8488
) @argumentOrParameter.iteration
8589
(parameters
86-
(_) @argumentOrParameter
90+
(_)? @_.leading.start.endOf
91+
.
92+
(_) @argumentOrParameter @_.leading.end.startOf @_.trailing.start.endOf
93+
.
94+
(_)? @_.trailing.end.startOf
95+
(#insertion-delimiter! @argumentOrParameter ", ")
8796
) @argumentOrParameter.iteration
8897

8998
(function_declaration

0 commit comments

Comments
 (0)