I'm trying to get omnicomplete working in neovim (0.3.4) on debian 10 with Ruby 2.6.6 (rbenv).
I have these plugins:
Plug 'vim-ruby/vim-ruby' " ruby
Plug 'tpope/vim-rails' " rails
With these settings:
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
I get this error when trying omnicomplete:
option 'omnifunc' is not set
If I add this:
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
I get this error:
Error: falling back to syntax completion
E117: Unknown function: rubycomplete#Complete
But after I click this error away it seems to work? What am I doing wrong? (I'm not interested in other plugins like deoplete, ...)
Update:
When I change
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
to
autocmd FileType ruby,eruby set omnifunc=syntaxcomplete#Complete
it seems to work. Not sure if that is the correct way?
update 2:
In Neovim you can check if Ruby is installed with :checkhealth
.
In Debian 10 you can install ruby-neovim if you use the system Ruby version.
Since I use rbenv I did this:
gem install neovim
.vimrc settings:
let g:ruby_host_prog = '~/.rbenv/shims/neovim-ruby-host'
let g:ruby_path = system('echo $HOME/.rbenv/shims')
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
There was also a bug in vim-ruby for the completion, but that is now fixed: https://github.com/vim-ruby/vim-ruby/pull/415
omnifunc
torubycomplete#Complete
if the filetype isruby
and your Vim has support for Ruby. Can you check that:set ft?
returnsfiletype=ruby
? Can you check that:version
includes+ruby
in the list of features?