如何将Vim的Omni Completion与本地Ruby类一起使用?

时间:2012-02-02 21:34:38

标签: ruby vim windows-7

我正在运行Vim 7.3executables from here以阻止它在我调用Omnicomplete时崩溃)和Ruby 1.9.3-p0。我也安装了Ruby 1.8.7,但它不在我的路上。我的系统路径中有C:\Ruby193\bin。我可以对默认的Ruby对象使用auto-complete(例如g = "foo"; g.<tab>有效),但我不能将它用于缓冲区中的本地类或类。

不幸的是,question's answers没有帮助。

我安装的唯一宝石有bigdecimal (1.1.0)io-console (0.3)json (1.5.4)minitest (2.5.1)qtbindings (4.6.3.4 x86-mingw32)rake (0.9.2.2),{{1 }和rdoc (3.9.4)。除了运行rubygems-update (1.8.15)gem update --system之外,这些都应该是默认设置。

我安装了以下插件:

我尝试删除snipMate和SuperTab以查看是否可以让它工作,但没有运气。

这是我的_vimrc文件,以防出现问题:

gem install qtbindings

我一直在测试的文件如下:

set nocompatible
syn enable "enable syntax highlighting
colorscheme peachpuff "yay my color scheme
set clipboard=unnamed "yanks go to clipboard
set nu "show line numbers
set lbr "line breaks on words if set nolist is run
set formatoptions=l
set wrap
set tabstop=4 "tabs are 4 characters long
set noexpandtab
set nosmarttab
set shellslash
set hidden " hide buffers instead of closing them
noremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
set shiftwidth=4
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
set backupdir=~/VIM_BACKUP

filetype plugin indent on

set list listchars=tab:\|_
" Enter the middle-dot by pressing Ctrl-k then .M
" Enter the right-angle-quote by pressing Ctrl-k then >>
" Enter the Pilcrow mark by pressing Ctrl-k then PI
" Extra options :dig
set list listchars=tab:»»,trail:·,extends:>
"set list listchars eol:¶


" Show the menu but not the toolbar
set guioptions=m

" 3 lines of buffer offset while scrolling:
set scrolloff=3

" Indent folding:
set nofoldenable
set fdm=indent

" Highlight current line
set cursorline

"Spell Checking:
set spell
set spelllang=en
set spellsuggest=9 "only show 9 suggestions

"Filename completion
"Complete longest, then each match, then show a list
set wildmode=longest,full,list

"Path for saving and loading
cd ~

set diffexpr=MyDiff()
function MyDiff()
    let opt = ''
    if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
    if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
    silent execute '\"!C:\Program Files\vim\diff\" -a ' . opt . v:fname_in . ' ' . v:fname_new . ' > ' . v:fname_out
endfunction

"SuperTab
 let g:SuperTabDefaultCompletionType = "context"
 let g:SuperTabContextDefaultCompletionType="<C-X><C-O>"

"snipMate
let g:snips_author = 'corvec'

"ruby
let g:ruby_path = ':C:\ruby193\bin'
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
    autocmd filetype ruby setlocal list
"    autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
    autocmd filetype text colorscheme 
endif

当我在最后一行之后输入class Giant attr :height, :weight def initialize(name) @name = name @height = 15 @weight = 800 end def description puts "#{@name} is a #{@height} foot tall, #{@weight} pound giant." end def talk puts "#{@name} says 'My name is #{@name}'" end def hello puts "#{@name} says 'Hello.'" end def goodbye puts "#{@name} throws a rock at you as you say goodbye. You die." end end g = Giant.new("Gary") g.description g.hello g. <tab>时,我会在状态栏中收到一条消息:<C-X><C-O> -- Omni completion (^O^N^P) ,以及完成不起作用。我的印象是,这应该足以让本地(和缓冲区)自动完成工作。我需要安装另一个插件吗?如果没有,我该如何让它工作?

0 个答案:

没有答案