jiangmiao / auto-pairs

Vim plugin, insert or delete brackets, parens, quotes in pair
http://www.vim.org/scripts/script.php?script_id=3599
4.09k stars 373 forks source link

Omni completion of neocomplete support error #151

Open hanqing0521 opened 7 years ago

hanqing0521 commented 7 years ago

1. neocomplete support Omni completion for pythonn, and it complete functions with" (" but this auto-pairs do not complete this "(" by add ")"

2. If i have written a () than neocomplete complete a function with "(" , this auto-pairs will regard the next ")" as the "(" of neocompete completed fucntion"(".

johnzeng commented 5 years ago

It was opened 3 years ago but nothing seems change... facing same issue and I don't know how to improve it ....

zhixuan-lin commented 4 years ago

I find a simple fix for vim-mucomplete. It should also work for other auto-complete plugins that only inserts (

func! CondInsert()
    " Insert )\<Left> only if the previous character is not )
    let line = getline('.')
    let pos = col('.') - 2
    if strgetchar(line, pos) != char2nr(')')
        return ")\<Left>"
    endif
    return ""
endf

autocmd! CompleteDone * if has_key(v:completed_item, 'word') && v:completed_item.word =~# '($' 
                \| call feedkeys("\<C-R>=CondInsert()\<CR>")
                \| endif