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
Enhance Python syntax support #63
Comments
Thank you for the kind words :). How did you set up your python indentation? On my machine, this is how the code gets indented: some_function(a,
b,
c,
d,
e) The indentation of Also, regarding this formatting: some_function(
a,
b,
c,
d,
e,
) First off, notice that there's a difference with the previous one -- there's a newline after some_function(
a,
b,
c,
d,
e,
) What kind of settings do you have for python? Is it possible that you have an older version of Vim or something? Could you tell me the output of |
I'm having the "issue" (likely not the right word, as I feel the behavior is expected) on several platforms, with different Vim versions. On my Windows machine, my current version is:
I'm using python-syntax and vim-python-pep8-indent. Actually, after re-reading the Github page I realize the behavior I'm facing might be due to this last plugin. It tested without it and the behavior you describe seems to happen indeed. But I'm still afraid this way of splitting a function call is not PEP8 compliant. At this point, I'm not sure what's the best course of action: It feels to me that if splitjoin had a way of putting the first function call argument on the next line, the other plugin syntax would kick-in automatically and I would get the expected output. Is there a way to achieve this behavior ? If you are not willing to reflect that change/option in your repository, I wouldn't mind doing the change myself, but I may need some directions. What do you think ? |
I don't mind adding an option to put the first argument on the next line, I'll take a look at it tomorrow. |
I took a shot at the change and made a pull request for it (I actually made two commits but the github view only shows one for some reason). I did not add an option or anything so you may not want to merge it as-is at it will break the current behavior. I tested with the pep8 plugin I mentionned and it works like wonders ! Note: Your code base is really well organized and it was a breeze to change it. Kudos for that. Let me know if you plan to add the feature and if I can be of any help. Thanks again for the hard work. |
I've made the fixes in the master branch, I've added an option for python indentation. You'd need to put this in your vimrc: let g:splitjoin_python_brackets_on_separate_lines = 1 This should give you the indentation you want, combined with the pep8 indent plugin. Let me know whether it works for you or not. |
The change seems to do the trick for function calls (basically for lists, tuples, and everything similar) but it doesn't work for dicts. I basically get the following result:
What I should get is:
The thing is, PEP8 indentation actually takes care of shift left/right so no extra Thanks ! |
The problem is, if you don't have the plugin, you need the extra shifts :/. Here's the default Vim indentation if I just leave it to spam = {'spam': [1, 2, 3], 'spam, spam': 'eggs'}
spam = {
'spam': [1, 2, 3],
'spam, spam': 'eggs'
} And putting no quotes results in (something that's technically correct): spam = {spam: [1, 2, 3], eggs: 'eggs'}
spam = {
spam: [1, 2, 3],
eggs: 'eggs'
} The pep8 plugin might take care of both of these, but the built-in doesn't and I'd really like the plugin to work on its own, without additional extras :/. Arguably, the built-in logic might be broken/not good enough, but I'd still like to be compatible with it. I've committed a potential fix, could you try it out? It works okay for the built-in indentation (once you shift them in, running one more |
I'm hoping that my fix improved the situation, so for the time being, I'll close the issue. Feel free to reopen if you'd like to continue the discussion on how to set things up. |
The current behavior with Python does not seem to be configurable:
When using
gS
on a function call like:If get:
Which may be fine for some people, but the default Python syntax I get when I type the line-endings manually gives me:
Is there a way to use the default syntax rules configured by the user to get the output I expect ?
Thanks for the good work !
The text was updated successfully, but these errors were encountered: