-
Notifications
You must be signed in to change notification settings - Fork 137
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
Add auto-alignment of class definition with tabular #86
base: master
Are you sure you want to change the base?
Conversation
Upd: the previous version has a bug with Here updated test:
|
I realized that it is possible to process the alignment of '=>' blocks in the same function. I'll try to do it nicely. |
a28915d
to
3abb237
Compare
Right now everything works smoothly. And again, class for tests:
|
I've tested this both with the provided example and some other manifest I have and it's working nicely! it realigns the text when you press enter after having modified a line that needs realigning and aligns parameters after their type, too. Also it's fast at doing its job: if you end up realigning more than 10 lines there's no delay in doing so. However it does not perform the realigning if you just open edition on a line (or just backspace to the end of the previous line while in edition mode) and press enter, and it also doesn't perform realignment if there are trailing spaces. I don't know if it's a limitation of the integration with tabular.. I do like this changeset though, it'll save me from having to call "Tabularize /=>" so many times Here's an idea: could this tabular integration also be called when the '=' command is used to fix indentation? |
Hi. Thank you for the feedback, @lelutin . About other things:
|
mapping to is really nice in terms of usability :) also, thanks for the explanation about not being possible to apply filtering with the '=' operator. I've just found a small bug though: with the following example:
if I open insert mode and press Enter at the end of any line that declares a parameter (see position of
it would be nicer if the commas didn't get moved. |
Thanks, nice catch |
nice thanks your last commit fixes moving commas. I found another quirk though. with a slightly different example this time (now the arguments without an equal sign are longer than the ones with one):
With the cursor at the end of a line of argument as shown above, if you press enter, the equal signs get moved all the way to the right of the longest argument without an equal sign, thus creating an awkward space like this:
|
But this is by design. We have three columns (type, argument, default value after
You could try here on (at least at current moment =) ) the full example. BTW, I found another one case, which wasn't covered, when class definition hadn't leading spaces. |
hmm there's another strangeness going on: in an empty file if I write this on the top level (not contained in anything):
the '=' gets moved uselessly by one space to the right:
Also, if I remove the additional space, and then write something on the line just below and press enter:
then the '=' on the line for $variable1 gets moved to the right once again:
|
if I git checkout 6b49440 to remove the patch that had to do with parameters without a leading space then something similar is happening but instead of moving the '=' to the right, it's getting pushed left so that there's no space between $variable1 and the '=':
|
Thanks, also fixed. Realy nice catch! |
And furthermore, this example looks ugly without last commit
|
Hello @rodjek |
Found another bug. example:
|
hello! commit ceb00c6 breaks a bunch of use cases since it only does anything if the first line is defining a class.. e.g. what about defined types? when there's one or more comment line(s) at the top of the file, which is common and recommended, then nothing happens. if there's one or more empty lines above the class definition then nothing happens. hash definitions at the top level don't get realigned either (for example if I'm editing a "default.pp" file for use with vagrant, I'll be editing stuff at the top level, not inside a class definition) |
@lelutin after some using of current configuration with I haven't idea right now how to do it properly. Tabular doesn't allow to use any of About last changes - yeah, there a lot of errors. As I said, I mentioned the bug on this example and tried to fix it. Maybe, as a workaround, I could remove from first lines comments line by line until the Could you provide broken examples for tests? |
here are examples:
|
hmm ctrl+a is by default used by vim for incrementing a number. the new mapping causes a clash there |
heh, no =)
|
Well, all examples work fine with |
I added proper Vader tests during the last rebasing. |
Hello.
I added automatical alignment of class definition with tabular plugin.
You could test it with next example:
I'll be happy to help if you'll have any questions