-
Notifications
You must be signed in to change notification settings - Fork 22
/
ts.nu
48 lines (42 loc) · 1.11 KB
/
ts.nu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# | A bunch of commands for developing `tree-sitter-nu`
#
# # requirements
# - tree-sitter cli
# Generates a parser from the grammar
export def "ts gen" [] { # -> nothing
clear
tree-sitter generate
}
# Performs highlighting on the specified file(s) and
# prints the highlighted result(s) to stdout
export def "ts hl" [ # -> string
glob: string # the file(s) to highlight
] {
clear
tree-sitter highlight $glob
}
# Runs all tests in the repo
export def "ts test" [] { # -> string
clear
tree-sitter test
}
# Parses the specified file(s) and prints their ASTs to
# std-out
export def "ts parse" [ # -> string
glob: string, # the file(s) to parse
--debug(-d), # print debug info along with the AST
--stat(-s), # only print success stats instead of the AST
] {
clear
if $debug {
tree-sitter parse $glob -d
} else if $stat {
tree-sitter parse $glob -sq
} else {
tree-sitter parse $glob
}
}
# Generates a default config file and prints out its path
export def "ts config" [] {
tree-sitter init-config
}