yami-beta / asyncomplete-omni.vim

Omni completion source for asyncomplete.vim
MIT License
39 stars 11 forks source link

Popup does not appear #2

Closed lcmen closed 7 years ago

lcmen commented 7 years ago

Hi! I'm testing it with NeoVim on Ruby files and it does not seem to work. When I invoke completion using <C-X><C-O> it works fine but the completion popup (from asynccomplete-omni) does not automatically appear as I type.

Fragments from my init.vim file:

    " Completions {{{
      Plug 'prabirshrestha/asyncomplete.vim'
      Plug 'prabirshrestha/asyncomplete-buffer.vim'
      Plug 'prabirshrestha/asyncomplete-gocode.vim'
      Plug 'prabirshrestha/asyncomplete-tags.vim'
      Plug 'yami-beta/asyncomplete-omni.vim'
    " }}}

    call asyncomplete#register_source(asyncomplete#sources#omni#get_source_options({
      \ 'name': 'omni',
      \ 'whitelist': ['*'],
      \ 'completor': function('asyncomplete#sources#omni#completor')
      \  }))

Any idea what can be wrong?

prabirshrestha commented 7 years ago

If you add this imap <c-space> <Plug>(asyncomplete_force_refresh) and then type <c-space> does it show autocomplete popup?

lcmen commented 7 years ago

@prabirshrestha thanks for quick reply. With <C-Space> it does not work correctly either. I've recorded screencast to show you how it behaves on my side:

out

At first try it asynccomplete shows error: No inserted text yet. Next I use normal omni-completion (<C-X><C-O>), then I try <C-Space> again (it works for include? method but it puts double ii at the beginning of the method) and finally when I try one more time, it wipes the code before the cursor.

prabirshrestha commented 7 years ago

Seems to work perfectly fine with vim8 on windows that comes with inbuilt ruby onmifunc. For me both syntax and omni sources works.

Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-necosyntax.vim'
Plug 'yami-beta/asyncomplete-omni.vim'

autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete

imap <c-space> <Plug>(asyncomplete_force_refresh)
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <cr> pumvisible() ? "\<C-y>\<cr>" : "\<cr>"
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif

au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#omni#get_source_options({
    \ 'name': 'omni',
    \ 'whitelist': ['*'],
    \ 'completor': function('asyncomplete#sources#omni#completor'),
    \ }))
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#necosyntax#get_source_options({
    \ 'name': 'necosyntax',
    \ 'whitelist': ['*'],
    \ 'completor': function('asyncomplete#sources#necosyntax#completor'),
    \ }))

Another option would be to also try vim-lsp with asyncomplete using asyncomplete-lsp.vim. This is better than omnicompletion since the actual lang server is started in different process and provides various other features such as go to definition, document formatting, find references and so on. This allow the actual completion to be purly async. A quick search let me to this https://github.com/mtsmfm/language_server-ruby and https://github.com/rubyide/vscode-ruby/issues/118#issuecomment-278221193

lcmen commented 7 years ago

Thanks for detailed troubleshooting instructions!

I'm sorry but I map incorrectly map <c-space> to <Plug>(asyncomplete_force_refresh) - I used nnoremap instead of imap. After changing to imap I don't see any popup nor it does not autocomplete.

Here is the minimal vimrc that I've been using for testing. I'm using neovim (NVIM v0.2.1-782-gf465bf0).

Do you have problems with other sources like gocode, buffer or is it just with ruby?

It's only with Ruby. Autocompletion for gocode and buffers works fine.

Are you using some other omnicomplete func? If so make sure that completefunc is sync.

No I'm not

Do you also other autocomplete plugins besides asyncomplete.vim. Since asyncomplete.vim is async it takes over our popup management. That means deoplete, ncm or neocomplete shouldn't be used. It is the same other way around. If you use those plugins use only one and not multiple autocomplete managers.

No I don't

Can you try disabling sign plugin. I do use ale personally but haven't seen this problem.

I tried with the vimrc I posted above. Still no popup.

You can also try to see the log let g:asyncomplete_log = expand('~/asyncomplete.log')

I tried it but it didn't even created the log file for me.

yami-beta commented 7 years ago

@lowski Sorry for my late reply. Please try fix-startcol branch. I think this branch works correctly.

If this branch resolve this issue, I merge it into master.

@prabirshrestha Thank you for help to resolve !

lcmen commented 7 years ago

@yami-beta I've switched to that branch but I don't see pop-up (neither when I type nor I hit <c-space>). I'm testing it with the following vimrc (using nvim -u path/to/file):

set nocompatible

call plug#begin('~/.vim/plugged')
  Plug 'prabirshrestha/asyncomplete.vim'
  Plug 'yami-beta/asyncomplete-omni.vim', { 'branch': 'fix-startcol' }
call plug#end()

autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
imap <c-space> <Plug>(asyncomplete_force_refresh)
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <cr> pumvisible() ? "\<C-y>\<cr>" : "\<cr>"
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
call asyncomplete#register_source(asyncomplete#sources#omni#get_source_options({
  \ 'name': 'omni',
  \ 'whitelist': ['*'],
  \ 'completor': function('asyncomplete#sources#omni#completor')
  \  }))
yami-beta commented 7 years ago

@lowski Sorry, I misspelled. Wrong: fix-startcol Correct: topic/fix-startcol

lcmen commented 7 years ago

@yami-beta this works perfectly, thanks! Please merge to master.

yami-beta commented 7 years ago

Merged!