spf13 / spf13-vim

The ultimate vim distribution
http://vim.spf13.com
Apache License 2.0
15.56k stars 3.63k forks source link

<esc> is not exiting insert mode when neocomplete dropdown is open #775

Open MuschPusch opened 9 years ago

MuschPusch commented 9 years ago

See this thread in neocomplcache: https://github.com/Shougo/neocomplcache.vim/issues/350#issuecomment-12708564

Even though it's neocomplcache the issue is the same and removing this line would fix it:

https://github.com/spf13/spf13-vim/blob/aaefac8f98e0f4e247836c7f295d3deecd28f88b/.vimrc#L489

Acanthostega commented 9 years ago

I don't know if the problem is related, but the same thing happens with YouCompleteMe. I have to double escape when the completion is showing in order to be able to leave insert mode. Removing the new plugin auto-pairs and switching again to vim-autoclose solved the problem if someone is in the same situation.

MuschPusch commented 9 years ago

Removing auto-pairs didn't worked for me but i didn't switched to vim-autoclose

JoveYu commented 9 years ago

same error here, back to autoclose work well https://github.com/spf13/spf13-vim/issues/769

gravis commented 9 years ago

+1, this is very annoying :( Removing the line solved the issue for me. thanks

gravis commented 9 years ago

auto-pairs will also make go editing a real pain

return SomeStruct{|
}

if the cursor is | and I type }, the cursor will just go to the closing } on the line bellow...

rbgarga commented 9 years ago

+1, this is really annoying

DevManChris commented 9 years ago

+1 Very annoying

rafaponieman commented 9 years ago

+1 @MuschPusch 's fix (at least temporarily fixed it), but this is a very annoying usability problem

gravis commented 9 years ago

Any news on this?

rafaponieman commented 9 years ago

I correct myself in the previous message, this @MuschPusch's fix is not working for me.

What happens is: When inserting, if Neocomplete hasn't been triggered (inserting at the end of any line, for example), esc key instantly quits exit mode, that works fine. However, when Neocomplete is triggered, and esc is pressed, there's a 1 second delay, then autocomplete closes, but instantly it goes back into insert mode and autocomplete opens again. The only way to avoid this is to press many times the esc key until neocomplete doesn't show up anymore, which is a really big problem for us programmers.

rafaponieman commented 9 years ago

Well, this is weird... correcting myself, again. But this time I solved it, and I got my vim to run really well. What I did was implement @MuschPusch's fix, which does work for me, and also added this, which removed that 1 second lag I was experiencing:

set timeoutlen=10 ttimeoutlen=0
mightyiam commented 9 years ago

:+1:

gravis commented 9 years ago

Doesn't work for me :(

wsdjeg commented 9 years ago

i just use this to select my choice

inoremap <cr> <esc>a 
gravis commented 9 years ago

@rafadev does NERDCommenter still works for you? With set timeoutlen=10 ttimeoutlen=0 it doesn't here :(

wsdjeg commented 9 years ago

hi @gravis i do not use any plugin but just add some func: here is my config for ( ,[ ,{ ,},],)

inoremap ( ()<Esc>i
inoremap [ []<Esc>i
inoremap { {}<Esc>i
autocmd Syntax java inoremap { {<CR>}<Esc>O
autocmd Syntax html,vim inoremap < <lt>><Esc>i| inoremap > <c-r>=ClosePair('>')<CR> |inoremap " "
inoremap ) <c-r>=ClosePair(')')<CR>
inoremap ] <c-r>=ClosePair(']')<CR>
inoremap } <c-r>=ClosePair('}')<CR>
autocmd Syntax java inoremap } <c-r>=CloseBracket()<CR>
inoremap " <c-r>=QuoteDelim('"')<CR>
inoremap ' <c-r>=QuoteDelim("'")<CR>
function ClosePair(char)
    if getline('.')[col('.') - 1] == a:char
        return "\<Right>"
    else
        return a:char
    endif
endf

function CloseBracket()
    if match(getline(line('.') + 1), '\s*}') < 0
        return "\<CR>}"
    else
        return "\<Esc>j0f}a"
    endif
endf

function QuoteDelim(char)
    let line = getline('.')
    let col = col('.')
    if line[col - 2] == "\\"
        "Inserting a quoted quotation mark into the string
        return a:char
    elseif line[col - 1] == a:char
        "Escaping out of the string
        return "\<Right>"
    else
        "Starting a string
        return a:char.a:char."\<Esc>i"
    endif
endf
au filetype java inoremap <silent> <buffer> } <C-r>=JavaCloseBracket()<cr>
function JavaCloseBracket()
    let line = getline('.')
    let col = col('.')
    if line[col - 2] == "\\"
        "Inserting a quoted quotation mark into the string
        return "}"
    elseif line[col - 1] == "}"
        "Escaping out of the string
        return "\<Right>"
    elseif match(getline(line('.') + 1), '\s*}') < 0
        return "\<CR>}"
    else
        return "\<Esc>j0f}a"
    endif
endf
rafaponieman commented 9 years ago

@gravis Hey! Sorry for the delay... No, it doesn't work any more, I didn't notice cause I wasn't using it... I think my setting just kills the timeout after pressing leader... any clues?

gravis commented 9 years ago

nope, I'm stil fighting with this, it's very annoying. I ended up with hitting esc 3-4 times, but it's a waste of time.

wsdjeg commented 9 years ago

hi @gravis what func do you want ,i think i can help you

rbgarga commented 9 years ago

I gave up spf13, moved to a simple installation with a few bundles, including YouCompleteMe, everything back to work now...

gravis commented 9 years ago

I think I'll do the same this week-end :(

gravis commented 8 years ago

9af9ba73cfca2d586ae6436208581379bffc22de seems to fix this!