Closed albertosantini closed 11 years ago
I cannot reproduce the issue in my vim 7.3.409. what's the cinoptions? and I'm afraid it's indent script's bug. indent script should be always correct when trying indent current line.
Here the stock 7.3.46.
If I use stock settings for javascript, I mean default cinoptions and cindent, I get the first indentation.
set cinoptions?
cinoptions=j1, J1
set cindent?
cindent
Setting cindent to nocindent I get the second one. Indeed I set in my _vimrc
set nocindent
So far way it is ok.
When I install auto-pairs and type
{<CR>
I get the second case.
Same settings here.
// cindent
function () {
var foo = {
bar: {
} // What's the result when press == or =k at this line in normal mode?
}
}
the empty line between bar: {
and }
is removed.
Maybe the different result it is due to another settings.
set autoindent
set smartindent
Then I have a mapping:
inoremap <buffer> {<cr> {<cr>}<Esc>O
Of course when I try auto-pairs, I comment out the above mapping.
So in my configuration, when I type {<cr>
, I get the correct, for me, indentation.
Pressing == or =k at this line in normal mode I transform:
function () {
var foo = {
bar: {
} // ok with my settings and mapping
}
}
to
function () {
var foo = {
bar: {
} // with auto-pairs or pressing ==
}
}
Anyway I am available to any change in my configuration to achieve that result.
Thanks for the support.
I'm sorry I think I won't fix this issue.
==
behaviour is not part of auto-pairs. It means indent current line. you could try ==
without auto-pairs
and your setting, you will get the same result. the indent should be always correct when trying ==
, and for most of situation
foo({|}).bar()
press <CR>
at |
will cause incorret indentation.
btw: maybe you could try better javascript indenter, https://github.com/jiangmiao/simple-javascript-indenter it should be always indent correctly. and the BriefMode is recommanded.
I believe we have similar problems. Check out my fix on #85
In javascript with nocindent, the indentation is "wrong".
Firstly without auto-pairs plugin:
With auto-pairs and nocindent the result is like setting cindent.
I think it is due to '=ko' in line 369:
https://github.com/jiangmiao/auto-pairs/blob/master/plugin/auto-pairs.vim#L369
Any thought?
Thanks in advance, Alberto