" An example for a vimrc file.
"
" Maintainer: Bram Moolenaar
" Last change: 2011 Apr 15
"
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
set nu
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
" Use Vim settings, rather than Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap u
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Convenient command to see the difference between the current buffer and the
" file it was loaded from, thus the changes you made.
" Only define it when not defined already.
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" Make sure you use single quotes
Plug 'https://github.com/joshdick/onedark.vim'
Plug 'itchyny/lightline.vim'
Plug 'sheerun/vim-polyglot'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'vim-jp/vim-cpp'
Plug 'fholgado/minibufexpl.vim'
Plug 'vim-scripts/taglist.vim'
" Shorthand notation; fetches https://github.com/junegunn/vim-easy-align
"Plug 'junegunn/vim-easy-align'
" Any valid git URL is allowed
Plug 'https://github.com/junegunn/vim-github-dashboard.git'
" Multiple Plug commands can be written in a single line using | separators
"Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
" On-demand loading
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
" Using a non-master branch
Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
" Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
"Plug 'fatih/vim-go', { 'tag': '*' }
" Plugin options
Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' }
" Plugin outside ~/.vim/plugged with post-update hook
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
" Unmanaged plugin (manually installed and updated)
Plug '~/my-prototype-plugin'
" Initialize plugin system
call plug#end()
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 | exe 'cd '.argv()[0] | endif
map :NERDTreeToggle
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
" NERDTress File highlighting
function! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg)
exec 'autocmd filetype nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifg
exec 'autocmd filetype nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#'
endfunction
call NERDTreeHighlightFile('jade', 'green', 'none', 'green', '#151515')
call NERDTreeHighlightFile('ini', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('md', 'blue', 'none', '#3366FF', '#151515')
call NERDTreeHighlightFile('yml', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('config', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('conf', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('json', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('html', 'yellow', 'none', 'yellow', '#151515')
call NERDTreeHighlightFile('styl', 'cyan', 'none', 'cyan', '#151515')
call NERDTreeHighlightFile('css', 'cyan', 'none', 'cyan', '#151515')
call NERDTreeHighlightFile('coffee', 'Red', 'none', 'red', '#151515')
call NERDTreeHighlightFile('js', 'Red', 'none', '#ffa500', '#151515')
call NERDTreeHighlightFile('php', 'Magenta', 'none', '#ff00ff', '#151515')
if (has("autocmd"))
augroup colorextend
autocmd!
" Make `Function`s bold in GUI mode
autocmd ColorScheme * call onedark#extend_highlight("Function", { "gui": "bold" })
" Override the `Statement` foreground color in 256-color mode
autocmd ColorScheme * call onedark#extend_highlight("Statement", { "fg": { "cterm": 128 } })
" Override the `Identifier` background color in GUI mode
autocmd ColorScheme * call onedark#extend_highlight("Identifier", { "bg": { "gui": "#333333" } })
augroup END
endif
colorscheme onedark
"g:onedark_termcolors 256
"g:onedark_terminal_italics 1
let g:lightline = {
\ 'colorscheme': 'onedark',
\ }
let g:airline_theme='onedark'
"Highlighting of class scope is disabled by default. To enable set
let g:cpp_class_scope_highlight = 1
"Highlighting of member variables is disabled by default. To enable set
let g:cpp_member_variable_highlight = 1
"Highlighting of class names in declarations is disabled by default. To enable set
let g:cpp_class_decl_highlight = 1
"There are two ways to highlight template functions. Either
"let g:cpp_experimental_simple_template_highlight = 1
"which works in most cases, but can be a little slow on large files. Alternatively set
let g:cpp_experimental_template_highlight = 1
"which is a faster implementation but has some corner cases where it doesn't work.
"Note: C++ template syntax is notoriously difficult to parse, so don't expect this feature to be perfect.
"Highlighting of library concepts is enabled by
let g:cpp_concepts_highlight = 1
"This will highlight the keywords concept and requires as well as all named requirements (like DefaultConstructible) in the standard library.
"Highlighting of user defined functions can be disabled by
let g:cpp_no_function_highlight = 1
set autoindent
set smartindent
set smartcase
set smarttab
set tabstop=4
set softtabstop=4
set shiftwidth=4
"set list listchars=tab:>-
"set listchars=tab:>-
set cindent
set linebreak
set cinoptions={0,1s,t0,n-2,p2s,(03s,=.5s,>1s,=1s,:1s
set showmatch
set whichwrap=b,s,<,>,[,]
set ignorecase
nmap w= :resize +3
nmap w- :resize -3
nmap w[ :vertical resize -3
nmap w] :vertical resize +3
nmap
nmap
nmap
nmap
nmap
nmap
nmap
nmap
" MiniBufExpl Colors
hi MBENormal guifg=#808080 guibg=fg
hi MBEChanged guifg=#CD5907 guibg=fg
hi MBEVisibleNormal guifg=#5DC2D6 guibg=fg
hi MBEVisibleChanged guifg=#F1266F guibg=fg
hi MBEVisibleActiveNormal guifg=#A6DB29 guibg=fg
hi MBEVisibleActiveChanged guifg=#F1266F guibg=fg
let g:Tlist_Inc_Winwidth = 0
let Tlist_Show_One_File = 1 "不同时显示多个文件的tag,只显示当前文件的
let Tlist_Exit_OnlyWindow = 1 "如果taglist窗口是最后一个窗口,则退出vim
let Tlist_Use_Right_Window = 1 "在右侧窗口中显示taglist窗口
nmap tl :TlistOpen
"map tl :TlistToogle
"set nofoldenable
"set foldenable " 开始折叠
set foldmethod=syntax " 设置语法折叠
set nofoldenable
"set foldcolumn=0 " 设置折叠区域的宽度
"setlocal foldlevel=1 " 设置折叠层数为
"set foldclose=all " 设置为自动关闭折叠
"set foldopen=all
"nnoremap @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')
nnoremap zz @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')
"--ctags setting--
" 按下F5重新生成tag文件,并更新taglist
"map :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . :TlistUpdate
"map TG :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . :TlistUpdate
"imap :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . :TlistUpdate
"imap TG :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . :TlistUpdate
map TG :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
set tags=tags
set tags+=./tags "add current directory's generated tags file
set tags+=/usr/include/tags
"set tags+=~/arm/linux-2.6.24.7/tags "add new tags file(刚刚生成tags的路径,在ctags -R 生成tags文件后,不要将tags移动到别的目录,否则ctrl+]时,会提示找不到源码文件)
"重新设定返回快捷键
"set tags+=./tags表示在当前工作目录下搜索tags文件
"set tags+=~/arm/linux-2.6.24.7/tags表示在搜寻tags文件的时候,也要搜寻~/arm/linux-2.6.24.7/文件夹下的tags文件。
"在/usr/include/c++文件夹下生成能与OmniCppComplete配合运作的tags文件
"/usr/include/c++$ ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
set tags+=/usr/local/include/tags
set tags+=/usr/include/c++/tags
"set tags+=/usr/include/boost/tags
"set tags+=/usr/include/lua5.2/tags
"set tags+=/usr/include/tbb/tags