Vim auto-completion plug-in-youcompleteme -- "Great-God Vim completion plug-in"

Source: Internet
Author: User
Vim auto-completion plug-in-youcompleteme

Preface

Vim is called the editor God mostly thanks to its rich DIY flexible plug-in functions (for example, youcompleteme, the magical Code Completion plug-in under Vim ), most of the users who use Vim feel that IDE development tools are not light enough, and IDE usually only supports specific languages or specific system platforms. Most people use it, but Vim is the best tool, it is the most comfortable to use.

The following Vim auto-completion plug-in youcompleteme makes up for the shortcomings that Vim cannot auto-complete. Ycm not only provides excellent support for the C language, but also is a powerful Vim auto-completion framework that can be used with eclim and Jedi, provides excellent support for Java, Python, and other languages.

 

YoucompletemeThe complete installation steps are as follows:

  1. Upgrade Vim to 7.3.584 + and support Python embedded scripts. 584 is the patch number. Generally, VIM is installed without a patch. You can choose to patch, but this is more troublesome, I chose to install Vim 7.4 directly (download the current vim-7.4a ).

    $ ./configure --with-features=huge --enable-perlinterp --enable-pythoninterp --enable-rubyinterp --enable-cscope --enable-multibyte --disable-gui --prefix=/usr$ make VIMRUNTIMEDIR=/usr/share/vim/vim74a# make install
  2. Install ycm through vundle. Vundle is recommended for plug-in management on the official website, but I have never used it before.

    First install vundle:

    $ git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle

    Configuration ~ /. Vimrc:

    Set nocompatible "be improvedfiletype off" required! Set RTP + = ~ /. Vim/bundle/vundle/call vundle # RC () "Let vundle manage vundle" required!Bundle'Gmarik/vundle' (do not add comments to the end of this sentence; otherwise, an error will be reported ~ Wonderful ~)Bundle'Valloric/youcompleteme' (do not add any comments after this sentence; otherwise, an error will be reported ~)Filetype plugin indent on "required! "" Brief help ": bundlelist-list configured bundles": bundleinstall (!) -Install (update) Bundles ": bundlesearch (!) Foo-search (or refresh cache first) For foo ": bundleclean (!) -Confirm (or auto-approve) removal of unused bundles "" See: H vundle For more details or wiki for FAQ "NOTE: comments after bundle command are not allowed ..

    Install ycm:

    $ vim +BundleInstall +qall
  3. Upgrade libclang to version 3.2 or later. You can use xcode to upgrade libclang.

    For Debian systems, you can add llvm sources and install them from the sources.

    # LLVM sourcedeb http://llvm.org/apt/wheezy/ llvm-toolchain-wheezy maindeb-src http://llvm.org/apt/wheezy/ llvm-toolchain-wheezy main
  4. Compile ycm_core. Install a cmake tool first.

    Compile:

    $ Cd ~ /. Vim/bundle/youcompleteme $./install. Sh -- clang-completer -- System-libclang (you can use it directly ~)

    Note:

    If you do not use-- System-libclangParameter, then ycm will download the Ubuntu x64 clang + llvm-3.3 Binary Package, which has compatibility issues on some platforms.

    You can also skip the install. Sh script during the compilation process. Run the following command:

    $ mkdir ycm_build$ cd ycm_build$ cmake -G "Unix Makefiles" -DEXTERNAL_LIBCLANG_PATH=/path/to/libclang.so . ~/.vim/bundle/YouCompleteMe/cpp$ make ycm_core$ make ycm_support_libs
  5. Install eclim to process Java. Download eclim 2.2.6 and install eclim 2.2.x. Eclipse 4.2.x is required. Double-click on the Mac and install it on the GUI.

     

  6. Add some configurations in. vimrc.

    let g:ycm_global_ycm_extra_conf = ‘~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py‘let g:EclimCompletionMethod = ‘omnifunc‘

    Modify the. ycm_extra_conf.py file, comment out the following code, and enable support for the c ++ standard library.

    #try:#  final_flags.remove( ‘-stdlib=libc++‘ )#except ValueError:#  pass
Use ycm(For Java User Configuration)

Ycm can be used directly for C and Python classes. For Java, you need to start eclim first.

The following describes how to use eclim + ycm to develop Java projects.

  1. Start the eclim service and run/Users/yeolar/. Eclipse/org. Eclipse. platform_4.2.0_119745494/eclimd.

    For convenience, you can ~ /. Add an alias to bash_profile:

    alias eclimd=‘/Users/yeolar/.eclipse/org.eclipse.platform_4.2.0_119745494/eclimd 2>&1 1>/dev/null &‘
  2. Verify the installation of eclim:

    : Pingeclim "whether the service is normal: eclimvalidate" to verify that the vim configuration is valid
  3. Create a Java project:

    :ProjectCreate /path/to/project -n java

    When a project is created, the. classpath,. Project, and SRC directories are automatically created. Available: ProjectlistView the project list.

    The source code path for adding a project can be used in the. classpath file.: Newsrcentry path/to/New/srcComplete. By default, the src directory is added when the project is created.

  4. Write code. You can write it normally. Because eclim configurations have been added to ycm, the automatic completion function is consistent with that of ycm. More methods can refer to the http://eclim.org/vim/java/index.html.

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.