Hoping someone can help me out with some pretty erratic behaviour from omnicomplete in Vim with Ruby & HTML.
The problem is that Ctrl+X Ctrl+O only seems to return non-local commands. Method & variable names are left out. If I type Ctrl+X Ctrl+P they show as expected, but omni just isn't picking them up.
A few things:
--version
confirms that Ruby in installed (+ruby
)The .vimrc
is below - any help much appreciated
" Set backup directory so that .swp files aren't stored in work folders
set backup
set backupdir=$HOME/temp/vim_backups/
set directory=$HOME/temp/vim_swp/
filetype on
filetype off
call pathogen#runtime_append_all_bundles()
syntax on
filetype plugin indent on
" Necessary for lot of cool vim things
set nocompatible
set tabstop=2
set smarttab
set shiftwidth=2
set autoindent
set expandtab
set wildmode=longest,list,full
set wildmenu
" Backspace should delete
set backspace=2 " make backspace work like most other apps
" For HTML
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
" For Ruby
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
" improve autocomplete menu color
highlight Pmenu ctermbg=230 gui=bold
" Remaps 'jj' to escape insert mode
inoremap jj <Esc>
" When closing tab, remove the buffer
set nohidden
" SuperTab Options
" let g:SuperTabDefaultCompletionType="<C-x><C-o>"
let g:SuperTabDefaultCompletionType="context"
let g:SuperTabContextDefaultCompletionType="<C-X><C-O>"
" Close tags
imap ,/ </<C-X><C-O>
Here are the relevant options:
set omnifunc=rubycomplete#Complete
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
You're probably missing the complete_buffer_loading.
You can wrap this in autocmd's for the ruby filetype:
if has("autocmd")
autocmd FileType ruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby let g:rubycomplete_buffer_loading=1
autocmd FileType ruby let g:rubycomplete_classes_in_global=1
endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With