Comments (8)
Thanks for the good work !
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 b
, c
, and so on is simply two shiftwidths, each of which is 4 spaces. I'm not sure how your indentation ended up like that.
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 (
. More importantly, though, for me, if I select these lines in visual mode and run =
(or, if I type it manually), I get:
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 vim --version
?
from splitjoin.vim.
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:
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2014 08:07:47)
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 ?
from splitjoin.vim.
I don't mind adding an option to put the first argument on the next line, I'll take a look at it tomorrow.
from splitjoin.vim.
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.
from splitjoin.vim.
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.
from splitjoin.vim.
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:
a = {1: 2, 3: 4, 5: 6}
a = {
1: 2,
3: 4,
5: 6
}
What I should get is:
a = {
1: 2,
3: 4,
5: 6,
}
The thing is, PEP8 indentation actually takes care of shift left/right so no extra <<
or >>
should be done in this case.
Thanks !
from splitjoin.vim.
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 ==
doesn't change indentation), and I think it should work just fine for the pep8-plugin one.
from splitjoin.vim.
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.
from splitjoin.vim.
Related Issues (20)
- YAML splitting flow-object with path as value fails to round-trip from joining HOT 3
- Feature request: Add solidity support HOT 1
- Feature request: "black" compatible python line-splitting HOT 3
- Feature request: Add Scala support HOT 3
- Rust: grouped multiline imports do not split correctly HOT 4
- Rust: attributes on grouped imports are not preserved HOT 10
- Adding splitjoins from one langage to another HOT 9
- Unexpected modifications when using `gS` / `gJ` HOT 1
- Python splitting and indentation HOT 2
- Feature request: Splitting LaTeX commands onto newlines HOT 1
- Can't work in visual after changing keymap HOT 2
- Rust: splitting multi-line expression into blocks produces broken code HOT 7
- Go: can't split/join var, const, type declarations inside block (not global scope) HOT 2
- Go: can't split/join var, const declarations with comma-separated one-typed vars, consts HOT 15
- Go: invalid join for var, const, import list HOT 11
- Go: join of struct fields inserts unnecessary spaces HOT 7
- Support for rmardown (rmd) and quarto (qmd) HOT 2
- Go: split of multiline var, const adds brackets in wrong place HOT 2
- vim: gS on dict access dot incorrectly adds space HOT 3
- Add support for R HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from splitjoin.vim.