当前位置: 动力学知识库 > 问答 > 编程问答 >

Vim Ruby and Rails autocomplete

问题描述:

I am using Tim Popes rail.vim and the ruby-vim. No matter what I have tried on the net I can't get code completion to work sensibly. The nearest I have got is

 <c-x><c-o> - auto completing ruby eg pu.. <c-x><c-o> shows "puts"

<c-x><c-u> - auto completing rails e.g ren.. <c-x><c-u> shows "render"

.vimrc (section mostly found on github)

.....

set omnifunc=rubycomplete#Complete

let g:rubycomplete_buffer_loading = 1

let g:rubycomplete_classes_in_global=1

let g:rubycomplete_rails = 1

......

"perform all your insert completion using the "Tab" key.

"let SuperTab decide which completion mode to use and should play with OmniCompletion

"let g:SuperTabMappingTabLiteral = '<c-tab>' " insert true TAB

let g:SuperTabDefaultCompletionType = "context"

let g:SuperTabContextDefaultCompletionType = "<c-x><c-u>"

let g:SuperTabCompletionContexts = ['s:ContextText', 's:ContextDiscover']

let g:SuperTabCompletionContexts = ['s:ContextDiscover']

let g:SuperTabContextTextOmniPrecedence = ['&omnifunc', '&completefunc']

let g:SuperTabContextDiscoverDiscovery = ["&completefunc:<c-x><c-u>", "&omnifunc:<c-x><c-o>"]

" let g:SuperTabMappingForword = '<c-space>' " replace default <Tab>

let g:SuperTabLongestEnhanced = 1 " when you have 'longest' in completeopt, enhanced longest.

let g:SuperTabLongestHighlight = 0 " highlight first one in popup menu let you hit <enter>.

I really would like the results of the two menus merged and under the one shortcut.

Thats is, both ruby and rails completion together.

Is this possible? perhaps using subertab chaining? which I couldn't get working either.

Other notes

Rails 3.2.8

Ruby 1.9.2p320 and tried 1.8.7

Vim 7.3.429 (ubuntu vim-nox package) complied with ruby 1.8.7

Rbenv, Rbenv-build, Rbenv-bundle

网友答案:

i use rails.vim and my .vimrc only has

let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_rails = 1

code completion works fine with "tab"

分享给朋友:
您可能感兴趣的文章:
随机阅读: