File tree Expand file tree Collapse file tree 5 files changed +69
-29
lines changed
Expand file tree Collapse file tree 5 files changed +69
-29
lines changed Original file line number Diff line number Diff line change 207207 (_) @prepend_end_scope @prepend_input_softline
208208 (#scope_id! "consecutive_scope")
209209)
210+ (block
211+ "{" @append_space
212+ "}" @prepend_space )
210213
211214(val_closure
212215 (_) @append_begin_scope
213216 .
214217 (_) @prepend_end_scope @prepend_input_softline
215218 (#scope_id! "consecutive_scope")
216219)
220+ (val_closure
221+ "{" @append_space
222+ .
223+ (parameter_pipes)? @do_nothing
224+ )
225+ (val_closure "}" @prepend_space )
217226
218227;; control flow
219228(ctrl_if
268277 entry: _ @prepend_spaced_softline
269278)
270279
280+ ;; match_arm
271281(val_list
272- item: _ @append_space @prepend_spaced_softline
282+ item: _ @append_space
283+ .
284+ item: _ @prepend_spaced_softline
273285)
274286
275287(val_table
276288 row: _ @prepend_spaced_softline
277289)
278290
279291(val_record
280- entry: (record_entry) @append_space @prepend_spaced_softline
292+ entry: (record_entry) @append_space
293+ .
294+ entry: (record_entry) @prepend_spaced_softline
281295)
282296
283297(record_body
284- entry: (record_entry) @append_space @prepend_spaced_softline
298+ entry: (record_entry) @append_space
299+ .
300+ entry: (record_entry) @prepend_spaced_softline
285301)
286302
287303(collection_type
Original file line number Diff line number Diff line change @@ -12,20 +12,20 @@ for i in [1 2 3] {
1212alias ll = ls - l # alias comment
1313# where
1414ls | where $in.name == ' foo'
15- | where {|e | $e.item.name !~ $' ^($e.index + 1 )' }
15+ | where {|e | $e.item.name !~ $' ^($e.index + 1 )' }
1616# match
17- let foo = { name : ' bar' count : 7 }
17+ let foo = {name : ' bar' count : 7 }
1818match $foo {
19- { name : ' bar' count : $it } if $it < 5 => ($it + 3 ) # match arm comment
19+ {name : ' bar' count : $it } if $it < 5 => ($it + 3 ) # match arm comment
2020 # match comment
21- { name : ' bar' count : $it } if not ($it >= 5 ) => ($it + 7 )
22- _ => {exit 0 }
21+ {name : ' bar' count : $it } if not ($it >= 5 ) => ($it + 7 )
22+ _ => { exit 0 }
2323}
2424# while
25- mut x = 0 ; while $x < 10 {$x = $x + 1 }; $x # while comment
25+ mut x = 0 ; while $x < 10 { $x = $x + 1 }; $x # while comment
2626# loop
2727loop {
28- if $x > 10 {break };
28+ if $x > 10 { break };
2929 $x = $x + 1
3030}
3131# try
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ extern hi [
99]
1010# env
1111hide-env ABC
12- with-env { ABC : ' hello' } {
12+ with-env {ABC : ' hello' } {
1313 (
1414 do - i -- env {|foo , bar |
1515 print $env .ABC
Original file line number Diff line number Diff line change @@ -15,15 +15,15 @@ def modify_args_per_workspace [
1515 let icons = (
1616 aerospace list-windows -- workspace $sid -- json
1717 | from json | get app-name
18- | each {$in | get_icon_by_app_name }
18+ | each { $in | get_icon_by_app_name }
1919 | uniq | sort
2020 | str join ' '
2121 )
2222 let extra = (
2323 if $sid == $focused_sid {
24- { highlight : on border_color: $colors.green }
24+ {highlight : on border_color: $colors.green }
2525 } else {
26- { highlight : off border_color: $colors.fg }
26+ {highlight : off border_color: $colors.fg }
2727 }
2828 )
2929
@@ -56,14 +56,14 @@ def workspace_modification_args [
5656 # use listener's label to store last focused space id
5757 let focused_sid = (aerospace list-workspaces -- focused )
5858 let ids_to_modify = (
59- if ($last_sid | is-empty ) {(aerospace list-workspaces -- all | lines )}
59+ if ($last_sid | is-empty ) { (aerospace list-workspaces -- all | lines ) }
6060 else {
6161 [$focused_sid $last_sid ]
6262 }
6363 )
6464 $ids_to_modify
6565 | uniq
66- | each {modify_args_per_workspace $in $focused_sid }
66+ | each { modify_args_per_workspace $in $focused_sid }
6767 | flatten
6868 | append [" --set" $name $" label=($focused_sid )" ]
6969}
Original file line number Diff line number Diff line change 11use std assert
22
3+ def run_ide_check [
4+ file : path
5+ ] {
6+ nu -- ide-check 9999 $file
7+ | lines
8+ | each { $in | from json }
9+ | flatten
10+ | where severity? == Error
11+ | reject start end
12+ }
13+
14+ def str_repeat [
15+ char : string
16+ count : int
17+ ] {
18+ if $count < 1 { return ' ' }
19+ 1 .. $count | each { $char } | str join
20+ }
21+
22+ def print_progress [
23+ ratio : float
24+ length : int = 20
25+ ] {
26+ let done = ' ▓'
27+ let empty = ' ░'
28+ let count = [1 (($ratio * $length ) | into int )] | math max
29+ print - n (str_repeat $done $count ) (str_repeat $empty ($length - $count )) ($ratio * 100 | into string -- decimals 0 ) %
30+ }
31+
332# Test the topiary formatter with all nu files within a directory
433# each script should pass the idempotent check as well as the linter
534export def test_format [
@@ -8,22 +37,17 @@ export def test_format [
837] {
938 let files = glob $' ($path | str trim - r - c ' /' )/**/*.nu'
1039 let target = " ./test.nu"
11- for file in $files {
40+ let len = $files | length
41+ for i in 1 .. $len {
42+ let file = $files | get ($i - 1 )
43+ print_progress ($i / $len )
44+ print - n $" (ansi - e ' 1000D' )"
1245 try {
1346 cp $file $target
47+ let err_before = run_ide_check $target
1448 topiary format $target
15- let errors = nu -- ide-check 9999 $target
16- | lines
17- | each {$in | from json }
18- | flatten
19- | (
20- where severity? == Error
21- and message ? !~ ' ((File|Module|Variable) not found|Unknown command)'
22- )
23- if ($errors | length ) > 0 {
24- print $errors
25- }
26- assert (($errors | length ) == 0 )
49+ let err_after = run_ide_check $target
50+ assert ($err_before == $err_after )
2751 } catch {
2852 print $file
2953 if $break {
You can’t perform that action at this time.
0 commit comments