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

What am I missing here? #466

Closed kshenoy closed 10 years ago

kshenoy commented 10 years ago

I'm trying to move from OmniCppComplete to Neocomplcache (The vim at work doesn't have if_lua, so I can't use Neocomplete). OmniCppComplete works with this setup but Neocomplcache doesn't.

For eg. typing a '.' or '->' after an object name doesn't show the methods of that class. Can you please tell me what am I missing here?

This is my entire vim setup. I started with a clean vimrc to eliminate the effect of any other plugin.

"  .vimrc
set nocompatible
filetype plugin indent on
syntax on

"Note: This option must set it in .vimrc(_vimrc).  NOT IN .gvimrc(_gvimrc)!
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplcache.
let g:neocomplcache_enable_at_startup = 1
" Use smartcase.
let g:neocomplcache_enable_smart_case = 1
" Set minimum syntax keyword length.
let g:neocomplcache_min_syntax_length = 3
let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'

" Enable heavy features.
" Use camel case completion.
"let g:neocomplcache_enable_camel_case_completion = 1
" Use underbar completion.
"let g:neocomplcache_enable_underbar_completion = 1

" Define dictionary.
let g:neocomplcache_dictionary_filetype_lists = {
    \ 'default' : '',
    \ 'vimshell' : $HOME.'/.vimshell_hist',
    \ 'scheme' : $HOME.'/.gosh_completions'
        \ }

" Define keyword.
if !exists('g:neocomplcache_keyword_patterns')
    let g:neocomplcache_keyword_patterns = {}
endif
let g:neocomplcache_keyword_patterns['default'] = '\h\w*'

" Plugin key-mappings.
inoremap <expr><C-g>     neocomplcache#undo_completion()
inoremap <expr><C-l>     neocomplcache#complete_common_string()

" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
  return neocomplcache#smart_close_popup() . "\<CR>"
  " For no inserting <CR> key.
  "return pumvisible() ? neocomplcache#close_popup() : "\<CR>"
endfunction
" <TAB>: completion.
inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
inoremap <expr><C-y>  neocomplcache#close_popup()
inoremap <expr><C-e>  neocomplcache#cancel_popup()
" Close popup by <Space>.
"inoremap <expr><Space> pumvisible() ? neocomplcache#close_popup() : "\<Space>"

" For cursor moving in insert mode(Not recommended)
"inoremap <expr><Left>  neocomplcache#close_popup() . "\<Left>"
"inoremap <expr><Right> neocomplcache#close_popup() . "\<Right>"
"inoremap <expr><Up>    neocomplcache#close_popup() . "\<Up>"
"inoremap <expr><Down>  neocomplcache#close_popup() . "\<Down>"
" Or set this.
"let g:neocomplcache_enable_cursor_hold_i = 1
" Or set this.
"let g:neocomplcache_enable_insert_char_pre = 1

" AutoComplPop like behavior.
"let g:neocomplcache_enable_auto_select = 1

" Shell like behavior(not recommended).
"set completeopt+=longest
"let g:neocomplcache_enable_auto_select = 1
"let g:neocomplcache_disable_auto_complete = 1
"inoremap <expr><TAB>  pumvisible() ? "\<Down>" : "\<C-x>\<C-u>"

" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags

" Enable heavy omni completion.
if !exists('g:neocomplcache_omni_patterns')
  let g:neocomplcache_omni_patterns = {}
endif
let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
let g:neocomplcache_omni_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)'
let g:neocomplcache_omni_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::'

" For perlomni.vim setting.
" https://github.com/c9s/perlomni.vim
let g:neocomplcache_omni_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
Shougo commented 10 years ago

let g:neocomplcache_omnipatterns.cpp = '[^.[:digit:] \t]\%(.|->)|\h\w_::'

You should use g:neocomplcache_force_omni_patterns instead of g:neocomplcache_omni_patterns.

ghost commented 10 years ago

Shougo, Thanks for this, I have spent the last two days struggling with this also. Perhaps the readme needs updating?

I know NeoComplete seems to be the preferred engine these days, but NeoComplCache works in vanilla environments which makes it very useful still. Plus machines are getting faster, so NeoCompleCache works just fine on my laptop. Those of us using Neovim also can use it now even though Neovim has neither python for YCM or Lua for Neocomplete.

When you update the readme, perhaps you could include omnicomplete regexs for GoLang, Python, & Java, as those are my most used languages these days. Thanks for all your good efforts toward making Vim completion smooth and reliable. Dave

Shougo commented 10 years ago

Pull request is wellcome. But I don't use neocomplcache, so I don't want to change it.

Those of us using Neovim also can use it now even though Neovim has neither python for YCM or Lua for Neocomplete.

I need if_lua interface in neovim...

ghost commented 10 years ago

Shougo, Thank you for responding. I had no idea NeoComplCache is unsupported...... It seems that no plugin can provide a good universal completion experience. I use NeoComplCache as a fallback, with minimal dependencies. It works on any of the machines I use, neovim included.

After posting my questions above, I visited the Eclim website page which concerns Java. I see they recommend the following setup:

let g:EclimCompletionMethod = 'omnifunc'

if !exists('g:neocomplcache_force_omni_patterns') let g:neocomplcache_force_omni_patterns = {} endif let g:neocomplcache_force_omni_patterns.java = '\k.\k*'

I have included these lines and they have helped a lot for Java. For Go, for the moment, I am using the regex for CPP and it seems to work fine so far. So I seem to be able to use NeoComplCache for Java, Go, Python, and of course the usuals, C, C++,etc.

One thing I would still like to do is to turn off NeoComplCache's closing of the preview window. I have a very small Autocommand that does this when I escape from insert mode, which is when I prefer for that window to close and this autocommand does it uniformly for my various languages and completion plugins.

I will clone NeoComplCache locally so I can experiment with an occasional local change.

Thanks so much for your efforts. Dave Day