Skip to content

Instantly share code, notes, and snippets.

@bmount
Last active February 18, 2016 19:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmount/135d61545d4cce10770e to your computer and use it in GitHub Desktop.
Save bmount/135d61545d4cce10770e to your computer and use it in GitHub Desktop.
vimrc
" runtime
set runtimepath=~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after
execute pathogen#infect()
" tabs in makefiles
filetype plugin on
filetype indent on
autocmd FileType make setlocal noexpandtab
set nocompatible
"set visualbell
" global
set backspace=indent,eol,start
syntax on
" show visual etc
set showcmd
" show matching brace
set showmatch
set mat=5
set ignorecase
set smartcase
set incsearch
set hlsearch
set autowrite
set ruler
set number
set hidden
set laststatus=2
" clipboard
set ruler
" gui
set guioptions=
set background=dark
if has('gui_running')
set background=dark
set guifont=Source\ Code\ Pro\ 12
colorscheme solarized
set lines=42 columns=120
endif
set gfn=Source\ Code\ Pro\ 12
set guifont=Source\ Code\ Pro\ 12
set cursorline
set mousehide
"set mouse=a
"set textwidth=120
" search
runtime macros/matchit.vim
set wildmenu
set wildmode=list:longest
set scrolloff=3
" formatting
set expandtab
set tabstop=2
set shiftwidth=2
set smarttab
autocmd Filetype python setlocal expandtab tabstop=4 shiftwidth=4
autocmd Filetype cpp setlocal expandtab tabstop=4 shiftwidth=4
autocmd FileType make setlocal noexpandtab
autocmd FileType go setlocal noexpandtab
let g:godef_split=2
" autocmd FileType go autocmd BufWritePre <buffer> Fmt
let g:syntastic_html_checkers=['']
let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++'
" whitespace
set listchars=tab:▸\ ,eol:¬
" folding
" set foldmethod=syntax
" set whichwrap=h,l,[,]
set nofoldenable
" external commands
" * grep
set grepprg=grep\ -nH\ $*
" custom bindings
nmap <leader>w :set list!<CR>
nmap <leader>h :noh<CR>
map . .`[
nmap , :b
" tabs
" au BufAdd,BufNewFile,BufRead * nested tab sball
" environment
autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p
autocmd WinEnter * call s:CloseIfOnlyNerdTreeLeft()
" Close all open buffers on entering a window if the only
" buffer that's left is the NERDTree buffer
function! s:CloseIfOnlyNerdTreeLeft()
if exists("t:NERDTreeBufName")
if bufwinnr(t:NERDTreeBufName) != -1
if winnr("$") == 1
q
endif
endif
endif
endfunction
let g:ycm_confirm_extra_conf = 0
let g:ycm_filepath_completion_use_working_dir = 1
let g:ycm_buffer_command = 'horizontal-split'
let g:syntastic_cpp_cpplint_exec = 'cpplint'
" let g:ycm_global_ycm_extra_conf = "~/.ycm/.ycm_extra_conf.py"
" let g:ycm_filetype_specific_completion_to_disable = { 'python' : 1 }
" let g:ycm_filetype_blacklist = { 'python' : 1, 'golang': 1, 'go': 1 }
" nnoremap <leader>gd :YcmCompleter GoToDefinition<CR> maps the <leader>gd
" nnoremap f :tab split | YcmCompleter GoToDefinition
nnoremap <leader>g :YcmCompleter GoToDefinitionElseDeclaration tabnew<CR>
map <Leader>' :NERDTreeToggle<CR>
" Don't indent namespace and template
function! CppNoNamespaceAndTemplateIndent()
let l:cline_num = line('.')
let l:cline = getline(l:cline_num)
let l:pline_num = prevnonblank(l:cline_num - 1)
let l:pline = getline(l:pline_num)
while l:pline =~# '\(^\s*{\s*\|^\s*//\|^\s*/\*\|\*/\s*$\)'
let l:pline_num = prevnonblank(l:pline_num - 1)
let l:pline = getline(l:pline_num)
endwhile
let l:retv = cindent('.')
let l:pindent = indent(l:pline_num)
if l:pline =~# '^\s*template\s*\s*$'
let l:retv = l:pindent
elseif l:pline =~# '\s*typename\s*.*,\s*$'
let l:retv = l:pindent
elseif l:cline =~# '^\s*>\s*$'
let l:retv = l:pindent - &shiftwidth
elseif l:pline =~# '\s*typename\s*.*>\s*$'
let l:retv = l:pindent - &shiftwidth
elseif l:pline =~# '^\s*namespace.*'
let l:retv = 0
endif
return l:retv
endfunction
if has("autocmd")
autocmd BufEnter *.{cc,cxx,cpp,h,hh,hpp,hxx} setlocal indentexpr=CppNoNamespaceAndTemplateIndent()
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment