Skip to content

Commit d7dd9a7

Browse files
blindFSBahex
andauthored
fix(style): match expression (#31)
* chore: parser upgrade * insert spaces around alternate pattern delimiter ('|') * insert space before closing brace in single line match expression --------- Co-authored-by: Bahex <[email protected]>
1 parent b5cd69b commit d7dd9a7

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

languages.ncl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
extensions = ["nu"],
55
grammar.source.git = {
66
git = "https://github.com/nushell/tree-sitter-nu.git",
7-
rev = "0e6c59c46db3c246eaf86ce5b325da1247e971a5",
7+
rev = "d9d6ad2c836bc3bd5010ab7850bc6da9498ca576",
88
},
99
},
1010
},

languages/nu.scm

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,11 @@
258258
scrutinee: _? @append_space
259259
(match_arm)? @prepend_spaced_softline
260260
(default_arm)? @prepend_spaced_softline
261+
"}"? @prepend_spaced_softline
261262
)
262263

264+
(match_pattern "|" @prepend_spaced_softline @append_space )
265+
263266
;; data structures
264267
(command_list
265268
[

test/expected_ctrl.nu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ match $foo {
2323
}
2424
match $foo {
2525
[a b c] => 0
26+
a | b | c => 42
2627
}
28+
match $foo { null => { return "default" } $val => $val }
2729
# while
2830
mut x = 0; while $x < 10 { $x = $x + 1 }; $x # while comment
2931
# loop

test/input_ctrl.nu

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ match $foo {
2323
}
2424
match $foo {
2525
[ a b c] => 0
26+
a|b|c => 42
2627
}
28+
match $foo {null => {return "default"} $val => $val}
2729
# while
2830
mut x = 0; while $x < 10 { $x = $x + 1 }; $x # while comment
2931
# loop

0 commit comments

Comments
 (0)