File tree Expand file tree Collapse file tree 4 files changed +82
-4
lines changed Expand file tree Collapse file tree 4 files changed +82
-4
lines changed Original file line number Diff line number Diff line change 1010
1111## Status
1212
13- * Supposed to work well with all language features of nushell v0.106
13+ * Supposed to work well with all language features of nushell v0.107
1414 * Except for some known issues of ` tree-sitter-nu `
1515
1616> [ !NOTE]
@@ -124,6 +124,24 @@ cat foo.nu | topiary format --language nu
124124
125125</details >
126126
127+ ### Locally disable formatting for certain expression
128+
129+ If you don't like the formatted output of certain parts of your code,
130+ you can choose to disable it locally with a preceding ` Topiary: disable ` comment:
131+
132+ ``` nushell
133+ ...
134+ # Topiary: disable
135+ let foo = [foo, bar
136+ baz, ]
137+ ...
138+ ```
139+
140+ This will keep the let assignment as it is while formatting the rest of the code.
141+
142+ > [ !NOTE]
143+ > We do recommend reporting code style issues before resorting to this workaround.
144+
127145## Editor Integration
128146
129147<details >
Original file line number Diff line number Diff line change 1818 (path)
1919] @leaf
2020
21+ ;; TODO: new feature of the next topiary release
22+ ;; (unescaped_interpolated_content) @keep_whitespaces
23+
2124;; keep empty lines
2225(_) @allow_blank_line_before
2326
188191 (#scope_id! "consecutive_scope")
189192)
190193
194+ (val_closure
195+ (_) @append_begin_scope
196+ .
197+ (_) @prepend_end_scope @prepend_input_softline
198+ (#scope_id! "consecutive_scope")
199+ )
200+
191201(block
192202 "{" @append_space
193203 "}" @prepend_space
194204)
195205
206+ ;; HACK: temporarily disable formatting after special comment
207+ ;; abuse capture `@do_nothing` for the predicate
208+ (nu_script
209+ (comment) @do_nothing
210+ .
211+ (_) @leaf
212+ (#match? @do_nothing "Topiary: disable")
213+ )
214+
215+ (block
216+ (comment) @do_nothing
217+ .
218+ (_) @leaf
219+ (#match? @do_nothing "Topiary: disable")
220+ )
221+
196222(val_closure
197- (_ ) @append_begin_scope
223+ (comment ) @do_nothing
198224 .
199- (_) @prepend_end_scope @prepend_input_softline
200- (#scope_id! "consecutive_scope ")
225+ (_) @leaf
226+ (#match? @do_nothing " Topiary: disable ")
201227)
202228
203229(val_closure
Original file line number Diff line number Diff line change 1+ # Topiary: disable
2+ let foo = {}
3+
4+ {||
5+ # other comments
6+ let foo = 1
7+ # Topiary: disable
8+ let bar = 2
9+ }
10+
11+ module foo {
12+
13+ #Topiary: disable
14+ def should_not_be_formatted [] { }
15+
16+ def should_be_formatted [] { }
17+ }
Original file line number Diff line number Diff line change 1+ # Topiary: disable
2+ let foo = {}
3+
4+ { ||
5+ # other comments
6+ let foo = 1
7+ # Topiary: disable
8+ let bar = 2
9+ }
10+
11+ module foo {
12+
13+ #Topiary: disable
14+ def should_not_be_formatted [] { }
15+
16+ def should_be_formatted [] { }
17+ }
You can’t perform that action at this time.
0 commit comments