工欲善其事必先利其器系列之(四):Vimベースの補完ジャンププラグインYouCompleteMeのDockerミラーを構築し、開発環境をワンタッチで配置する

17525 ワード

日付
作成者
バージョン#バージョン#
コメント
2021-03-24
dingbin
V1.0
C++プログラマーの日常的な開発では、コンピュータの変更やサーバの変更など、必要以上に貴重な時間を費やすことが避けられません.vimのYouCompleteMe(略称YCM)プラグインは優れたC/C++言語自動補完ジャンプ機能を実現し、vimを利用してC/C++コード編集を行うための必須の神器の一つである.その後、実際のYCMのインストールはpythonダイナミックリンクライブラリだけでなく、特定の高バージョンのgccやclang、clangdやcmakeなどにも依存します.これらのフロントコンポーネントの準備にも時間と労力がかかります.これに鑑みて,VimベースのC++補完ジャンププラグインYouCompleteMeのDockerミラーを構築し,任意のマシン上のC++開発環境の構築をワンタッチで完了する新しい遊び方を紹介し,実際の操作の詳細と直接利用可能なdockerミラーの成果を示した.具体的な操作方法は以下の通りです.
環境準備
時間:2021-03-24
マシン構成:CentOS Linux release 7.5.1804(Core)、8コア12 G
ベースのdockerミラーの作成
現在時刻の最新バージョンのvimとYoucompleteMeプラグインのインストールを検討します.YouCompleteMeの公式サイトで紹介されているインストール方法を参照すると、vim/gcc/clangd/cmake/pythonは比較的高いバージョンでインストールに成功する必要があります.私たちはdockerミラーを作るために、古いベースosを選ぶことはできません.YCM公式サイトのアドバイスを参考に、基本OSはubuntu 20.04 LTSを選択します.hub.docker.comに直接作成されたミラーファイル.プロファイルは以下の3つのプロファイルを用意する必要があります.本文は直接原文の内容を以下のように貼り付けます.
vimプロファイルvimrc
set nocompatible              " be iMproved, required
filetype off                  " required
set encoding=utf-8
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'flazz/vim-colorschemes'
Plugin 'godlygeek/csapprox'
Plugin 'Valloric/YouCompleteMe'
call vundle#end()            " required
filetype plugin indent on    " required

set cst
set csto=1 
set nocsverb
set csverb

"set smd        "set showmode
"set sc         "set showcmd

set aw         "set autowrite
set awa        "set autowriteall

set  title

"                           
if has("autocmd")
  autocmd BufRead *.txt set tw=78
  au BufReadPost * exe "normal! g`\""
endif

"         
syntax enable
syntax on     "   syn on

"               
"set nows          "set nowrapscan              
set ws

"               
set hls    "set hlsearch
"                
"set nohls  "set nohlsearch 

"          set cursorline
set cul         "      set nocul
"set nocul


"                       
set is       "set incsearch
"                       
"set nois       "set noincsearch

"   backspace       ,    ,     ,   
set backspace=indent,eol,start

set ic   "    set noic
"set scs  "    set noscs

"               ,    
set wildmenu

"            
"set foldmethod=syntax
"         
set foldmethod=manual
"    vim         
set foldlevel=100
set fdc=1      "set foldcolumn=1 

"          
set helplang=cn
"set helplang=en

"  C     (indent)
set cin   

"    
set nu
"set nonu


"  256  
set t_Co=256
"      
"colorscheme    colo
"colo colorful 
"colo white2 
colo  desert
"colo  night
"colo  navajo
"colo  lucius
"colo  blackdust
"colo  freya
"colo  darkslategray
"colo  torte
"colo  fruidle
"colo colorful

"              
set ru "set ruler
"               
"set noru "set noruler

"       
set history=1000

"      
"filetype on
filetype plugin on
"                 
filetype plugin indent on   

"                 
set ww=b,s,,[,]  ",h,l

"Alt          
set winaltkeys=no

"    GBK UTF-8  
set fileencodings=utf-8,ucs-bom,gbk,cp936
set fileencoding=utf-8
set encoding=utf-8
"          Vim,    termencoding           。  :
set termencoding=utf-8 

"    ctags      
"map    : !  ${HOME}/tools/gen_tags_by_dingbin.bash "%:p:h" z6tags  
"map    : !  ${HOME}/tools/gen_tags_by_dingbin.bash "%:p:h" oatags  
"map    : !  ${HOME}/tools/gen_tags_by_dingbin.bash "%:p:h" qttags  

"====================================================================================================================
"map     : cs show : let @i = &tags  :let @j = $CSCOPE_TAGS  : !genvimtags -vimCtags i -vimCscope j  :so ${VIM_SCRIPT_HOME}/configure/vimSourceFile 
"map     : cs show : let @i = &tags  :let @j = $CSCOPE_TAGS  : !genvimtags  -g -vimCtags i -vimCscope j  :so ${VIM_SCRIPT_HOME}/configure/vimSourceFile  
"====================================================================================================================

"  grep      
"nnoremap   :Grep

"-----------------------------------------------------
"       ,       4    。
" shiftWidth,        ,  <>,cindent
set shiftwidth=4         

"softtabstop,sts,   0,
"      ,                  
set softtabstop=4     "set sts=4

"       Tab      。
"          Tab      ,              ,        Tab      。 
"       ,     tab   ,   CTRL-V CTRL-Q,   tab   
set et    "      set noet
"Tab     4    。
set ts=4      " set tabstop=4

"Tab      !
"nnoremap   :tabnext:TlistClose:TlistToggle
"nnoremap   :tabprev:TlistClose:TlistToggle
"nnoremap   :tabnext:TlistClose
"nnoremap   :tabprev:TlistClose


""  tab    
"map tn :tabnext
"map tp :tabprevious
"map td :tabnew .
"map te :tabedit
"map tc :tabclose
""map tf :tabnew %:p:TlistClose:TlistToggle
"map tf :tabnew %:p:TlistClose

"        
set nobackup                                                        
"                       
set wb          "set writebackup
"set nowb         "set nowritebackup

"     ,             
set sm            "set showmatch               
"            
set matchtime=2

"    
set magic                   

"                ,       vim     
set hidden                  

"             
set smartindent             
set autoindent
"             。         cindent   ,           C/C++         。
set ai

"      Ctrl+c   
"vmap  "+y
"            e b   word             
"set keymodel=                    "      
set keymodel=startsel,stopsel     "     

"visual        (*,#)  
vnoremap  *  y/"  
vnoremap  #  y?"  
nnoremap  g[  :tag =expand("")
vnoremap  g[  :tag *

:inoremap ( ()i
:inoremap [ []i
:inoremap ;; A;

"      Ctrl+ h,j,k,l           、 、 、    
inoremap  
inoremap  
inoremap  
inoremap  
"      ctrl+ w,b             ctrl+w(      ),ctrl+b(
"      )
inoremap  b
inoremap  w
"      ctrl+ f(front),Ctrl+e(end)             , 
inoremap   
inoremap   
"     ctrl + d,        backspace ,
"     ctrl + x,        delete ,
inoremap  
inoremap  

"        ,               
set selection=inclusive
"-----------------------------------------------------

"-----------------------------------------------------
"     。       ,       ,            。          ,              。
set nowrap
"set wrap

"            
set tw=80       "set textwidth=80

"       。          ,                     。
set guioptions-=b
"  vim GUI   toolbar
set guioptions+=T
"  vim GUI   menubar
set guioptions+=m

"    ,         ,             
"           ,  :         ,      
set lbr           "set linebreak
"             。 m              ,             。
"B              ,             。                   。
set fo+=mB

"    
"set fileencoding=gbk
"set guifont=Courier\ 11 
"set guifont=Inconsolata\ Medium\ 9  "      vim  
"set guifont=Bitstream_Vera_Sans_Mono:h10:cANSI
"set gfw=  :h10.5:cGB2312
set guifont=Bitstream\ Vera\ Sans\ Mono\ 13

"          ,       
set mousemodel=popup
"       
set selectmode=

"       ctrl+d,ctrl+u   ,        ,   
set scr=4

"-----------------------------------------------------

"""""""""""""""""""""""""""""""
""Taglist plugin settings 
"""""""""""""""""""""""""""""""
"let Tlist_Auto_Highlight_Tag = 1
"let Tlist_Hightlight_Tag_On_BufEnter = 1
"let Tlist_GainFocus_On_ToggleOpen = 0   "if 0 focus at code window, if 1 focus at tag window
"
""  vim    taglist
"let Tlist_Auto_Open = 0 
"
""            tag ,        
"let Tlist_Show_One_File = 1
"
""    taglist          ,    vim
"let Tlist_Exit_OnlyWindow = 1
"
""                      
"let Tlist_File_Fold_Auto_Close = 0
"
"" taglist         ,      
"let Tlist_Use_Right_Window=1 
"
""  taglist  
"let Tlist_Show_Menu = 1
"
""taglist window width
"let Tlist_WinWidth = 40
"
"let Tlist_Process_File_Always = 1
"
""       taglist         ,      .
"let Tlist_Inc_Winwidth = 1
""     ,    tag        ,       
"let Tlist_Compact_Format = 1
"" tag        ,  "order"  "name",    order,    s  ,
"let Tlist_Sort_Type = "order"
"
""  +     Tab  
""  Gnome-terminal     ,    Terminal     TAB  ,  ALT+     
""        .        ,     :
"
"noremap  1gt
"noremap  2gt
"noremap  3gt
"noremap  4gt
"noremap  5gt
"noremap  6gt
"noremap  7gt
"noremap  8gt
"noremap  9gt
"noremap  10gt
"
"
"""""""""""""""""""""""""""""""
""Winmanager plugin settings 
"""""""""""""""""""""""""""""""
""      
"let g:winManagerWindowLayout='FileExplorer|TagList'
""let g:winManagerWindowLayout = BufExplorer,FileExplorer|TagList"
""let g:winManagerWindowLayout = TagList|FileExplorer,BufExplorer"
"
""  winmanager   ,   25
""let g:winManagerWidth = 30
"
""      winmanager  
"nmap wm :WMToggle
""nmap   :WMToggle
"nmap   :TlistToggle
"
""1)        
""  winmanager.vim, function! StartWindowsManager()     :
"" :wincmd H    wincmd L:
"" for now assume that the explorer windows always stay on the left.
"" TODO: make this optional later
"" make the explorers window always stay on the right ---by chenyong
""        wincmd H
""wincmd L
"
""2)  vim    winmanager
""   vim     winmanager
"let g:AutoOpenWinManager = 0
""    winmanager.vim   :
""set auto open Winmanager 
""if g:AutoOpenWinManager 
""autocmd VimEnter * nested call s:StartWindowsManager()|1wincmd w  
""endif
"
""3)      ,    vim
""        taglist       , taglist.vim    。
""  :function! s:Tlist_Window_Exit_Only_Window()  winbunr(2)  winbunr(3),
""   2      ,   2          ,         : 
""   vimrc     :
""let Tlist_Exit_OnlyWindow=1
"
"
"""""""""""""""""""""""""""""""
""QuickFix plugin settings 
"""""""""""""""""""""""""""""""
"nmap  :cw:cn
"nmap  :cw:cp
"nmap  :cclose
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""
""       quickfix       cscope   
"""""""""""""""""""""""""""""""""""""""""""""""""""""
":set cscopequickfix=s-,g-,c-,d-,i-,t-,e-,f-
"
"
""cscope find"   :
""cs find c|d|e|f|g|i|s|t name
""0   s         C   (      )
""1   g          
""2   d               
""3   c               
""4   t           
""6   e         egrep   
""7   f          
""8   i               
"nmap s :cs find s =expand("")
"nmap g :cs find g =expand("")
"nmap c :cs find c =expand("")
"nmap t :cs find t =expand("")
"nmap e :cs find e =expand("")
"nmap f :cs find f =expand("")
"nmap i :cs find i ^=expand("")$
"nmap d :cs find d =expand("")
"
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""
""           a.vim settings
"""""""""""""""""""""""""""""""""""""""""""""""""""""
""nnoremap   :A 
""A           Buffer    c\h  
""AS              c\h  
""AV              c\h  
""AT               c\h  
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""
""  F11 : set csto=1, F12 : set csto=0
"""""""""""""""""""""""""""""""""""""""""""""""""""""
"nnoremap   :set csto=1  
"nnoremap   :set csto=0  
"
"
"" set cs hotkey
"nmap s :cs find s =expand("")
"nmap g :cs find g =expand("")
"nmap c :cs find c =expand("")
"nmap t :cs find t =expand("")
"nmap e :cs find e =expand("")
"nmap f :cs find f =expand("")
"nmap i :cs find i ^=expand("")$
"nmap d :cs find d =expand("")
"
"" Using 'CTRL-spacebar' then a search type makes the vim window
"" split horizontally, with search result displayed in
"" the new window.
"
"nmap s :scs find s =expand("")
"nmap g :scs find g =expand("")
"nmap c :scs find c =expand("")
"nmap t :scs find t =expand("")