Skip to content

Instantly share code, notes, and snippets.

@wrpaape
Last active March 28, 2019 17:49
Show Gist options
  • Save wrpaape/4f425e248abd3abd1d66 to your computer and use it in GitHub Desktop.
Save wrpaape/4f425e248abd3abd1d66 to your computer and use it in GitHub Desktop.
"VUNDLE PLUGINS
"===============================================================================
execute pathogen#infect()
set nocompatible " be iMproved, required
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim' " required
Plugin 'tpope/vim-repeat'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-surround'
Plugin 'jiangmiao/auto-pairs'
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
" Plugin 'pboettch/vim-cmake-syntax'
Plugin 'nickhutchinson/vim-cmake-syntax'
Plugin 'Valloric/YouCompleteMe'
call vundle#end() " required
"GLOBAL SETTINGS
"===============================================================================
"syntax highlighting
syntax on
"sets default indentation for filetypes
filetype plugin indent on
"dark colors
colorscheme koehler
"crosshairs
set cursorline cursorcolumn
highlight CursorLine cterm=NONE ctermbg=238 ctermfg=NONE guibg=black guifg=NONE
highlight CursorColumn cterm=NONE ctermbg=238 ctermfg=NONE guibg=black guifg=NONE
"map '%%' in command line to current buffer directory
cnoremap <expr> %% getcmdtype() == ':' ? expand('%:h').'/' : '%%'
"line numbers, highlight search
set number hlsearch
"copy contents of '+' register to clipboard
autocmd VimLeave * call system("xsel -ib", getreg('+'))
"put .swp and ~ files under ~/.vim
set backupdir=$HOME/.vim/backup
set directory=$HOME/.vim/swap
"default to 4-space indent
set shiftwidth=4 tabstop=4 expandtab
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
"FILE-SPECIFIC SETTINGS
"===============================================================================
autocmd FileType c setlocal shiftwidth=8 tabstop=8 noexpandtab cino=(0
autocmd FileType make setlocal shiftwidth=8 tabstop=8 noexpandtab cino=(0
autocmd FileType cpp setlocal cino=(0
autocmd FileType cmake setlocal cino=(0
autocmd FileType java setlocal cindent noexpandtab
autocmd FileType python setlocal cino=(0
autocmd FileType xml setlocal shiftwidth=2 tabstop=2
autocmd FileType yaml setlocal shiftwidth=2 tabstop=2
" view c++ standard headers with correct FileType
autocmd BufRead * if search('\M-*- C++ -*-', 'n', 1) | setlocal ft=cpp | endif
"PLUGIN SETTINGS
"===============================================================================
"YouCompleteMe
let g:ycm_global_ycm_extra_conf ='~/.vim/.ycm_extra_conf.py' "global conf
let g:ycm_show_diagnostics_ui =0 "no syntax
let g:ycm_enable_diagnostic_signs =0 "no syntax
let g:ycm_enable_diagnostic_highlighting =0 "no syntax
set completeopt -=preview "no popups
"vim-commentary
autocmd FileType groovy setlocal commentstring=//\ %s "/**/ -> //
autocmd FileType cpp setlocal commentstring=//\ %s "/**/ -> //
autocmd FileType cmake setlocal commentstring=#\ %s "/**/ -> #
"UltiSnips
let g:UltiSnipsExpandTrigger="<c-k>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
let g:UltiSnipsEditSplit="vertical"
"cscope
function! LoadCscope() "search for cscope in current and parent directories
let db = findfile("cscope.out", ".;")
if (!empty(db))
let path = strpart(db, 0, match(db, "/cscope.out$"))
set nocscopeverbose " suppress 'duplicate connection' error
exe "cs add " . db . " " . path
set cscopeverbose
endif
endfunction
autocmd BufEnter *.[ch],*.[chi]pp,*.[eh]rl call LoadCscope() "C/C++/erlang files
"ctags
set tags=tags; "if not found in current directory, search ancestors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment