【问题标题】:make omnifun default in vim insert completion在vim插入完成中使omnifun默认
【发布时间】:2014-02-07 16:19:17
【问题描述】:

在 vim 中安装 eclim 和 ycm 后,当你开始输入 vim 时会在弹出菜单中使用 -- user defined completion,你可以切换到 Omni 补全,它设置为使用 c-x c-o 显示 eclim 选项。

如何让 vim 用户 Omni 完成选项默认而不是用户定义的选项,而不必每次都按 c-x c-o ?

如果我理解正确,链条应该去:

completefunc -(calls)> omnifunc -(calls)> eclim 选项

默认情况下,completefunc 是调用用户定义的完成,并且会在 c-x c-o 上切换到omnifunc

【问题讨论】:

  • 这是一个 ycm 设置,试试文档。另外,你为什么不简单地使用eclipse?

标签: vim autocomplete eclim


【解决方案1】:

除了默认的<C-n>完成(其来源可以通过'complete'选项配置),Vim有两个自定义完成,即useromni 完成。唯一的区别在于触发键(<C-x><C-u><C-x><C-o>)和函数名称的选项名称。要通过用户功能键使用全功能,只需在设置全功能后重新分配功能名称​​

:let &omnifunc = &completefunc

【讨论】:

  • 我试过了,正如前面的答案中提到的那样,但是当设置这个时,弹出菜单不会像以前那样在打字时出现。你需要触发它。
  • 嗯,这就是 YCM 的问题;我猜它提供了自动完成功能。
  • 'user' 和 'omni' 补全之间还有另一个区别。我认为用户完成在所有文件中都是全局的,而全能完成是基于文件类型
  • @mikew 不,两者都是/可以是缓冲区本地的。
  • @IngoKarkat,我没说要成为本地缓冲区。
【解决方案2】:

这是来自我当前的 ~/.vim/vimrc:

" Eclim + YouCompleteMe {{{1
" See <~/MyDocs/SysAdmin/Eclim.otl>
" This next line recommended by Eclim installation instructions

autocmd FileType php,java,ruby let g:EclimCompletionMethod = 'omnifunc'

" For your list of filetypes where you want Eclim semantic completion 
" as the default YCM completion mode:

autocmd FileType php,java,ruby,c,cpp,perl,python  
    \if &completefunc != '' | let &omnifunc=&completefunc | endif

" This will allow you to hit <Enter> in normal mode to search for the
" word under the cursor

nnoremap <silent> <buffer> <cr> :PhpSearchContext<cr>
" End Eclim + YouCompleteMe }}}1 

我发现我想使用的时候需要有 &omnifunc = &completefunc Eclim 的语义补全。

我不确定我是否完全理解,但看起来 Eclim 期望使用omnifunc YCM 期望完成函数,其中 用户完成 = completefunc 和 全方位完成 = 全方位功能

【讨论】:

    猜你喜欢
    • 2014-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多