Vim plug-in neocomplcache configuration experience

Source: Internet
Author: User
Tags imap

For vimist, neocomplcache is a plug-in that is both love and hate. The main feature is powerful, complex configuration, and like to conflict with various plug-ins.

I was also overwhelmed by him. During this period, you searched countless times, but could not find the detailed configuration. After constantly exploring and reading the help documentation and source code, I finally had some experience. In addition, this plug-in configuration is better. After using it with snipmate, it is basically similar to visual assist X in Visual Studio.

Neocomplcache can be used basically without configuring snipmate. However, snippets of snipmate is comprehensive, and enhanced versions of snippets are available on the Internet. The number of snippets is much larger than that of neocomplcache. Sadly, neocomplcache cannot directly call snippets of snipmate. Therefore, snipmate cannot be removed.

However, snipmate occupies the key Tab key (use the tab to activate its snippets, And you can modify its source code to implement it ). Neocomplcache won't be able to use tabs to select candidate words. However, after configuration, I still have several methods to use:

1. enable quick match:

Let G: neocomplcache_enable_quick_match = 1 "for input-saving, this variable controls whether you can choose a candidate with a alphabet or number displayed beside a candidate after '-'. when you input 'Ho-A', neocomplcache will select candidate 'A '.

After this switch is enabled, you can press the "-" key each time the completion menu pops up. This indicates that each candidate word in the completion menu will be labeled with a letter, you can complete the selection immediately after entering the corresponding letter.

2, CTRL-N, CTRL-P:

These two keys can replace the tab function and select your candidate words up or down.

3. Use space:
Inoremap <expr> <space> pumvisible ()? Neocomplcache # close_popup (). "\ <space>": "\ <space>"

Use space to automatically rotate the current candidate word and add a space. This is a real and unobstructed input method. <Tab> and <enter> in front of space are all floating clouds. The author of neocomplcache did not even think of this. The recommended configurations are still entangled in <tab> and <enter>. This is also recommended by visual assist X.

 

Of course, for so long, neocomplcache certainly has more to do with this. There are several days of tips:

1. neocomplcache can select the dict Dictionary Based on the file type. This is the first release of editplus. You can directly copy the syntax file of editplus. You can assign it to neocomplcache after a little sorting:

"Define dictionary.
Let G: neocomplcache_dictionary_filetype_lists = {
\ 'Default ':'',
\ 'Vimshell': $ home. '/. vimshell_hist ',
\ 'Scheme ': $ home.'/. gosh_completions ',
\ 'Css ': $ vimfiles.'/dict/CSS. dic ',
\ 'Php': $ vimfiles. '/dict/PHP. dic ',
\ 'Javascript ': $ vimfiles.'/dict/JavaScript. dic'
\}

2. The default carriage return definition of neocomplcache will conflict with plug-ins such as 'auto-pairs 'and 'endwise. This bug left me alone for one night. However, I also find a configuration method for finding conflicting plug-ins. Call add (G: pathogen_disabled, directory name) is disabled by pathogen ). Disable all plug-ins under bundle with this function. Then, add "comment out" to disable in batches, that is, open the plug-in. In this way, the conflicting plug-in can be found in just a few minutes after multiple tests.

Call add (G: pathogen_disabled, 'auto-pairs ') "conflict with neocomplcache
Call add (G: pathogen_disabled, 'endwise ') "conflict with neocomplcache

With regard to pathogen, all the vim plug-ins managed by experts in this year use pathogen and git. If you still mix the downloaded plug-ins, consider updating them.

Git is essential for maintaining the vim configuration library of the network version that is always updated. In this regard, we need to seriously refer to this article:

Http://blog.wu-boy.com/2011/09/introduction-to-git-submodule/

That is to say, you only need to maintain your vimrc file and the list of plug-ins, and configure the specific plug-ins to the directories under the bundle through pathogen, then, point to the original file library of each plug-in through git submodule, so that you have an always-up-to-date Vim release.

Some people say that Emacs is an operating system disguised as an editor, and VIM is not... The concepts of boot, Loading modules, and desktop management are fully embodied in these editors.

 

Key conflicts are discussed here: https://github.com/sjbach/lusty/issues/20

Https://github.com/ervandew/supertab/issues/10

3. Some functions used in the neocomplcache configuration file:

Pumvisible (): If the pop-up menu is visible, non-zero is returned. Otherwise, zero is returned.

Neocomplcache # undo_completion: You can see the name. perform an Undo operation to cancel the completion.

Neocomplcache # close_popup (). The pop-up box is closed after the candidate word is supplemented.

Neocomplcache # cancel_popup () does nothing. Close the pop-up box directly.

Neocomplcache # smart_close_popup () depends on the function definition. It is said to be smart, but I set it to G: neocomplcache_enable_auto_select for half a day, and the flexibility is changed to neocomplcache # close_popup.

  1: function! neocomplcache#smart_close_popup()
  2:   return g:neocomplcache_enable_auto_select ? neocomplcache#cancel_popup() : neocomplcache#close_popup()
  3: endfunction

 

Finally, my configuration file. Because the configuration file is too large, I directly saved a file named neocomplcache. conf and then called it in vimrc:

"--- Neocomplcache it's such a big config file that I split into a single file.
Source $ Vim/vimfiles/neocomplcache. conf

 

 
  1: " Disable AutoComplPop.
  2: let g:acp_enableAtStartup = 0
  3: " Use neocomplcache.
  4: let g:neocomplcache_enable_at_startup = 1
  5: " Use smartcase.
  6: let g:neocomplcache_enable_smart_case = 1
  7: " Use camel case completion.
  8: let g:neocomplcache_enable_camel_case_completion = 1
  9: " Use underbar completion.
 10: let g:neocomplcache_enable_underbar_completion = 1
 11: " Set minimum syntax keyword length.
 12: let g:neocomplcache_min_syntax_length = 3
 13: let g:neocomplcache_lock_buffer_name_pattern = '\*ku\*'
 14: 
 15: " AutoComplPop like behavior.
 16: let g:neocomplcache_enable_auto_select = 0
 17: 
 18: " When you input 'ho-a',neocomplcache will select candidate 'a'.
 19: let g:neocomplcache_enable_quick_match = 1
 20: 
 21: " Define dictionary.
 22: let g:neocomplcache_dictionary_filetype_lists = {
 23:     \ 'default' : '',
 24:     \ 'vimshell' : $HOME.'/.vimshell_hist',
 25:     \ 'scheme' : $HOME.'/.gosh_completions',
 26:     \ 'css' : $VIMFILES.'/dict/css.dic',
 27:     \ 'php' : $VIMFILES.'/dict/php.dic',
 28:     \ 'javascript' : $VIMFILES.'/dict/javascript.dic'
 29:     \ }
 30: 
 31: let g:neocomplcache_snippets_dir=$VIMFILES."/snippets"
 32: inoremap <expr><S-TAB>  pumvisible() ? "\<C-p>" : "\<TAB>"
 33: inoremap <expr><C-TAB>  pumvisible() ? "\<C-p>" : "\<TAB>"
 34: 
 35: 
 36: " Define keyword.
 37: if !exists('g:neocomplcache_keyword_patterns')
 38:   let g:neocomplcache_keyword_patterns = {}
 39: endif
 40: let g:neocomplcache_keyword_patterns['default'] = '\h\w*'
 41: 
 42: " Plugin key-mappings.
 43: imap <C-k>     <Plug>(neocomplcache_snippets_expand)
 44: smap <C-k>     <Plug>(neocomplcache_snippets_expand)
 45: inoremap <expr><C-g>     neocomplcache#undo_completion()
 46: inoremap <expr><C-z>     neocomplcache#undo_completion()
 47: inoremap <expr><C-l>     neocomplcache#complete_common_string()
 48: 
 49: " SuperTab like snippets behavior.
 50: "imap <expr><TAB> neocomplcache#sources#snippets_complete#expandable() ? "\<Plug>(neocomplcache_snippets_expand)" : pumvisible() ? "\<C-n>" : "\<TAB>"
 51: 
 52: " Recommended key-mappings.
 53: " <CR>: close popup and save indent.
 54: " inoremap <expr><CR>  neocomplcache#close_popup() . "\<CR>"
 55: inoremap <expr><CR> pumvisible() ? neocomplcache#close_popup() : "\<CR>"
 56: " <TAB>: completion. THIS HAS NO USE WHEN WITH SNIPMATE
 57: " inoremap <expr><TAB>  pumvisible() ? "\<C-n>" : "\<TAB>"
 58: " <SPACE>: completion.
 59: inoremap <expr><space>  pumvisible() ? neocomplcache#close_popup() . "\<SPACE>" : "\<SPACE>"
 60: 
 61: 
 62: " <C-h>, <BS>: close popup and delete backword char.
 63: inoremap <expr><C-h> neocomplcache#close_popup()."\<C-h>"
 64: inoremap <expr><BS> neocomplcache#close_popup()."\<C-h>"
 65: 
 66: inoremap <expr><C-y>  neocomplcache#close_popup()
 67: inoremap <expr><C-e>  neocomplcache#cancel_popup()
 68: 
 69: " Shell like behavior(not recommended).
 70: "set completeopt+=longest
 71: "let g:neocomplcache_enable_auto_select = 1
 72: "let g:neocomplcache_disable_auto_complete = 1
 73: "inoremap <expr><TAB>  pumvisible() ? "\<Down>" : "\<TAB>"
 74: "inoremap <expr><CR>  neocomplcache#close_popup() . "\<CR>"
 75: 
 76: " Enable omni completion.
 77: autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
 78: autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
 79: autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
 80: autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
 81: autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
 82: autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete
 83: 
 84: " Enable heavy omni completion.
 85: if !exists('g:neocomplcache_omni_patterns')
 86:   let g:neocomplcache_omni_patterns = {}
 87: endif
 88: let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::'
 89: let g:neocomplcache_omni_patterns.php = '[^. \t]->\h\w*\|\h\w*::'
 90: let g:neocomplcache_omni_patterns.c = '\%(\.\|->\)\h\w*'
 91: let g:neocomplcache_omni_patterns.cpp = '\h\w*\%(\.\|->\)\h\w*\|\h\w*::'
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.