当前位置:网站首页>VIM uses vundle to install the code completion plug-in (youcompleteme)

VIM uses vundle to install the code completion plug-in (youcompleteme)

2022-04-23 16:02:00 weixin_ forty-three million two hundred and twenty-four thousan

Vim Use Vundle Install the code completion plug-in (YouCompleteMe)
install Vundle
It's easy to use , To install a plug-in, you only need to install it in ~/.vimrc Add by rule Plugin The name of , Some paths need to be added , After the Vim Use in :PluginInstall It can be installed automatically .

1、 First create a new directory

mkdir ~/.vim/bundle/Vundle.vim
2、git clone Vundle Project to local

git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
 3、 modify ~/.vimrc To configure Plugins. stay ~/.vimrc Add the following contents to the file and save

Introduction:

Installation requires Git and triggers git clone for each configured repository to ~/.vim/bundle/ by default. Curl is required for search.

If you are using Windows, go directly to Windows setup. If you run into any issues, please consult the FAQ. See Tips for some advanced configurations.

Using non-POSIX shells, such as the popular Fish shell, requires additional setup. Please check the FAQ.

Set up Vundle:

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

Configure Plugins:

Put this at the top of your .vimrc to use Vundle. Remove plugins you don't need, they are for illustration purposes.



set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}

" All of your Plugins must be added before the following line
call vundle#end()            " required
filetype plugin indent on    " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList       - lists configured plugins
" :PluginInstall    - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean      - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

Install Plugins:

Launch vim and run :PluginInstall

To install from command line: vim +PluginInstall +qall

(optional) For those using the fish shell: add set shell=/bin/bash to your .vimrc

4、 Get into vim Run the command

:PluginInstall
Vundle command
# Installing a plug-in
:BundleInstall
# Update plug-in
:BundleUpdate
# Clear unnecessary plug-ins
:BundleClean
# List the current plug-ins
:BundleList
# Search plug-ins
:BundleSearch
Be careful
The plug-in configuration should not be in call vundle#end() Before , Otherwise, the plug-in will not work
If the configuration is wrong , After reconfiguration , stay vim Run command in :PluginInstall

Use Vundle install YouCompleteMe
stay ~/.vimrc To add the following Position in call vundle#begin() and call vundle#end() Between

Bundle 'Valloric/YouCompleteMe'
stay vim Run the following command in to install itself , Installation time is a little long , Please be patient

:BundleInstall
After installation, you need to compile YouCompleteMe
The compilation process requires CMake, No installation CMake You can use the following command to install

sudo apt install cmake
Then switch to the following directory

cd ~/.vim/bundle/YouCompleteMe 
Finally, enter the following command ( The default support python)

./install.sh
To configure YouCompleteMe
stay ~/.vimrc Add configuration in

"  Autocomplete configuration 
set completeopt=longest,menu " Give Way Vim The complete menu behavior of is similar to that of general IDE Agreement ( Reference resources VimTip1228)
autocmd InsertLeave * if pumvisible() == 0|pclose|endif " Automatically close preview window after leaving insert mode 
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" " Enter to select the current item 
" The behavior of up, down, left and right keys   Other information will be displayed 
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
inoremap <expr> <PageDown> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>"
inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>"

"youcompleteme  Default tab s-tab  Conflict with automatic completion 
"let g:ycm_key_list_select_completion=['<c-n>']
let g:ycm_key_list_select_completion = ['<Down>']
"let g:ycm_key_list_previous_completion=['<c-p>']
let g:ycm_key_list_previous_completion = ['<Up>']
let g:ycm_confirm_extra_conf=0 " Turn off loading .ycm_extra_conf.py Tips 

let g:ycm_collect_identifiers_from_tags_files=1 "  Turn on  YCM  Based on the tag engine 
let g:ycm_min_num_of_chars_for_completion=2 "  From 2 Typing characters starts listing matches 
let g:ycm_cache_omnifunc=0 "  Disable caching matches , Regenerate the match every time 
let g:ycm_seed_identifiers_with_syntax=1 "  Grammar keyword completion 
nnoremap <F5> :YcmForceCompileAndDiagnostics<CR> "force recomile with syntastic
"nnoremap <leader>lo :lopen<CR> "open locationlist
"nnoremap <leader>lc :lclose<CR> "close locationlist
inoremap <leader><leader> <C-x><C-o>
" It can also be completed in comment input 
let g:ycm_complete_in_comments = 1
" It can also be completed in string input 
let g:ycm_complete_in_strings = 1
" The text in the comments and strings will also be complemented by the revenue 
let g:ycm_collect_identifiers_from_comments_and_strings = 0

nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR> "  Jump to definition 


Here we are ,YouCompleteMe Installed successfully .
 

版权声明
本文为[weixin_ forty-three million two hundred and twenty-four thousan]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231558144853.html