Skip to content

Instantly share code, notes, and snippets.

@OneOfOne
Created September 15, 2014 15:08
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 OneOfOne/9ed59ff27f1de90a8d77 to your computer and use it in GitHub Desktop.
Save OneOfOne/9ed59ff27f1de90a8d77 to your computer and use it in GitHub Desktop.
vimgo-vimrc
set nocompatible
filetype off " required
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
Plugin 'bling/vim-airline'
Plugin 'tpope/vim-fugitive'
Plugin 'Valloric/YouCompleteMe'
Plugin 'SirVer/ultisnips'
Plugin 'fatih/vim-go'
call vundle#end() " required
syntax on
filetype plugin indent on
set background=dark
colorscheme tir_black
set encoding=utf8
set ttyfast
set showmode
set showcmd
set cmdheight=5
set hidden
set ruler
set cursorline
set number
set lazyredraw
set magic
set noerrorbells
set ignorecase
" make preview window at the bottom and/or right
set splitbelow
set splitright
set autoindent
set noexpandtab
set tabstop=4
set shiftwidth=4
" Turn backup off, since most stuff is in SVN, git et.c anyway...
set nobackup
set nowb
set noswapfile
"tell the term has 256 colors
set t_Co=256
set ai "Auto indent
set si "Smart indent
set list
set listchars=tab:── ",eol:¬,trail:~,extends:>,precedes:<
set backspace=indent,eol,start
set completeopt=menuone,longest
au FileType cpp set completeopt+=preview
highlight Pmenu guibg=brown gui=bold
let g:go_fmt_command = "goimports"
let g:go_auto_type_info = 1
if &shell =~ 'fish'
set shell=/usr/bin/bash
endif
set regexpengine=1
let g:ycm_complete_in_strings = 0
let g:ycm_seed_identifiers_with_syntax = 1
let g:ycm_server_use_vim_stdout = 1
let g:ycm_key_list_select_completion = ['<Down>']
let g:UltiSnipsExpandTrigger="<tab>"
set laststatus=2
"keybindings
command W w !sudo tee % > /dev/null
"Go
au FileType go nmap <Leader>i <Plug>(go-implements)
au FileType go nmap <leader>t :w<cr><Plug>(go-test)
au FileType go nmap <Leader>gd <Plug>(go-def-split)
au FileType go nmap <leader>r :w<cr><Plug>(go-run)
" Opens a new tab with the current buffer's path
" Super useful when editing files in the same directory
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
" tabs & buffers
map <leader>n :tabnew<CR>
map <leader>[ :tabprev<CR>
map <leader>] :tabnext<CR>
map <leader>w :bd<CR>
map <leader>ww :tabclose<CR>
function! PoorMultiCursor()
let word = expand('<cword>')
if strlen(word) > 0
call inputsave()
let repl = input('replace "'.word.'" with: ')
call inputrestore()
if strlen(repl) > 0
execute '%s/\<'.word.'\>/'.repl.'/g'
endif
endif
endfunction
" sublime text's ctrl+d / ctrl+alt+d (find all)
inoremap <C-d> <C-o>:call PoorMultiCursor()<cr>
nnoremap <C-d> :call PoorMultiCursor()<cr>
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"
" disable help mapping
nnoremap <F1> <nop>
inoremap <F1> <nop>
vnoremap <F1> <nop>
au FileType cpp map <silent> <F1> :echom system('clang++ -std=c++11 -stdlib=libc++ -lc++abi -I. -I' . fnamemodify(expand('%'), ':p:h') . ' -g "' . expand('%') . '" -o /tmp/current-build && /tmp/current-build')<CR>
" Open markdown files with Chrome.
autocmd BufEnter *.md exe 'noremap <F5> :!google-chrome-beta %:p<CR>'
" other
" Return to last edit position when opening files (You want this!)
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Remember info about open buffers on close
set viminfo^=%
try
set switchbuf=useopen,usetab,newtab
set stal=2
catch
endtry
"Airline
let g:airline_theme = 'zenburn'
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
"let g:airline_exclude_preview = 1
"" unicode symbols
let g:airline_left_sep = '»'
let g:airline_left_sep = '▶'
let g:airline_right_sep = '«'
let g:airline_right_sep = '◀'
let g:airline_symbols.linenr = '␊'
let g:airline_symbols.linenr = '␤'
let g:airline_symbols.linenr = '¶'
let g:airline_symbols.branch = '⎇'
let g:airline_symbols.paste = 'ρ'
let g:airline_symbols.paste = 'Þ'
let g:airline_symbols.paste = '∥'
let g:airline_symbols.whitespace = 'Ξ'
let g:airline#extensions#whitespace#mixed_indent_algo = 1
let g:airline_section_z = '%c,%l'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment