" basic {{
setnumbersetrulersetshowcmdsetnobackupsetnoswapfilesetcursorlinesetautoindentsetcindentsetsmarttabsetexpandtabsetsmartindentsetwildmenusethlsearchsetnowrapsetguifont=monacosetencoding=utf-8
setmouse=asettabstop=4
setshiftwidth=4
setsofttabstop=4
sethistory=1000
" }}
"leader {{
letmapleader=","nmap <leader>w :w<CR>
nmap <leader>q :q<CR>
nmap <leader>q1 :q!<CR>
nmap <leader>wq :wq<CR>
nmap <leader>y"+y
nmap <leader>p "+pnmap <space> :
nmap <C-l> :noh<CR>
"buffer
nmap <leader><Tab> :bn<CR>
"stripalltrailingwhitespaceinthecurrentfilennoremap <leader>w :%s/\s\+$//<cr>:let @/=''<CR>
" }}
"hightlightsyntaxenablesyntaxon" color
"airlinecanbedisplaywhensetthissett_Co=256
setlaststatus=2
"set background=dark
colorscheme molokai
"colormolokaifiletypeonfiletypeindentonfiletypepluginonfiletypepluginindenton" for vundle {{
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#rc()
"addpluginattherePlugin 'VundleVim/Vundle.vim'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'scrooloose/nerdtree'
Plugin 'nathanaelkane/vim-indent-guides'
Plugin 'tpope/vim-fugitive'
Plugin 'djoshea/vim-matlab'
Plugin 'djoshea/vim-matlab-fold'
Plugin 'dracula/vim'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'kien/ctrlp.vim'
Plugin 'majutsushi/tagbar'
Plugin 'Valloric/YouCompleteMe'
Plugin 'Raimondi/delimitMate'
Plugin 'docunext/closetag.vim'
Plugin 'scrooloose/nerdcommenter'
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
Plugin 'scrooloose/syntastic'
" Plugin 'jeaye/color_coded'
Bundle 'ShowTrailingWhitespace'
Bundle 'molokai'
"pluginendherecallvundle#end()
filetypepluginindenton" }}
"settingsforairlineletg:airline_theme='luna'
letg:airline_powerline_fonts=1
letg:solarized_termcolors=16
letg:airline#extensions#tabline#enabled = 1
letg:airline#extensions#tagbar#enabled = 1
letg:airline#extensions#syntastic#enabled = 1
letg:airline#extensions#tabline#buffer_idx_mode = 1
" tarbar
nmap <leader>tb :Tagbar<CR>
"settingsfornerdtreemap <C-b> :NERDTreeToggle<CR>
autocmdStdinReadPre * lets:std_in=1
autocmdStdinReadPre * lets:std_in=1
autocmdbufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endifletg:NERDTreeDirArrowExpandable = '▸'
letg:NERDTreeDirArrowCollapsible = '▾'
" settings for IndentGuides
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_auto_colors = 0
let g:indent_guides_guide_size = 1
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=red ctermbg=3
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=green ctermbg=4
hi IndentGuidesOdd guibg=red ctermbg=3
hi IndentGuidesEven guibg=green ctermbg=4
"settingsforyoucompleteme" highlight Pmenu ctermfg=2 ctermbg=3 guifg=#005f87 guibg=#EEE8D5
"highlightPmenuSelctermfg=2 ctermbg=3 guifg=#AFD700 guibg=#106900
letg:ycm_global_ycm_extra_conf = '~/.ycm_extra_conf.py'
setcompleteopt=longest,menu"让Vim的补全菜单行为与一般IDE一致(参考VimTip1228)
autocmd InsertLeave * if pumvisible() == 0|pclose|endif "离开插入模式后自动关闭预览窗口
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>""回车即选中当前项
"youcompleteme 默认tabs-tab 和自动补全冲突
letg:ycm_key_list_select_completion=['<c-n>']
" let g:ycm_key_list_select_completion = ['Down']
let g:ycm_key_list_previous_completion=['<c-p>']
"letg:ycm_key_list_previous_completion = ['<Up>']
letg:ycm_confirm_extra_conf=0 "关闭加载.ycm_extra_conf.py提示
let g:ycm_key_invoke_completion = '<C-a>' " 强制补全
letg:ycm_collect_identifiers_from_tags_files=1 " 开启 YCM 基于标签引擎
let g:ycm_min_num_of_chars_for_completion=2 " 从第2个键入字符就开始罗列匹配项
letg:ycm_cache_omnifunc=0 " 禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_seed_identifiers_with_syntax=1 " 语法关键字补全
nnoremap <F5> :YcmForceCompileAndDiagnostics<CR> "force recomile with syntastic
"nnoremap <leader>lo :lopen<CR> "open locationlist
"nnoremap <leader>lc :lclose<CR> "close locationlist
inoremap <leader><leader> <C-x><C-o>
let g:ycm_complete_in_comments = 1
let g:ycm_complete_in_strings = 1
let g:ycm_collect_identifiers_from_comments_and_strings = 0
nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR> " 跳转到定义处
" imap { {}<ESC>i<CR><ESC>V<O
"settingsfornerdcommenter" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
"Usecompactsyntaxforprettifiedmulti-linecommentsletg:NERDCompactSexyComs = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
"Setalanguagetouseitsalternatedelimitersbydefaultletg:NERDAltDelims_java = 1
" Add your own custom formats or override the defaults
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } }
"Allowcommentingandinvertingemptylines (usefulwhencommentingaregion)
letg:NERDCommentEmptyLines = 1
" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
"forultisnipsletg:UltiSnipsExpandTrigger="<tab>"letg:UltiSnipsJumpForwardTrigger="<c-b>"letg:UltiSnipsJumpBackwardTrigger="<c-z>"" syntastic
let g:syntastic_error_symbol = '✗'
let g:syntastic_warning_symbol = '⚠'
"colorcode" hi link StructDecl Type
"hilinkUnionDeclType" hi link ClassDecl Type
"hilinkEnumDeclType
youcompleteme配置文件
# Copyright (C) 2014 Google Inc.## This file is part of ycmd.## ycmd is free software: you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation, either version 3 of the License, or# (at your option) any later version.## ycmd is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with ycmd. If not, see <http://www.gnu.org/licenses/>.import os
import ycm_core
# These are the compilation flags that will be used in case there's no# compilation database set (by default, one is not set).# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
flags = [
'-Wall',
'-Wextra',
'-Werror',
'-fexceptions',
'-DNDEBUG',
# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which# language to use when compiling headers. So it will guess. Badly. So C++# headers will be compiled as C headers. You don't want that so ALWAYS specify# a "-std=<something>".# For a C project, you would set this to something like 'c99' instead of# 'c++11'.'-std=c++11',
# ...and the same thing goes for the magic -x option which specifies the# language that the files to be compiled are written in. This is mostly# relevant for c++ headers.# For a C project, you would set this to 'c' instead of 'c++'.'-x',
'c++',
'-isystem',
'/usr/include',
'-isystem',
'/usr/local/include',
'-isystem',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1',
'-isystem',
'/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include',
# 注意下面把的库文件根据你的系统修改# 格式和下面类似一个'-isystem'一个库地址'-isystem',
'/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../include/c++/6.3.1',
'-isystem',
'/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../include/c++/6.3.1/x86_64-pc-linux-gnu',
'-isystem',
'/usr/bin/../lib64/gcc/x86_64-pc-linux-gnu/6.3.1/../../../../include/c++/6.3.1/backward',
'-isystem',
'/usr/local/include',
'-isystem',
'/usr/bin/../lib/clang/3.9.1/include',
'-isystem',
'/usr/include',
]
# Set this to the absolute path to the folder (NOT the file!) containing the# compile_commands.json file to use that instead of 'flags'. See here for# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html## Most projects will NOT need to set this to anything; you can just change the# 'flags' list of compilation flags.
compilation_database_folder = ''if os.path.exists( compilation_database_folder ):
database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
database = None
SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
defDirectoryOfThisScript():return os.path.dirname( os.path.abspath( __file__ ) )
defMakeRelativePathsInFlagsAbsolute( flags, working_directory ):ifnot working_directory:
return list( flags )
new_flags = []
make_next_absolute = False
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
for flag in flags:
new_flag = flag
if make_next_absolute:
make_next_absolute = Falseifnot flag.startswith( '/' ):
new_flag = os.path.join( working_directory, flag )
for path_flag in path_flags:
if flag == path_flag:
make_next_absolute = Truebreakif flag.startswith( path_flag ):
path = flag[ len( path_flag ): ]
new_flag = path_flag + os.path.join( working_directory, path )
breakif new_flag:
new_flags.append( new_flag )
return new_flags
defIsHeaderFile( filename ):
extension = os.path.splitext( filename )[ 1 ]
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
defGetCompilationInfoForFile( filename ):# The compilation_commands.json file generated by CMake does not have entries# for header files. So we do our best by asking the db for flags for a# corresponding source file, if any. If one exists, the flags for that file# should be good enough.if IsHeaderFile( filename ):
basename = os.path.splitext( filename )[ 0 ]
for extension in SOURCE_EXTENSIONS:
replacement_file = basename + extension
if os.path.exists( replacement_file ):
compilation_info = database.GetCompilationInfoForFile(
replacement_file )
if compilation_info.compiler_flags_:
return compilation_info
returnNonereturn database.GetCompilationInfoForFile( filename )
# This is the entry point; this function is called by ycmd to produce flags for# a file.defFlagsForFile( filename, **kwargs ):if database:
# Bear in mind that compilation_info.compiler_flags_ does NOT return a# python list, but a "list-like" StringVec object
compilation_info = GetCompilationInfoForFile( filename )
ifnot compilation_info:
returnNone
final_flags = MakeRelativePathsInFlagsAbsolute(
compilation_info.compiler_flags_,
compilation_info.compiler_working_dir_ )
else:
relative_to = DirectoryOfThisScript()
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
return { 'flags': final_flags }