ubuntu 18.0Lts +YouCompleteMe插件安裝

1. 經過sudo apt安裝的cmake  g++ 以及gitjavascript

 

2設置python的默認版本php

echo alias python=python2 >> ~/.bashrc
source ~/.bashrc

3.下載plug插件管理器,具體安裝方式參照gitcss

      https://github.com/junegunn/vim-plughtml

參照網頁的安裝方式:前端

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vimvue

4.clone YCM java

cd ~/vim.plugged  node

mrdir  YouCompleteMepython

git clone  https://github.com/ycm-core/YouCompleteMe.gitcss3

注意gitclone 後還有不少依賴庫的沒有下載 cd  YouCompleteMe

執行    git submodule update --init --recursive  下載子依賴庫

5.檢測環境並編譯YCM

cd  YouCompleteMe

python run_tests.py

經過pip以及apt install 安裝對應所缺乏的模塊

注意:在此安裝時候制定python的安裝版本 

$ python2 -m pip install modename

其中有一個模塊built缺失了是安裝future模塊

$ python2 -m pip install future

testok以後

執行python install.py就行

 

 

 

6.下載安裝以後就是對應插件的配置,配置文件是 ~/vimrc

配置文檔參照     

https://github.com/Johnyewen123/At-config  劉傲天的配置

注意修改python2版本

" YouCompleteMe let g:ycm_server_python_interpreter = '/usr/bin/python2' let g:ycm_python_binary_path = 'python2'

而後執行PlugInstall

以下

call plug#begin('~/.vim/plugged') " 下面的我安裝的插件

" Plug 'Valloric/YouCompleteMe', {'on': [], 'do': './install.py --clang-complete --go-complete --system-libclang --java-complete'}
 Plug '~/.vim/plugged/YouCompleteMe' Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'} Plug 'ryanoasis/vim-devicons', Plug 'majutsushi/tagbar', {'on': 'TagbarToggle'} " Tab縮進線
Plug 'Yggdroot/indentLine' Plug 'jiangmiao/auto-pairs' Plug 'ntpeters/vim-better-whitespace' Plug 'iamcco/markdown-preview.vim', {'for': 'markdown'} Plug 'Chiel92/vim-autoformat', {'on': 'Autoformat'} Plug 'sgur/vim-lazygutter' Plug 'SirVer/ultisnips' Plug 'fisadev/vim-isort', {'on': 'Isort'} Plug 'itchyny/lightline.vim' Plug 'scrooloose/nerdcommenter', {'on': '<plug>ERDCommenterToggle'} Plug 'tpope/vim-surround' Plug 'ryanoasis/vim-devicons' Plug 'junegunn/vim-easy-align', {'on': '<Plug>(EasyAlign)'} Plug 'tpope/vim-sensible' Plug 'rhysd/clever-f.vim' Plug 'vim-scripts/stlrefvim' Plug 'Mizuchi/STL-Syntax', {'for': 'cpp'} " find & search & move
Plug 'Yggdroot/LeaderF', {'on': ['LeaderfFile', 'LeaderfFunction']} Plug 'easymotion/vim-easymotion', {'on': ['<Plug>(easymotion-bd-w)', '<Plug>(easymotion-bd-jk)']} " syntax highlight
Plug 'Glench/Vim-Jinja2-Syntax', {'for': 'html'} Plug 'liuchengxu/space-vim-dark' Plug 'PotatoesMaster/i3-vim-syntax', {'for': 'i3'} Plug 'posva/vim-vue', {'for': 'vue'} Plug 'luochen1990/rainbow'
" html插件 讓他們只在寫前端文件的時候起做用
Plug 'mattn/emmet-vim', {'for':['html', 'css', 'js']} Plug 'hail2u/vim-css3-syntax', {'for':['html', 'css', 'js']} Plug 'groenewege/vim-less', {'for':['html', 'css', 'js']} Plug 'Raimondi/delimitMate', {'for':['html', 'css', 'js']} Plug 'sophacles/vim-processing', {'for':['html', 'css', 'js']} Plug 'MarcWeber/vim-addon-mw-utils' Plug 'tomtom/tlib_vim' Plug 'garbas/vim-snipmate'
" 管理tab
Plug 'ervandew/supertab'
" 語法補全
Plug 'honza/vim-snippets', {'on':[]} call plug#end() "插件末尾 " 延時加載語法補全
augroup load_snippets autocmd! autocmd InsertEnter * call plug#load('vim-snippets') | autocmd! load_snippets augroup END augroup load_ycm autocmd! autocmd InsertEnter * call plug#load('YouCompleteMe') | autocmd! load_ycm augroup END " vim setting
set ttyfast set scrolloff=7            " 滾動的時候有7行多餘
set updatetime=100         " update time
set termguicolors          " true color
set lazyredraw             " lazy draw
set nofoldenable           " 禁用摺疊"
set nocompatible           " 去除vi 和vim 的一致性
set nu                     " 設置行號
filetype plugin indent on  " 開啓類型檢查
syntax on                  " 開啓語法高粱
set autoindent             " 自動縮進
set cindent                " C語言的縮進格式
set smartindent            " 當遇到右花括號(}),則取消縮進形式
set shiftround set ruler                  " 底部的行號等顯示
set novisualbell           " 去掉輸入錯誤的提示聲音 " 關於tab和space的一些setting
set softtabstop=2          " 逢2空格進1製表符
set expandtab              " expandtab,輸入一個tab,將被展開成softtabstop值個空格,若是softtabstop=4,那麼一個tab就會被替換成4個空格
set tabstop=2              " 定義tab所等同的空格長度
set shiftwidth=2           " 程序中自動縮進所使用的空白長度指示的
set t_md=                  " 禁用粗體
set t_Co=256               " 開啓256色 " file type setting
set fileformat=unix        " filetype 文件格式主要區別在於Windows和Unix的換行符不一樣
set encoding=utf-8         " 編碼utf-8
set cmdheight=1            " vim命令模式下的命令行高度,最下方命令行
set noswapfile             " 禁止生產交換文件
set relativenumber         " 相對模式的行號 " set norelativenumber " 行號爲不是相對模式 set ignorecase             " 忽略大小寫
set shortmess=I            " 不顯示vim版本信息
set noshowmode             " 在底部命令行不顯示當前模式
set nrformats=             " 使vim將全部數字當成十進制
set timeoutlen=300        " 設置leader鍵延遲爲300ms
set splitbelow set splitright set showcmd set hidden set laststatus=2           " 設置狀態航
set hlsearch " ctags setting
set tags=./tags " vimsymotion-bd-jk) " 跳轉到任意行首" colorscheme and color setting
colorscheme space-vim-dark hi CursorLineNR cterm=bold gui=bold hi lineNr guibg=NONE ctermbg=NONE hi Normal guibg=NONE ctermbg=NONE hi SignColumn ctermbg=NONE guibg=NONE hi Comment guifg=#5C6370 ctermfg=59 gui=NONE hi CursorLineNr guibg=NONE ctermbg=NONE hi Pmenu guibg=NONE ctermbg=NONE guifg=#af87d7 guibg=NONE hi TabLineFill ctermfg=NONE ctermbg=NONE guifg=NONE guibg=NONE hi TabLine ctermfg=NONE ctermbg=NONE guifg=NONE guibg=NONE hi TabLineSel ctermfg=red ctermbg=NONE guifg=#d75faf guibg=NONE hi Search cterm=underline ctermfg=red ctermbg=NONE guifg=red guibg=NONE gui=underline highlight OverLength ctermbg=red ctermfg=white guibg=#592929 let mapleader="," map <leader>n :NERDTreeToggle<cr> map <leader><leader>t :LeaderfFunction!<cr> "查找函數
map <F1> <nop>
" map j gj " map k gk
vnoremap <leader>y "+y
vnoremap <leader>p "+p " nnoremap <F5> :vsplit $MYVIMRC<cr>
nnoremap <F6> :source $MYVIMRC<cr> nnoremap <C-h> <C-w>h nnoremap <C-j> <C-w>j nnoremap <C-k> <C-w>k nnoremap <C-l> <C-w>l nnoremap <down> <C-w>- nnoremap <up> <C-w>+ nnoremap <left> <C-w>< nnoremap <right> <C-w>> noremap <c-a> I noremap <c-e> A noremap ; : noremap <leader>w :w<cr> noremap <leader>q :q!<cr> noremap <leader>e :wq<cr> autocmd FileType python noremap <leader>c A:<cr>
" 消除顏色 好比搜索上的顏色 消除掉這個顏色
noremap <leader><space> :nohlsearch<cr>
" 加載文件
noremap <leader>f :LeaderfFile<cr> autocmd FileType python noremap <leader><leader>d :Pydocstring<cr> noremap H ^ noremap L $ " 跳轉到不一樣的窗口
noremap <leader>1 1gt noremap <leader>2 2gt noremap <leader>3 3gt noremap <leader>4 4gt noremap <leader>5 5gt noremap <leader>6 6gt noremap <leader>7 7gt noremap <leader>8 8gt noremap <leader>9 9gt noremap <leader>0 :tablast<cr> noremap D d$ noremap Y y$ noremap <tab> % inoremap <leader>w <Esc>:w<cr> inoremap <C-a> <esc>I inoremap <C-e> <esc>A inoremap <leader>q <Esc>:wq<cr> inoremap <leader>e = inoremap <leader>r - inoremap <leader>a + inoremap <leader>u _ inoremap <leader>i ____<Esc>hi inoremap <leader>n <Esc>o inoremap <leader>b ()<Esc>i inoremap <leader>s []<Esc>i inoremap <leader>t {}<Esc>i inoremap <leader>m * inoremap <leader>d -> inoremap <leader>f <Esc>bi"<Esc>ea" inoremap <leader>j <Esc>ji inoremap <leader>k <Esc>ki inoremap jj <Esc>j inoremap kk <Esc>k inoremap <leader>O <Esc>O inoremap <leader>o <Esc>o inoremap <c-l> <right>


" 輸入快捷方式
iabbrev im import cabbrev tn tabnew cabbrev install PlugInstall " vim tables
noremap gn :tabn<CR> noremap gp :tabp<CR>

" terminal mapping
tnoremap <Esc> <C-\><C-n> tnoremap <leader>w <C-\><C-n> tnoremap <leader>q <C-\><C-n>:q!<cr>

if has("nvim") nnoremap <leader>o :below 10sp term://$SHELL<cr>i
endif tnoremap <C-h> <C-\><C-n><C-w>h tnoremap <C-j> <C-\><C-n><C-w>j tnoremap <C-k> <C-\><C-n><C-w>k tnoremap <C-l> <C-\><C-n><C-w>l tnoremap gn <C-\><C-n>:tabn<CR> tnoremap gp <C-\><C-n>:tabp<CR>


" vim autocmd " 配置vim打開時vim自動定位到上次的位置
if has("autocmd") autocmd BufRead *.txt set tw=78 autocmd BufReadPost * \ if line("'\"") > 0 && line ("'\"") <= line("$") | \ exe "normal g'\"" | \ endif endif " 判斷文件類型
set cursorline " 插件相關配置
let g:gitgutter_map_keys = 0 "關閉全部鍵位映射

" vim-autoformater
let g:formatdef_harttle = '"astyle --style=attach --pad-oper"' let g:formatters_cpp = ['harttle'] let g:formatter_yapf_style = 'google' noremap <leader>a :Autoformat<CR>

" indentLine " 設置豎線顏色
let g:indentLine_color_gui = '#E64A19' let g:indentLine_char_list = ['|', '¦', '', ''] let g:indentLine_enabled = 1 let g:indentLine_fileTypeExclude = ['json'] " indentLine 不在json文件中加載, 目的是顯示雙引號


" ultisnips
let g:UltiSnipsExpandTrigger="<c-j>" let g:UltiSnipsJumpForwardTrigger="<c-f>" let g:UltiSnipsJumpBackwardTrigger="<c-b>" let g:UltiSnipsEditSplit="vertical" let g:UltiSnipsSnippetDirectories = ['~/.vim/UltiSnips', 'UltiSnips'] " nerdcommenter
let g:NERDSpaceDelims = 1 let g:NERDTrimTrailingWhitespace = 1 let g:NERDCreateDefaultMappings = 0 map <leader>z <plug>NERDCommenterToggle " vim-isort
let g:vim_isort_map = '' let g:vim_isort_python_version = 'python3'


" tagbar
let g:tagbar_width = 30 nmap <F8> :TagbarToggle<CR>

" YouCompleteMe
let g:ycm_server_python_interpreter = '/usr/bin/python3' let g:ycm_python_binary_path = 'python3'
" 輸入兩個字符後開始補全
let g:ycm_min_num_identifier_candidate_chars = 2 let g:ycm_seed_identifiers_with_syntax = 1 let g:ycm_collect_identifiers_from_tags_files = 1 let g:ycm_add_preview_to_completeopt = 0 let g:ycm_server_keep_logfiles = 1 let g:ycm_autoclose_preview_window_after_completion = 1 let g:ycm_max_num_candidates = 14 let g:ycm_max_num_identifier_candidates = 7
set completeopt=menu,menuone   " 讓Vim的補全菜單行爲與通常IDE一致(參考VimTip1228)
let g:ycm_global_ycm_extra_conf = "~/.ycm_extra_conf.py" nnoremap <leader>j :YcmCompleter GoToDeclaration<CR> nnoremap <leader>k :YcmCompleter GoToDefinition<CR> nnoremap <leader>l :YcmCompleter GoToDefinitionElseDeclaration<CR> nnoremap <F6> :YcmForceCompileAndDiagnostics<CR>    "force recomile with syntastic " 在插入模式下按兩下leader退出插入模式
inoremap <leader><leader> <Esc>:w<CR>
" 在正常模式下按兩下leader進入插入模式
noremap <leader><leader> a inoremap <leader>x <Esc>xa let g:ycm_cache_omnifunc=0 let g:ycm_complete_in_comments = 1 let g:ycm_complete_in_strings = 1 let g:ycm_show_diagnostics_ui = 0 "close syntax checked
let g:ycm_filetype_blacklist = { \ 'tagbar' : 1, \ 'nerdtree' : 1, \} let g:ycm_semantic_triggers = { \ 'c' : ['->', '.'], \ 'objc' : ['->', '.'], \ 'cpp,objcpp' : ['->', '.', '::'], \ 'perl' : ['->'], \ 'php' : ['->', '::'], \ 'cs,java,javascript,d,vim,ruby,python,perl6,scala,vb,elixir,go' : ['.'], \ 'lua' : ['.', ':'], \ 'erlang' : [':'], \ 'css' : ['re!^\s{4}', 're!:\s+'], \ 'html' : ['</'], \ } " NERDTree setting
let NERDTreeShowLineNumbers=1 let NERDTreeAutoCenter=1 let NERDTreeShowHidden=1 " 是否顯示隱藏文件
let NERDTreeWinSize=20 " 設置寬度 " autocmd StdinReadPre * let s:std_in=1 " autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif " 按下 F2 調出/隱藏 NERDTree
map <F2> :NERDTreeToggle<CR>
" autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") &&b:NERDTreeType == "primary") | q | endif
let g:NERDTreeIgnore = ['\.pyc$', '^__pycache__$', '\.git$', '^migrations$', 'node_modules', '^.pytest_cache$', '^.mypy_cache$'] " autocmd StdinReadPre * let s:std_in=1 " autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif


" lightline
let g:lightline = { \ 'colorscheme': 'one', \ } let g:Lf_ReverseOrder = 1 let g:Lf_WindowHeight = 0.30 let g:Lf_CursorBlink = 0 let g:Lf_WildIgnore = { \ 'dir': ['.svn','.git','.hg', 'anaconda3', 'Download', 'node_modules', '.*', 'venv', 'migrations', '__pycache__'], \ 'file': ['*.sw?','~$*','*.bak','*.exe','*.o','*.so','*.py[cod]'] \} set cursorcolumn set cursorline hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkgreen guifg=white hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white guibg=darkgreen guifg=white " 打開文件自動跳轉到上一次的光標位置
if has("autocmd") au BufReadPost * if line("`\"") > 1 && line("`\"") <= line("$") | exe "normal! g`\"" | endif " for simplicity, "  au BufReadPost * exe "normal! g`\"", is Okay. endif " 光標限制,儘可能讓你的工做區放置在屏幕當中
set scrolloff=24

" 解決tab衝突
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>'] let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>'] let g:SuperTabDefaultCompletionType = '<C-n>'

" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>" let g:UltiSnipsJumpForwardTrigger = "<tab>" let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"

" 設置python文件的縮進長度
autocmd FileType python set sw=2 autocmd FileType python set ai autocmd FileType python set ts=2 autocmd FileType python set sts=2

 7.效果以下,終於裝好了!!!!!!!!

相關文章
相關標籤/搜索