其他分享
首页 > 其他分享> > VIM配置【增量更新】

VIM配置【增量更新】

作者:互联网

自己的vim配置

"HELP
"key bindings:
"<F1>: HELP vimdoc 
"<F2>: Toggle: NERDTreeToggle
"<F4>: autoformat - yapf
"<F7>: Toggle: linenumber
"<F8> :Toggle: TagbarToggle  
"<F11>:Toggle: paste mode

"================= ALL CONFIGURATION START ===============================
set nocompatible
filetype off
call plug#begin('~/.vim/plugged')
Plug 'junegunn/vim-easy-align'
Plug 'w0rp/ale'
Plug 'Chiel92/vim-autoformat'
Plug 'Yggdroot/indentLine'
Plug 'Valloric/YouCompleteMe'
Plug 'scrooloose/nerdcommenter'
Plug 'scrooloose/nerdtree'
Plug 'tpope/vim-surround'
Plug 'majutsushi/tagbar'
Plug 'mhinz/vim-startify'
Plug 'jiangmiao/auto-pairs'
Plug 'chxuan/change-colorscheme'
Plug 'flazz/vim-colorschemes'
Plug 'junegunn/fzf', { 'dir': '~/.vim/fzf', 'do': './install --all'  }
Plug 'junegunn/fzf.vim'
Plug 'yianwillis/vimcdoc'
"Plug 'vim-latex/vim-latex'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'haya14busa/incsearch.vim'
Plug 'ludovicchabant/vim-gutentags' 
call plug#end()

"==============BASIC CONFIGURATION=====================
filetype plugin indent on
syntax on
set mouse=                     "set mouse= means mouse can not be used in vim at any mode"
set t_Co=256                   " 在终端启用256色
set backspace=2                " 设置退格键可用
set encoding=utf-8

"Leader Key
nnoremap <SPACE> <Nop>
let mapleader=" "

"toggle: paste
set pastetoggle=<F11>

"toggle: linenumber
nmap <F7> :set invnumber<CR>

"indent
set smartindent
set autoindent
set expandtab                                         " convert TAB to space
set softtabstop=4                                     " set width of one TAB

"edit
set writebackup                             "保存文件前建立备份,保存成功后删除该备份
set noswapfile
set undofile
set autoread "renew file when modified outside
set nowrap "do not warp line automatically

"search
set hlsearch
set incsearch       "在输入要搜索的文字时,实时匹配
set ignorecase      "搜索模式里忽略大小写
set smartcase       "如果搜索模式包含大写字符,不使用 'ignorecase' 选项,只有在输入搜索模式并且打开 'ignorecase' 选项时才会使用
set showmatch

" insert mode move
imap <c-k> <Up>
imap <c-j> <Down>
imap <c-h> <Left>
imap <c-l> <Right>

" Status line
"set cmdheight=2                                       "设置命令行的高度为2,默认为1
set cursorline                                        "突出显示当前行
set ruler
set showcmd
set showmode

"==============PLUGIN CONFIGURATION===============================

"=============== <airline> ===================
let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
let g:airline#theme = 'atomic'

"===============<<colorscheme>>=====================
colorscheme space-vim-dark
hi Comment guifg=#5C6370 ctermfg=59 "Comment grey color

"========== <fzf> ==================================
nnoremap <silent> <C-p> :Files<CR>

"========== <ALE configuration> ====================
let b:ale_warn_about_trailing_whitespace = 0
let g:ale_echo_msg_error_str = 'ERROR'
let g:ale_echo_msg_warning_str = 'WARNING'
let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'

" show side
let g:ale_sign_column_always = 1
let g:ale_set_highlights = 0

" config figure
let g:ale_sign_error = '✗'
let g:ale_sign_warning = '⚡'
"<Leader>s触发/关闭语法检查
nmap <Leader>s :ALEToggle<CR>

"===========<autoformat configuration>=================
let g:formatdef_jxm = '"yapf --style=google "'
let g:formatters_python = ['jxm']
noremap <F4> :Autoformat<CR>

"=========== <indentline> =============================
nmap <leader>il :IndentLinesToggle<CR>
let g:indentLine_color_term = 239 "set indentline color

"==========  <nerdcommenter config> ===================
let NERDSpaceDelims = 1                     "在左注释符之后,右注释符之前留有空格
nmap <F2> :NERDTreeToggle<CR>

"========== <youcompleteme> ==========================
let g:ycm_add_preview_to_completeopt = 0
let g:ycm_show_diagnostics_ui = 0
let g:ycm_server_log_level = 'info'
let g:ycm_min_num_identifier_candidate_chars = 2
let g:ycm_collect_identifiers_from_comments_and_strings = 1
let g:ycm_complete_in_strings=1
let g:ycm_key_invoke_completion = '<c-z>'
noremap <c-z> <NOP>
set completeopt=menu,menuone
"modify complete color
highlight PMenu ctermfg=0 ctermbg=242 guifg=black guibg=darkgrey
highlight PMenuSel ctermfg=242 ctermbg=8 guifg=darkgrey guibg=black
" complete with min 2 candidate chars on some file types
let g:ycm_semantic_triggers =  {
                        \ 'c,cpp,python,java,go,erlang,perl': ['re!\w{2}'],
                        \ 'cs,lua,javascript': ['re!\w{2}'],
                        \ }
let g:ycm_filetype_whitelist = {
                        \ "c":1,
                        \ "cpp":1,
                        \ "go":1,
                        \ "python":1,
                        \ "sh":1,
                        \ "zsh":1,
                        \ }
let g:ycm_filetype_blacklist = {
                        \ 'markdown' : 1,
                        \ 'text' : 1,
                        \ 'pandoc' : 1,
                        \ 'infolog' : 1,
                        \ 'xml' : 1,
                        \}
"======== <guntentags> =============================
set tags+=~/.cache/tags/
" gutentags搜索工程目录的标志,碰到这些文件/目录名就停止向上一级目录递归 "
let g:gutentags_project_root = ['.root', '.svn', '.git', '.project']

" 所生成的数据文件的名称 "
let g:gutentags_ctags_tagfile = '.tags'

" 将自动生成的 tags 文件全部放入 ~/.cache/tags 目录中,避免污染工程目录 "
let s:vim_tags = expand('~/.cache/tags')
let g:gutentags_cache_dir = s:vim_tags
" 检测 ~/.cache/tags 不存在就新建 "
if !isdirectory(s:vim_tags)
   silent! call mkdir(s:vim_tags, 'p')
endif

" 配置 ctags 的参数 "
let g:gutentags_ctags_extra_args = ['--fields=+niazS', '--extra=+q']
let g:gutentags_ctags_extra_args += ['--c++-kinds=+pxI']
let g:gutentags_ctags_extra_args += ['--c-kinds=+px']
"======== <tagbar> ===============================
let g:tagbar_ctags_bin='/usr/bin/ctags' 
let g:tagbar_width=30
let g:tagbar_right=1  
map <F8> :TagbarToggle<CR>  

 

标签:Plug,set,tags,更新,vim,let,ycm,增量,VIM
来源: https://www.cnblogs.com/jxmer/p/11526927.html