Townk / vim-autoclose

This plugin for Vim enable an auto-close chars feature for you. For instance if you type an '(', ``autoclose`` will automatically insert a ')' and put the cursor between than.
http://townk.github.com/vim-autoclose/
503 stars 66 forks source link

bash indent #35

Closed ofdrykkja closed 12 years ago

ofdrykkja commented 12 years ago

when i type:

function foo {

then press enter, i got 4 extra whitespace

function foo {
........|
....}

please fix it

Townk commented 12 years ago

Are you sure this is Autoclose problem?

If you remove Autoclose what happen when you do a { and press enter? The cursor is posicioned on the 4th ot 8th column?

ofdrykkja commented 12 years ago

without Autoclose i don't have this problem:

function foo {
....|

also i trying remove all plugin without Autoclose and i got same problem

ofdrykkja commented 12 years ago

i added checker to function s:Enter() for "smartindent" and all worked


function! s:Enter()
    if has_key(b:AutoClosePumvisible, 'ENTER') && pumvisible()
        let b:snippet_chosen = 1
        return b:AutoClosePumvisible['ENTER']
    elseif b:AutoCloseOn && s:IsEmptyPair() && stridx( b:AutoCloseExpandEnterOn, s:GetPrevChar() ) >= 0
        if has("smartindent")
            return "\<CR>\<Esc><<O"
        else
            return "\<CR>\<Esc>O"
        endif
    endif
    return "\<CR>"
endfunction
Townk commented 12 years ago

Do you use many vim plugins? What is your vimrc configuration for smartindent, cinwords, etc.? Your code might break indent for other languages.

ofdrykkja commented 12 years ago

as I said above, I tried to remove all plugins leaving Autoclose but the problem still exists. your plugin breaks indent because my .vimrc contains "set smartindent". I've checked my fix on Java and Javascript files and everything is OK. can you tell me why my fix can be broken in other languages?

Townk commented 12 years ago

I'm not sure about anything yet. On my vim I set smartindent and the problem you reported doesn't exists. Than if I put your fix the "<<" "unindent" the code.

As I said, I'm not sure about anything yet. I'll try more things tonight to see if I can get your problem. BTW, can you send me your vimrc file?

ofdrykkja commented 12 years ago

i send my .vimrc on your email

Townk commented 12 years ago

Thanks, I'll check it when I get home tonight

ofdrykkja commented 12 years ago

this problem solved, after reinstalling all plugins with vundle plugin