New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change all indentation from 3 spaces to 2 using findent #80
Conversation
@@ -283,11 +283,11 @@ subroutine divergence_v2p(self, div_u, u, v, w) | |||
! Interpolation for v field in x | |||
! Interpolation for w field in x | |||
call self%backend%tds_solve(du_x, u, self%xdirps, & | |||
self%xdirps%stagder_v2p) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here, I would expect the continuation from the parentheses, isn't this more common?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we can play with this parameter
--align_paren[=<n>]
align continuation lines not preceded
by '&' with preceding unmatched left parenthesis.
n=0, or flag omitted: do not align.
n=1: do align (default).
though the default should be do leave it as is
last_r = ffr(1) | ||
|
||
du(i, 1, b) = coeffs_s(1, 1)*u_s(i, 1, b) & | ||
+ coeffs_s(2, 1)*u_s(i, 2, b) & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be very confusing, very surprised fprettify findent allows this to be honest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again not visible here on the comment tab, but + coeff...
starts from all the way left with two spaces, however I would expect it to start from right below the previous variable after the =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I didn't see any way in the manual to indent continuation lines after a =
nor a ::
with findent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with ::
its not the end of the world, one can argue its better to follow findent way, but with +
I think things would get very confusing and hard to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am tempted to write a small script just to handle these tbh. This is pretty lacking indeed
@@ -1,37 +1,37 @@ | |||
module m_allocator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is also interesting, even the module declaration starts with two spacing. Is there a way to disable it? seems like a waste of two spaces to me. (Because its like +2 in every single line due to this)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the -I2
parameter, this can be removed
!! by calling the type bound procedure | ||
!! [[m_allocator(module):release_block(subroutine)]]. The | ||
!! released block is then pushed in front of the block list. | ||
module m_allocator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented on the wrong side and its actually not visible due to that. I mean the 2 spaces before module m_allocator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #80 (comment)
u_y, v_y, w_y, du_y, dv_y, dw_y, & | ||
u_z, w_z, dw_z | ||
u_y, v_y, w_y, du_y, dv_y, dw_y, & | ||
u_z, w_z, dw_z |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually everywhere but had to comment on a specific example. I would expect the continuation line to start aligned with the first variable like it used to be.
last_r = ffr(1) | ||
|
||
du(i, 1, b) = coeffs_s(1, 1)*u_s(i, 1, b) & | ||
+ coeffs_s(2, 1)*u_s(i, 2, b) & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commenting here just to show the actual change with spacing
case (RDR_Z2Y) | ||
dir_in = DIR_Z | ||
dir_out = DIR_Y | ||
case (RDR_X2Y) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another interesting point. case
is shifted only one space, not two, and also the lines inside the case
are shifted by one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one will be fixed by using --indent_select=4 --indent_case=2
yky(i) = yky(ny-i+2) | ||
eys(i) = eys(ny-i+2) | ||
yk2(i) = yk2(ny-i+2) | ||
yky(i) = yky(ny-i+2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like findent (at least with current settings) doesn't enforce anything between operators. (I think this particular line is not compatible with our current preference (spacing around -
and +
but no spacing around *
and /
) it would be nice if findent can identify and enforce a spacing based on our preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findent doesn't support modifying these things. It is really mainly doing indentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its actually good. Because fprettify is too restrictive with spacing around operators, and I don't really like it. For example, when passing a keyword argument to a function, I would rather not using spaces around =
, but of course prefer spaces around assingment =
normally. And fprettify can't tell them apart and want you to pick one and use it everywhere. Also with if
and allocate
. You may want space after if
, but no space after allocate
, but fprettify won't let you do this because it considers these two in the same group and the rule is defined for the whole group...
RDR_Y2X, 0, RDR_Y2Z, RDR_Y2C, & | ||
RDR_Z2X, RDR_Z2Y, 0, RDR_Z2C, & | ||
RDR_C2X, RDR_C2Y, RDR_C2Z, 0], shape=[4, 4]) | ||
RDR_Y2X, 0, RDR_Y2Z, RDR_Y2C, & |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is a good one to test findent. With the settings @Nanoseb recommended I would expect this line to start after the [
above. Curious to see what will happen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To my surprise, it does work:
integer, protected :: &
rdr_map(4, 4) = reshape([0, RDR_X2Y, RDR_X2Z, RDR_X2C, &
RDR_Y2X, 0, RDR_Y2Z, RDR_Y2C, &
RDR_Z2X, RDR_Z2Y, 0, RDR_Z2C, &
RDR_C2X, RDR_C2Y, RDR_C2Z, 0], shape=[4, 4])
With findent --align_paren=1 < common.f90
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great!
I would add
|
Is there any setting for alignment for multi-line assignments and for multi-line variable declarations? |
no, unfortunately I haven't seen anything about that in the help page |
to use in combination with findent
Because the main limitation of findent is line continuation after
|
using fprettify instead see #81 |
Used pip-installed findent 4.3.1 to change all indentation from 3 spaces to 2 using the following fish command: