Avoid indentation within `@testitem` blocks
gdalle opened this issue · comments
The new test item framework in VSCode allows you to specify standalone tests that can be executed independently. However, since they are typically pretty long, it would be nice to avoid indenting them (as is done eg. for module
blocks). What do you think? Is that a difficult change?
Probably similar effort to https://github.com/domluna/JuliaFormatter.jl/pull/489/files
similar to #707
generalizing the module indent option to user patterns might be worth it
Are there any plans to support such a feature that allows to disable indentation for certain macros (I am affiliated to #707)? This is essentially the only thing blocking us from using JuliaFormatter for Trixi.jl right now, since we have a lot of code wrapped in @muladd begin ... end
that should not be indented.
Of course I am aware that everyone's time / resources are extremely limited, thus I just wanted to kindly asks if there are any plans (or if I better not hold my breath).
Alternatively, would it be hard to support? AFAICT, macros are essentially formatted as functions, thus a simple solution (in terms of usability) could be to allow specfying a list of function/macro names that should not be indented.
EDIT: I think I read the wrong section: macro
is for macro definitions. What we really want is not clear to me, since also macrocall
does not seem to be the right place.
maybe adding a comment so something along the lines of
@muladd begin
# fmt: dedent
code here is not indented
end
i think this should be fairly easy to add since in print.jl you can check if the comment has that before printing the indent
i think this should be fairly easy to add since in print.jl you can check if the comment has that before printing the indent
This sounds like an interesting and comparably portable approach. However, I am not sure into which function I would have to look - print_inlinecomment
does sound correct, but it is not clear to me how and where the indent size is modified.
https://github.com/domluna/JuliaFormatter.jl/blob/master/src/print.jl#L49-L97
the check part is
ws = repeat(" ", max(indent, 0))
i think adding another keyword argument would be sufficient. defaults to false and would be true if the NOTCODE node contains the string we're looking for
format: deindent
or "noindent" ?
ehh we can bikeshed that later
occursin(r"^#!\sformat\s:\sdeindent\s$", n.val) would capture it
#! format: deindent
I'll tackle this tonight
I'll tackle this tonight
That would be fantastic, thanks a lot 🙏
FWIW, I think from a user perspective, noindent
is clearer, since what the user (presumably) thinks is "I put this here to get no indentation, ie, noindent". But either keyword is fine, really.
@domluna please let me know if you need someone to testdrive anything...
this is possible now with #724
thanks!