Skip to content

Commit 77bfe1d

Browse files
committed
feat(nu): add nushell support
1 parent 89ebe73 commit 77bfe1d

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

queries/nu/textobjects.scm

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
(stmt_let) @assignment.outer
2+
3+
(stmt_mut) @assignment.outer
4+
5+
(stmt_const) @assignment.outer
6+
7+
(stmt_let
8+
value: (_) @assignment.inner)
9+
10+
(stmt_mut
11+
value: (_) @assignment.inner)
12+
13+
(stmt_const
14+
value: (_) @assignment.inner)
15+
16+
(block) @block.outer
17+
18+
(comment) @comment.outer
19+
20+
(pipeline) @pipeline.outer
21+
22+
(pipe_element) @pipeline.inner
23+
24+
(decl_def) @function.outer
25+
26+
(decl_def
27+
body: (_) @function.inner)
28+
29+
(ctrl_for) @loop.outer
30+
31+
(ctrl_loop) @loop.outer
32+
33+
(ctrl_while) @loop.outer
34+
35+
(ctrl_for
36+
body: (_) @loop.inner)
37+
38+
(ctrl_loop
39+
body: (_) @loop.inner)
40+
41+
(ctrl_while
42+
body: (_) @loop.inner)
43+
44+
; Conditional inner counts the last one, rather than the current one.
45+
(ctrl_if
46+
then_branch: (_) @conditional.inner
47+
else_block: (_)? @conditional.inner) @conditional.outer
48+
49+
(parameter) @parameter.outer
50+
51+
(command
52+
head: (_) @call.inner) @call.outer
53+
54+
(where_command
55+
predicate: (_) @call.inner) @call.outer
56+
57+
; define pipeline first, because it should only match as a fallback
58+
; e.g., `let a = date now` should match the whole assignment.
59+
; But a standalone `date now` should also match a statement
60+
(pipeline) @statement.outer
61+
62+
(stmt_let) @statement.outer
63+
64+
(stmt_mut) @statement.outer
65+
66+
(stmt_const) @statement.outer
67+
68+
(ctrl_return) @statement.outer @return.outer
69+
70+
(ctrl_do) @statement.outer
71+
72+
(ctrl_if) @statement.outer
73+
74+
(ctrl_try) @statement.outer
75+
76+
(ctrl_match) @statement.outer
77+
78+
(ctrl_while) @statement.outer
79+
80+
(ctrl_loop) @statement.outer
81+
82+
("break"
83+
"continue") @statement.outer
84+
85+
(val_number) @number.inner

0 commit comments

Comments
 (0)