Skip to content

Chained methods are indented #514

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

Closed
jeremija opened this issue Jun 27, 2016 · 16 comments
Closed

Chained methods are indented #514

jeremija opened this issue Jun 27, 2016 · 16 comments

Comments

@jeremija
Copy link

Hi there,

It looks like PR #385 broke the way I'm used to write chained function calls:

db.fetch()
.then(doSomething)
.then(doSomethingElse);

Instead, it's now forcing an indent:

db.fetch()
    .then(doSomething)
    .then(doSomethingElse);

Is there an easy way to bring back the old behavior without checking out an old commit before the PR?

Thanks!

@bounceme
Copy link
Collaborator

#467

@cireric
Copy link

cireric commented Jun 28, 2016

HI,
I also have this problem
current (master & develop) when I write React component

<Abc className="xxx" data={this.props.data}>
    <Def 
      className="yay"
    />
</Abc>

instead, when indent Component property, it will be

<Abc className="xxx" data={this.props.data}>
<Def
className="yay" />
</Abc>

when I use 8c56957, it no problem

@amadeus
Copy link
Collaborator

amadeus commented Jul 15, 2016

This should all be fixed in develop

@amadeus amadeus closed this as completed Jul 15, 2016
@bounceme
Copy link
Collaborator

#566

@JetFault
Copy link

What config options needs to be set to not indent chained funcitons?

@bounceme
Copy link
Collaborator

https://github.com/pangloss/vim-javascript#indentation-specific .
though see if the behaviour on develop is preferable for you first (there were some small changes with operators)

@tribou
Copy link

tribou commented Sep 18, 2016

For anyone searching and finding this issue, I was able to disable indenting chained methods with this new config variable:

let g:javascript_opfirst = 1

@bounceme
Copy link
Collaborator

the reason i removed the documentation for them^^. probably a better idea to change that to '' unless you want to indent when a line starts with 1

@tribou
Copy link

tribou commented Sep 18, 2016

@bounceme I tried using let g:javascript_opfirst = '', but it caused the indentation to continue.

@bounceme
Copy link
Collaborator

true, that is a terrible suggestion, '' matches everything.

@bounceme
Copy link
Collaborator

Anyway, this issue is about chained functions, so suggesting a change to an option which removes indenting for all operators isn't helpful.

@bounceme
Copy link
Collaborator

just to clarify, this is a regex option

@tribou
Copy link

tribou commented Sep 19, 2016

Ah ok, thank you for clarifying. In that case, which indentation option would apply to chained functions? When I check the help from the link above, the cino-: section references switch statements.

@bounceme
Copy link
Collaborator

I removed the options from the readme as they are very complicated to get right. just remove the dots in these regexes https://github.com/pangloss/vim-javascript/blob/develop/indent/javascript.vim#L70

@tribou
Copy link

tribou commented Sep 19, 2016

Thanks for your patience with this issue. I tried removing the dots by setting these in my .vimrc:

let g:javascript_opfirst = '\%([<>,?^%|*&]\|\/[^/*]\|\([-:+]\)\1\@!\|=>\@!\|in\%(stanceof\)\=\>\)'
let g:javascript_continuation = '\%([<=,?/*^%|&:]\|+\@<!+\|-\@<!-\|=\@<!>\|\<in\%(stanceof\)\=\)'

However, it's still indenting chained functions.

@bounceme
Copy link
Collaborator

those work for me, maybe a issue with your vimrc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants