Skip to content

Commit 7f38df1

Browse files
committed
fix: space issues
1 parent 2508c6e commit 7f38df1

File tree

4 files changed

+23
-50
lines changed

4 files changed

+23
-50
lines changed

languages.ncl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
extensions = ["nu"],
55
grammar.source.git = {
66
git = "https://github.com/blindfs/tree-sitter-nu.git",
7-
rev = "46ca5853edec9f3bc19a36d68d1311c1f36cd540",
7+
rev = "b3ececada7a378336732d17351e824919512d3f5",
88
},
9-
109
},
1110
},
1211
}

languages/nu.scm

Lines changed: 16 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
(val_number)
1414
(val_string)
1515
(val_variable)
16+
(cmd_identifier)
17+
(identifier)
18+
(path)
1619
] @leaf
1720

1821
;; keep empty lines
@@ -31,40 +34,6 @@
3134

3235
[
3336
"="
34-
(match_guard)
35-
(short_flag)
36-
(long_flag)
37-
] @prepend_space
38-
39-
;; FIXME: temp workaround for the whitespace issue
40-
(short_flag "=" @prepend_antispace)
41-
(long_flag "=" @prepend_antispace)
42-
(param_value "=" @append_space)
43-
44-
(assignment
45-
opr: _
46-
rhs: (pipeline
47-
(pipe_element
48-
(val_string
49-
(raw_string_begin)
50-
)
51-
)
52-
) @prepend_space
53-
)
54-
55-
(
56-
"="
57-
.
58-
(pipeline
59-
(pipe_element
60-
(val_string
61-
(raw_string_begin)
62-
)
63-
)
64-
) @prepend_space
65-
)
66-
67-
[
6837
"->"
6938
"=>"
7039
"alias"
@@ -93,6 +62,7 @@
9362
"source-env"
9463
"use"
9564
"where"
65+
(match_guard)
9666
] @prepend_space @append_space
9767

9868
(pipeline
@@ -104,7 +74,7 @@
10474
opr: _ @append_input_softline @prepend_input_softline
10575
)
10676

107-
(assignment opr: _ @prepend_space)
77+
(assignment opr: _ @prepend_space @append_space)
10878

10979
(where_predicate
11080
opr: _ @append_input_softline @prepend_input_softline
@@ -119,19 +89,12 @@
11989
.
12090
(_)
12191
)
92+
(short_flag "=" @prepend_antispace @append_antispace)
93+
(long_flag "=" @prepend_antispace @append_antispace)
94+
(env_var "=" @prepend_antispace @append_antispace)
12295

12396
(overlay_hide
124-
overlay: _ @prepend_space
125-
)
126-
127-
;; FIXME: temp workaround for the whitespace issue
128-
(hide_env
129-
[
130-
(short_flag)
131-
(long_flag)
132-
] @append_antispace
133-
.
134-
(_)
97+
overlay: _ @prepend_space @append_space
13598
)
13699

137100
(hide_env
@@ -354,3 +317,10 @@
354317
key: _ @prepend_space
355318
(#delimiter! ",")
356319
)
320+
321+
(composite_type
322+
type: _ @append_delimiter
323+
.
324+
type: _ @prepend_space
325+
(#delimiter! ",")
326+
)

test/expected_decl.nu

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ use module [ "foo" bar ]
4949

5050
# decl_module
5151
module greetings {
52-
export def hello [name: string] {
52+
export def hello [
53+
name: string
54+
--experimental-options: oneof<list<string>, string> # enable or disable experimental options
55+
] {
5356
$"hello ($name)!"
5457
}
5558

test/input_decl.nu

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ use module ["foo" bar]
4444

4545
# decl_module
4646
module greetings {
47-
export def hello [name: string] {
47+
export def hello [name: string --experimental-options: oneof<list<string>, string> # enable or disable experimental options
48+
] {
4849
$"hello ($name)!"
4950
}
5051

0 commit comments

Comments
 (0)