Git Product home page Git Product logo

Comments (13)

tweekmonster avatar tweekmonster commented on May 22, 2024 1

@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.

tweekmonster avatar tweekmonster commented on May 22, 2024

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.

jperras avatar jperras commented on May 22, 2024

@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.

tweekmonster avatar tweekmonster commented on May 22, 2024

@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.

jperras avatar jperras commented on May 22, 2024

@tweekmonster will do! Thanks for the docs on it; my vimscript is lackluster. I'll report back shortly.

from braceless.vim.

tweekmonster avatar tweekmonster commented on May 22, 2024

@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.

jperras avatar jperras commented on May 22, 2024

@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.

tweekmonster avatar tweekmonster commented on May 22, 2024

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.

jperras avatar jperras commented on May 22, 2024

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:

crappy image

Sorry for all the trouble – I must be doing something wrong!

from braceless.vim.

tweekmonster avatar tweekmonster commented on May 22, 2024

@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.

tweekmonster avatar tweekmonster commented on May 22, 2024

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.

jperras avatar jperras commented on May 22, 2024

@tweekmonster that did it – thanks! A big πŸ‘ from me.

from braceless.vim.

tweekmonster avatar tweekmonster commented on May 22, 2024

@jperras Cool. Will be merging into master in a few minutes. πŸŽ‰

from braceless.vim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.