Ubuntu18.04使用Vundle安装YouCompleteMe

Ubuntu18.04使用Vundle安装YouCompleteMe

1 .先安装好Vundle

2 .cd  ~/.vim/bundle/

 sudo git clone https://github.com/Valloric/YouCompleteMe.git

3 .cd YouCompleteMe

4.  sudo git submodule update --init --recursive 

       # cmake 安装 

    sudo apt install build-essential cmake python3-dev

      ./install.py --clangd-completer   # 报错,提示要要配python2.7路径,我不用cmake 安装,转用下面方法装



5. sudo python3 install.py 

6. sudo vim ~/.vimrc

     我的.vimrc

 1 "vundle
  2 set nocompatible
  3 filetype off
  4 
  5 set rtp+=~/.vim/bundle/Vundle.vim
  6 call vundle#begin()
  7 
  8 Plugin 'VundleVim/Vundle.vim'
  9 "git interface
 10 Plugin 'tpope/vim-fugitive'
 11 "filesystem
 12 Plugin 'scrooloose/nerdtree'
 13 Plugin 'jistr/vim-nerdtree-tabs'
 14 Plugin 'kien/ctrlp.vim'
 15 
 16 "html
 17 "  isnowfy only compatible with python not python3
 18 "Plugin 'jtratner/vim-flavored-markdown'
 19 Plugin 'suan/vim-instant-markdown'
 20 Plugin 'nelstrom/vim-markdown-preview'
 21 "python sytax checker
 22 Plugin 'nvie/vim-flake8'
 23 Plugin 'vim-scripts/indentpython.vim'
 24 Plugin 'scrooloose/syntastic'
 25 
 26 "auto-completion stuff
 27 "Plugin 'klen/python-mode'
 28 Plugin 'Valloric/YouCompleteMe'
 29 "Plugin 'klen/rope-vim'
 30 "Plugin 'davidhalter/jedi-vim'
 31 Plugin 'ervandew/supertab'
 32 ""code folding
 33 Plugin 'tmhedberg/SimpylFold'
 34 
 35 "Colors!!!
 36 Plugin 'altercation/vim-colors-solarized'
 37 Plugin 'jnurmine/Zenburn'
 38 
 39 call vundle#end()
 40 
 41 filetype plugin indent on    " enables filetype detection
 42 let g:SimpylFold_docstring_preview = 1
 43 
 44 ""autocomplete
 45 "let g:ycm_autoclose_preview_window_after_completion=1
 46 " YouCompleteMe
 47 set runtimepath+=~/.vim/bundle/YouCompleteMe
 48 let g:ycm_collect_identifiers_from_tags_files = 1           " 开启 YCM 基于标签引擎
 49 let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释与字符串中的内容也用于补全
 50 let g:syntastic_ignore_files=[".*\.py$"]
 51 let g:ycm_seed_identifiers_with_syntax = 1                  " 语法关键字补全
 52 let g:ycm_complete_in_comments = 1
 53 let g:ycm_confirm_extra_conf = 0
 54 let g:ycm_key_list_select_completion = ['<c-n>', '<Down>']  " 映射按键, 没有这个会拦截掉tab, 导致其他插件的tab不
    能用.
 55 let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>']
 56 let g:ycm_complete_in_comments = 1                          " 在注释输入中也能补全
 57 let g:ycm_complete_in_strings = 1                           " 在字符串输入中也能补全
 58 let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释和字符串中的文字也会被收入补全
 59 let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
 60 let g:ycm_show_diagnostics_ui = 0                           " 禁用语法检查
 61 inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>" |            " 回车即选中当前项
 62 nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR>|     " 跳转到定义处
 63 "let g:ycm_min_num_of_chars_for_completion=2                 " 从第2个键入字符就开始罗列匹配

65 "custom keys
 66 let mapleader=" "
 67 map <leader>g  :YcmCompleter GoToDefinitionElseDeclaration<CR>
 68 
 69 "call togglebg#map("<F5>")
 70 "colorscheme zenburn
 71 "set guifont=Monaco:h14
 72 
 73 let NERDTreeIgnore=['\.pyc$', '\~$'] "ignore files in NERDTree
 74 
 75 "I don't like swap files
 76 set noswapfile
 77 
 78 "turn on numbering
 79 set nu
 80 
 81 
 82 "it would be nice to set tag files by the active virtualenv here
 83 ":set tags=~/mytags "tags for ctags and taglist
 84 "omnicomplete
 85 autocmd FileType python set omnifunc=pythoncomplete#Complete
 86 
 87 "------------Start Python PEP 8 stuff----------------
 88 " Number of spaces that a pre-existing tab is equal to.
 89 au BufRead,BufNewFile *py,*pyw,*.c,*.h set tabstop=4
 90 
 91 "spaces for indents
 92 au BufRead,BufNewFile *.py,*pyw set shiftwidth=4
 93 au BufRead,BufNewFile *.py,*.pyw set expandtab
 94 au BufRead,BufNewFile *.py set softtabstop=4
 95 
 96 " Use the below highlight group when displaying bad whitespace is desired.
 97 highlight BadWhitespace ctermbg=red guibg=red
 98 
 99 " Display tabs at the beginning of a line in Python mode as bad.
100 au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
101 " Make trailing whitespace be flagged as bad.
102 au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
103 
104 " Wrap text after a certain number of characters
105 au BufRead,BufNewFile *.py,*.pyw, set textwidth=100
106 
107 " Use UNIX (\n) line endings.
108 au BufNewFile *.py,*.pyw,*.c,*.h set fileformat=unix
109 
110 " Set the default file encoding to UTF-8:
111 set encoding=utf-8
112 
113 " For full syntax highlighting:
114 let python_highlight_all=1
115 syntax on
116 
117 " Keep indentation level from previous line:
118 autocmd FileType python set autoindent
119 
120 " make backspaces more powerfull
121 set backspace=indent,eol,start
122 
123 
124 "Folding based on indentation:
125 autocmd FileType python set foldmethod=indent
126 "use space to open folds
127 nnoremap <space> za
128 "----------Stop python PEP 8 stuff--------------
129 
130 "js stuff"131 autocmd FileType javascript setlocal shiftwidth=2 tabstop=2

7. sudo vim   

      :PluginInstall

8. 完成!

猜你喜欢

转载自blog.csdn.net/wto882dim/article/details/88611208