Comments (13)
@jperras I pushed a branch that gives some options to override the indentation you mentioned. Would you mind trying it out and giving some feedback on it?
from braceless.vim.
Thanks π
If you leave off +indent
in the BracelessEnable
command, it will let the builtin Python indent handler take over. Unfortunately, that also disables the contextual indentation for blocks.
May I ask what your company's guidelines are regarding indentation? Depending on how not-weird it is, I could probably make it customizable for compliance. I'm in the middle of adding auto-formatting that will wrap block lines as you type, so your input could be significant for this.
from braceless.vim.
@tweekmonster right, the contextual indentation for blocks is something I'd like to keep.
So, the indentation rules are almost identical to the PEP8 indentation rules, except the following:
foo = long_function_name(var_one, var_two,
var_three, var_four)
The problem that occurs with something like that is that it's very easy to end up jutting against the righthand 80/100 cols margin. Instead, we expect the following:
foo = long_function_name(var_one, var_two,
var_three, var_four)
which is somewhat hilariously explicitly disallowed in the PEP8 styleguide I linked. This example is also more in line with how you would perform the same operation for conditional if
statements, e.g.:
# No extra indentation.
if (this_is_one_thing and
that_is_another_thing):
do_something()
of course, this example is somewhat coincidental with the fact that if (
is exactly 4 characters long, meaning that the continuation line is perfectly aligned at all times. I guess we simply prefer the visual symmetry in having our overly-long conditional statements indented in the same visual manner as our overly long arguments to callables.
β¦ the more I explain this, the more I realize that providing the hooks to make something like this customizable must be a complete pain in the butt. If you'd rather not go down that road, I'd completely understand!
from braceless.vim.
@jperras Nah, company coding standards are what they are for a reason regardless of how silly they seem. I don't have a mission statement for this plugin, but my overall goal is to enhance and not break the workflow. So, I'll leave this issue open until I find some time to add finer control over the indentation rules.
I know this plugin can be a little confusing, but if you just want to hack it to get it working in the meantime, take a look at this function: https://github.com/tweekmonster/braceless.vim/blob/master/autoload/braceless/python.vim#L31
The first two if
statements deal with if
and def
blocks, respectively. The third deals with function calls (solid text followed by parenthesis). What you can do is take the return values and adjust them. As long as that function returns a value greater than -1, Braceless's fallback indent won't take over. a:col_head[0]
is the line the open parenthesis is on, and a:col_head[1]
will be the position where the open parenthesis starts.
from braceless.vim.
@tweekmonster will do! Thanks for the docs on it; my vimscript is lackluster. I'll report back shortly.
from braceless.vim.
@jperras I hope you were able to have happy good time fun with the custom settings. Is this good to go?
I was also wondering if you've come across any coding guidelines that treat lists, tuples, and dicts differently from what PEP8 suggests.
from braceless.vim.
@tweekmonster pardon the delay!
So, I switched to the indent-configure
branch and attempted to set the specified configurations:
let g:braceless_cont_call = 1
but it didn't seem as though anything changed. I then tried to change the indent level to 2
and 0
and -1
both in execute mode and within the configuration file, but I didn't notice a change in behaviour.
What am I messing up?
from braceless.vim.
g:braceless_cont_call
is for functions calls, e.g. x = somefunc()
since they're regarded differently in PEP8 from block statements. Did you set g:braceless_cont_block
to 1 as well? That's for things like def somefunc(args):
or if (grouping):
from braceless.vim.
I set both of those to 1
. No errors on startup, and I verified that the variables are loaded in the current session by checking their value in execution mode, but still no dice βΒ it still indented to the opening paren:
Sorry for all the trouble βΒ I must be doing something wrong!
from braceless.vim.
@jperras Thanks. It looks like I missed a part of the solution. Break the line at the opening parenthesis and it should drop to the correct level. I'll look into this.
Are block indents correct?
from braceless.vim.
I just updated the branch. It should correct that indent example you gave.
Sorry for all the trouble β I must be doing something wrong!
Also enough of that! VimL is pretty confusing and sometimes terrible, and I'm mixing it with imaginary Python block boundaries. Mistakes will be made and people will get hurt from time to time. No big deal.
from braceless.vim.
@tweekmonster that did it β thanks! A big π from me.
from braceless.vim.
@jperras Cool. Will be merging into master in a few minutes. π
from braceless.vim.
Related Issues (20)
- Is it possible to tune dedenting by Enter key? HOT 4
- <CR> not working HOT 5
- E132: Function call depth is higher than 'maxfuncdepth' HOT 6
- Bad fold interaction with sessions HOT 1
- Custum popup handling for <cr> mapping HOT 3
- GVim window view moving on `o` or `O` with option +indent HOT 1
- Removal of whitepsace surround operators on 'J'oin lines HOT 5
- g] doesn't work? HOT 5
- Jumping between classes? HOT 7
- Losing backslash and double quotes when joining two lines together HOT 3
- Incorrect auto-indenting after decorator line? HOT 4
- braceless make "o" in normal node very slow HOT 10
- zf is unconditionally mapped to a notification HOT 4
- Found a pathological case for indenting HOT 3
- Feature Request: Highlight Toggle
- Incorrectly adds \ at end of line
- No auto-indent for coroutines HOT 2
- BracelessEnable in ftplugin works but raises error while opening files HOT 1
- help conflict : need fixing help tag; that change to plugin-prefix using HOT 4
- All sorts of problems with `o` command
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 braceless.vim.