V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
laskuma
V2EX  ›  Vim

请教下neocomplcache设置问题

  •  
  •   laskuma · 2012-08-27 06:08:00 +08:00 · 9036 次点击
    这是一个创建于 4261 天前的主题,其中的信息可能已经有所发展或是发生改变。
    一直想找一款类似xcode自动补全的插件。听说这款很好用就使用vundle安装了。gihub上的那么点文档看了半小时还是没搞明白到底该按什么键开始提示补全。
    莫非默认是自动提示但是我安装的别的插件冲突了?

    求解
    22 条回复    1970-01-01 08:00:00 +08:00
    laskuma
        1
    laskuma  
    OP
       2012-08-27 13:43:38 +08:00
    自顶一下…没人用过吗?或者推荐一款自动补全插件也行,主要用来写java和c++
    AlloVince
        2
    AlloVince  
       2012-08-27 13:49:57 +08:00
    先开启,补全是自动显示的
    let g:neocomplcache_enable_at_startup = 1

    via http://avnpc.com/pages/vim-of-allovince
    ivenvd
        3
    ivenvd  
       2012-08-27 13:56:38 +08:00   ❤️ 1
    我的配置:

    """""""""""""""""""""""""""""""""""""""
    "neocomplcache
    """""""""""""""""""""""""""""""""""""""
    let g:acp_enableAtStartup = 0
    let g:neocomplcache_enable_at_startup = 1
    let g:neocomplcache_max_list = 20
    let g:neocomplcache_enable_smart_case = 1
    let g:neocomplcache_enable_auto_select = 1
    let g:neocomplcache_enable_auto_delimiter = 1
    let g:neocomplcache_enable_fuzzy_completion = 1
    let g:neocomplcache_min_syntax_length = 2
    let g:neocomplcache_min_keyword_length = 2
    let g:neocomplcache_manual_completion_start_length = 2
    let g:neocomplcache_enable_cursor_hold_i = 1
    let g:neocomplcache_enable_insert_char_pre = 1
    if !exists('g:neocomplcache_omni_patterns')
    let g:neocomplcache_omni_patterns = {}
    endif
    let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\h\w*\|\h\w*::'
    let g:neocomplcache_omni_patterns.python = '[^. *\t]\.\h\w*\|\h\w*::'
    let g:neocomplcache_omni_patterns.python3 = '[^. *\t]\.\h\w*\|\h\w*::'
    let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
    let g:neocomplcache_omni_patterns.c = '\%(\.\|->\)\h\w*'
    let g:neocomplcache_omni_patterns.cpp = '\h\w*\%(\.\|->\)\h\w*\|\h\w*::'
    "let g:neocomplcache_snippets_disable_runtime_snippets = 1
    "imap <C-k> <Plug>(neocomplcache_snippets_expand)
    "smap <C-k> <Plug>(neocomplcache_snippets_expand)
    "inoremap <expr><C-g> neocomplcache#undo_completion()
    imap <expr><TAB> neocomplcache#sources#snippets_complete#expandable() ? "\<Plug>(neocomplcache_snippets_expand)" : pumvisible() ? "\<C-n>" : "\<TAB>"
    inoremap <expr><C-l> neocomplcache#complete_common_string()
    inoremap <expr><C-e> neocomplcache#cancel_popup()
    "imap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
    laskuma
        4
    laskuma  
    OP
       2012-08-27 19:58:38 +08:00
    @AlloVince 这条已经设置了…但是还是不显示…不知道是不是装了snipmate的问题?
    laskuma
        5
    laskuma  
    OP
       2012-08-27 20:00:52 +08:00
    @ivenvd 还是不理解各行的意思… 日本作者敢不敢把文档写全点 貌似我的帮助文档还进不去 是不是vundle install之后还需要做些设置?
    AlloVince
        6
    AlloVince  
       2012-08-27 20:33:42 +08:00   ❤️ 1
    @laskuma 我的配置里同时用了snipmate和neocomplcache,没有做特殊设置,也没什么冲突

    Bundle "snipmate-snippets"

    https://github.com/AlloVince/vim-of-allovince/blob/master/_vimrc
    laskuma
        7
    laskuma  
    OP
       2012-08-27 21:23:07 +08:00
    @AlloVince
    @ivenvd
    大概是之前装了java completion的问题,所以之前没跳出来,删掉后现在好了。
    已经设置了autoselect,请问可以设置成按tab补全到选中的项吗?

    还有就是针对各语言的补全能不能详细说一下?还是没太搞明白该怎么设置
    谢谢
    humiaozuzu
        8
    humiaozuzu  
       2012-08-27 21:38:11 +08:00
    https://github.com/humiaozuzu/dot-vimrc

    又来推荐自己的啦 = =,有gif演示动画,用的neocomplcache
    laskuma
        9
    laskuma  
    OP
       2012-08-27 21:52:49 +08:00
    @humiaozuzu 求教该怎么让supertab跟snipmate兼容呢?
    humiaozuzu
        10
    humiaozuzu  
       2012-08-27 22:10:32 +08:00
    @laskuma 看我的配置,已经让他们兼容了,很简单的几行代码
    laskuma
        11
    laskuma  
    OP
       2012-08-27 22:12:40 +08:00
    @humiaozuzu 求地址。。表示没找到= =
    humiaozuzu
        12
    humiaozuzu  
       2012-08-27 22:24:46 +08:00
    @laskuma
    在vimrc文件里面啊

    " NeoComplCache
    set completeopt-=preview
    let g:neocomplcache_enable_at_startup=1
    "let g:neoComplcache_disableautocomplete=1
    let g:neocomplcache_enable_smart_case=1
    let g:neocomplcache_min_syntax_length = 3
    let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
    imap <C-k> <Plug>(neocomplcache_snippets_force_expand)
    smap <C-k> <Plug>(neocomplcache_snippets_force_expand)
    "imap <C-l> <Plug>(neocomplcache_snippets_expand)
    "smap <C-l> <Plug>(neocomplcache_snippets_expand)
    "imap <C-t> <Plug>(neocomplcache_snippets_jump)
    "smap <C-t> <Plug>(neocomplcache_snippets_jump)
    imap <C-l> <Plug>(neocomplcache_snippets_force_jump)
    smap <C-l> <Plug>(neocomplcache_snippets_force_jump)

    " Enable omni completion.
    autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
    autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
    autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
    autocmd FileType python setlocal omnifunc=pythoncomplete#Complete

    " SuperTab
    let g:SuperTabDefaultCompletionType="<c-n>"
    laskuma
        13
    laskuma  
    OP
       2012-08-27 23:05:16 +08:00
    @humiaozuzu 原来是neo的snip插件… 想再问下omnifunc的问题 那些xxxComplete需要另外装吗?
    humiaozuzu
        14
    humiaozuzu  
       2012-08-27 23:11:44 +08:00
    @laskuma 直接用homebrew 安装macvim,大部分支持都有了,终端下替换默认的vim为macvim的vim就行了。
    laskuma
        15
    laskuma  
    OP
       2012-08-27 23:22:30 +08:00
    @humiaozuzu 是编译选项的问题吗? 我主要写java和c++都支持吗?
    nouh
        16
    nouh  
       2012-08-27 23:35:24 +08:00   ❤️ 1
    有neocomplcache还要什么supertab呢,同类型的东西用一个终极的就可以了,贴下我的配置吧,自动弹出补全菜单,snippet仍然用的是snipmate的,snippets会显示在补全菜单里,有比较明显的标识区别与其他的补全。 触发补全仍然是tab,上关键字是enter, 轮转菜单是tab

    let g:neocomplcache_enable_at_startup = 1
    " Use smartcase.
    let g:neocomplcache_enable_smart_case = 1
    " Use camel case completion.
    let g:neocomplcache_enable_camel_case_completion = 1
    " Use underbar completion.
    let g:neocomplcache_enable_underbar_completion = 1
    " Set minimum syntax keyword length.
    let g:neocomplcache_min_syntax_length = 3
    let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'

    " Define dictionary.
    let g:neocomplcache_dictionary_filetype_lists = {
    \ 'default' : '',
    \ 'vimshell' : $HOME.'/.vimshell_hist',
    \ 'scheme' : $HOME.'/.gosh_completions'
    \ }

    " Define keyword.
    if !exists('g:neocomplcache_keyword_patterns')
    let g:neocomplcache_keyword_patterns = {}
    endif
    let g:neocomplcache_keyword_patterns['default'] = '\h\w*'

    " Plugin key-mappings.
    imap <C-k> <Plug>(neocomplcache_snippets_expand)
    smap <C-k> <Plug>(neocomplcache_snippets_expand)
    inoremap <expr><C-g> neocomplcache#undo_completion()
    inoremap <expr><C-l> neocomplcache#complete_common_string()

    " SuperTab like snippets behavior.
    "imap <expr><TAB> neocomplcache#sources#snippets_complete#expandable() ? "\<Plug>(neocomplcache_snippets_expand)" : pumvisible() ? "\<C-n>" : "\<TAB>"

    " Recommended key-mappings.
    " <CR>: close popup and save indent.
    "inoremap <expr><CR> neocomplcache#smart_close_popup() . "\<CR>"
    inoremap <expr><silent> <CR> <SID>my_cr_function()
    "use <CR> to choose the candidate under cursor
    function! s:my_cr_function()
    return pumvisible() ? neocomplcache#close_popup() : "\<CR>"
    endfunction

    inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
    imap <expr><Tab> neocomplcache#sources#snippets_complete#expandable() ? "\<Plug>(neocomplcache_snippets_expand)" : "\<C-n>"
    " <TAB>: completion.
    " <C-h>, <BS>: close popup and delete backword char.
    inoremap <expr><C-h> neocomplcache#smart_close_popup()."\<C-h>"
    inoremap <expr><BS> neocomplcache#smart_close_popup()."\<C-h>"
    inoremap <expr><C-j> neocomplcache#close_popup()
    inoremap <expr><C-e> neocomplcache#cancel_popup()


    " AutoComplPop like behavior.
    let g:neocomplcache_enable_auto_select = 1

    " Enable omni completion.
    autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
    autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
    autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
    autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
    autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
    humiaozuzu
        17
    humiaozuzu  
       2012-08-27 23:36:46 +08:00
    @laskuma omnicomplete对C++/java无能为力,虽然有插件cppomnicomplete,但是不是很好用。

    非vim的方案cpp直接上Xcode,java可以试试IntelliJ IDEA
    whenov
        18
    whenov  
       2012-08-27 23:38:32 +08:00
    为什么我开了neocomplcache后变得这么卡?
    laskuma
        19
    laskuma  
    OP
       2012-08-28 01:23:50 +08:00
    @nouh 用supertab是希望可以用tab上关键字,已经习惯xcode了
    laskuma
        20
    laskuma  
    OP
       2012-08-28 05:51:45 +08:00
    @nouh 按照你的配置了一下。。不知道为什么貌似没用。。
    其实我只是希望能把snipmate的snips放进neocomplcache的自动补全列表中,自动补全列表自动显示,按tab自动补全为第一个候选项那么简单。。
    ivenvd
        21
    ivenvd  
       2012-08-30 13:41:55 +08:00
    @humiaozuzu 请教一下,那个 snip 怎么使用默认的值?比如我想输入 #include <stdio.h>,输入 inc<Tab> 之后,补全为 #include <stdio.h><`0`>,这时候怎么不修改 stdio ,而直接跳到行尾呢?
    humiaozuzu
        22
    humiaozuzu  
       2012-08-30 15:40:25 +08:00
    @ivenvd 我的设置是Ctrl+l跳转到下一个占位符,也就是<`0`>。你按一下Ctrl+l就OK了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2974 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 13:11 · PVG 21:11 · LAX 06:11 · JFK 09:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.