Shougo / neocomplcache.vim

Ultimate auto-completion system for Vim.
http://www.vim.org/scripts/script.php?script_id=2620
1.72k stars 135 forks source link

work around neocomplcache#mappings#complete_common_string() #472

Closed Isaac0616 closed 10 years ago

Isaac0616 commented 10 years ago

I'm trying to write some mapping like

inoremap <expr><TAB> pumvisible() ? (empty(neocomplcache#complete_common_string()) ? "\<C-n>" : neocomplcache#complete_common_string()) : "\<TAB>"

to use tab to both complete common string and choose next candidate But it didn't work originally So, I look into neocomplcache#mappings#complete_common_string() source code

I don't really know how to write vim script However, I'm wondering is it any problem to add something like

  if len(complete_str) == len(common_str)
      return ''
  endif

before

  return (pumvisible() ? "\<C-e>" : '')
        \ . repeat("\<BS>", len(complete_str)) . common_str

I think it can let my mapping work out and change the behavior of calling neocomplcache#mappings#complete_common_string() twice (If I call the function twice, it will complete common string and close the popup menu originally After adding the code, it will still complete common string but keep menu open)

Shougo commented 10 years ago

No. You should not call neocomplcache#mappings#complete_common_string() twice. I don't want to change neocomplcache code.

Shougo commented 10 years ago

I improved neocomplete#mappings#complete_common_string() behavior. You should use neocomplete.