2017年1月27日 星期五

Vundle-Vim Plugin 管理工具和vimrc設定

4.2 Vim + YCM + rust-analyzer

================================================
Older

蠻好用的tool for vim :)
(version: 7.4+)
Install:
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
Setting: (vim ~/.vimrc)
set nocompatible              " be iMproved, required
filetype off                  " required

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

" let Vundle manage Vundle, required
Plugin 'gmarik/vundle'
ref: Here
  • 安裝:
    :PluginUpdate
  • 刪除:
    將Plugin那行給del就行了,然後去 ~/.vim/bundle/下del該資料夾
  • Brief help:
    :PluginList          - list configured plugins
    " :PluginInstall(!)    - install (update) plugins
    " :PluginSearch(!) foo - search (or refresh cache first) for foo
    " :PluginClean(!)      - confirm (or auto-approve) removal of unused plugins
.vimrc
"Install
Plugin 'tpope/vim-fugitive'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'tpope/vim-rails.git'
" 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/'}
" scripts from http://vim-scripts.org/vim/scripts.html
Plugin 'L9'

" CtrlP
Plugin 'ctrlpvim/ctrlp.vim'

" Matchit
Plugin 'vim-scripts/matchit.zip'

" NerdTree
Plugin 'https://github.com/scrooloose/nerdtree.git'
Plugin 'Xuyuanp/nerdtree-git-plugin'

" ctags
"sudo apt-get install exuberant-ctags
" cscope
"sudo apt-get install cscope
" Tagbar
Plugin 'https://github.com/majutsushi/tagbar.git'

" SrcExpl (Source Explorer)
Plugin 'https://github.com/wesleyche/SrcExpl'

" YouCompleteMe
Plugin 'https://github.com/Valloric/YouCompleteMe.git'

" Syntastic
Plugin 'scrooloose/syntastic'

" SimpylFold
Plugin 'tmhedberg/SimpylFold'

filetype plugin indent on     " required
"=============================================================================
"Setting

" SimpylFold 
let g:SimpylFold_docstring_preview=1
set foldmethod=indent
set foldlevel=99
nnoremap  za

" CtrlP
let g:ctrlp_map = '<c-p>'
let g:ctrlp_custom_ignore = { 
  \ 'dir':  '\v[\/]\.(git|hg|svn)$',
  \ 'file': '\v\.(exe|so|dll)$',
  \ }
" NerdTree
nmap <f5> :NERDTreeToggle<cr>

" Tagbar
nmap  :TagbarToggle

" NerdTree plugin for git
let g:NERDTreeIndicatorMapCustom = { 
    \ "Modified"  : "✹",
    \ "Staged"    : "✚",
    \ "Untracked" : "✭",
    \ "Renamed"   : "➜",
    \ "Unmerged"  : "═",
    \ "Deleted"   : "✖",
    \ "Dirty"     : "✗",
    \ "Clean"     : "✔︎",
    \ "Unknown"   : "?" 
    \ }

" Matchit
let b:match_words='\<ifneq\>\|\<ifeq\>:\<else\>:\<endif\>'

" ctags
set tags=./tags,./TAGS,tags;~,TAGS;~

"SrcExpl
nmap <f9> :SrcExplToggle<cr>
let g:SrcExpl_jumpKey = "<enter>"
let g:SrcExpl_gobackKey = "<c-t>"

" YouCompleteMe
set runtimepath+=~/.vim/bundle/YouCompleteMe
let g:ycm_collect_identifiers_from_tags_files = 1           " 开启 YCM 基于标签引擎
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释与字符串中的内容也用于补全
let g:syntastic_ignore_files=[".*\.py$"]
let g:ycm_seed_identifiers_with_syntax = 1                  " 语法关键字补全
let g:ycm_complete_in_comments = 1 
let g:ycm_confirm_extra_conf = 0 
let g:ycm_key_list_select_completion = ['<c-n>', '<Down>']  " 映射按键, 没有这个会拦截掉tab, 导致其他插件的tab不能用.
let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>']
let g:ycm_complete_in_comments = 1                          " 在注释输入中也能补全
let g:ycm_complete_in_strings = 1                           " 在字符串输入中也能补全
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释和字符串中的文字也会被收入补全
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
let g:ycm_show_diagnostics_ui = 0                           " 禁用语法检查
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"       " 回车即选中当前项
nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR>     " 跳转到定义处
"let g:ycm_min_num_of_chars_for_completion=2                 " 从第2个键入字符就开始罗列匹配项

" csopetag
set cscopetag
set csto=0

if filereadable("cscope.out")
    cs add cscope.out
elseif $CSCOPE_DB != ""
    cs add $CSCOPE_DB
endif
set cscopeverbose
nmap zs :cs find s <C-R>=expand("<cword>")<CR><CR>
nmap zg :cs find g <C-R>=expand("<cword>")<CR><CR>
nmap zc :cs find c <C-R>=expand("<cword>")<CR><CR>
nmap zt :cs find t <C-R>=expand("<cword>")<CR><CR>
nmap ze :cs find e <C-R>=expand("<cword>")<CR><CR>
nmap zf :cs find f <C-R>=expand("<cfile>")<CR><CR>
nmap zi :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
nmap zd :cs find d <C-R>=expand("<cword>")<CR><CR>

" Syntastic 
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 1
let g:syntastic_aggregate_errors = 1
let g:syntastic_warning_symbol='⚠'
let g:syntastic_error_symbol='✗'
let g:syntastic_python_checkers = ['python', 'pyflakes']

vim-bookmarks:



CtrlP: (Once CtrlP is open:)
  • Use <c-t> or <c-v>, <c-x> to open the selected entry in a new tab or in a new split.
  • Press <c-f> and <c-b> to cycle between modes.
YouCompleteMe:
  1. requires Vim compiled with Python 2.x or Python 3.x support
    用vim --version來檢查支援的語言,
    如果看到 -python, -python3 (-代表還沒支援)
    安裝:
      sudo apt-get install vim-nox (python3)
      sudo apt-get install vim-nox-py2 (python2)
  2. 安裝 clang和cmake
      sudo apt-get install clang cmake
  3. 支援C-family
      $ cd ~/.vim/bundle/YouCompleteMe
      $ ./install.sh --clang-completer
ctags:
  1. 安裝:
    $ sudo apt-get install exuberant-ctags
  2. 專案下:
    $ ctags -R *
    $ ctags -R -h ".h.c.cpp.java" (指定檔案)
  3. 使用:
    Ctrl + ] 跳到該名稱的定義
    Ctrl + t 跳回到剛離開的位置
  4. vimrc
    加入 set tags=./tags,./TAGS,tags;~,TAGS;~
Syntastic:
  1. for python
    安裝pyflakes:
  2.     $ sudo apt-get install python-pip
        $ sudo apt-get install python3-pip
        $ pip2 install pyflakes
        $ pip3 install pyflakes
    執行:
        $ python3 -m pyflakes
ref:

沒有留言:

張貼留言