Skip to content

Instantly share code, notes, and snippets.

@jen20
Created March 10, 2016 21:10
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 jen20/28767ca65ab449cb4682 to your computer and use it in GitHub Desktop.
Save jen20/28767ca65ab449cb4682 to your computer and use it in GitHub Desktop.
" vim:fdm=marker
" Nocompatible and Leader {{{
set nocompatible
let mapleader="\<Space>"
" }}}
" Plugins {{{
call plug#begin('~/.vim/plugged')
" Fast file switching
Plug 'kien/ctrlp.vim'
" Go support
Plug 'fatih/vim-go'
" Search using The Silver Searcher
Plug 'rking/ag.vim'
" Graphical undo tree browsing
Plug 'sjl/gundo.vim'
" ctags-based tag bar
Plug 'majutsushi/tagbar'
" Allows pressing F12 to toggle mouse capture in terminal, great for copying
Plug 'nvie/vim-togglemouse'
" Info line
Plug 'bling/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Syntax checking support (using gofmt for instance)
Plug 'scrooloose/syntastic'
" Enhancements for when running in tmux
Plug 'edkolev/tmuxline.vim'
" Allows using vim to generate prompt lines
Plug 'edkolev/promptline.vim'
" Go completion support
Plug 'nsf/gocode', { 'rtp': 'vim', 'do': '~/.vim/plugged/gocode/vim/symlink.sh' }
" Git handling inside vim
Plug 'tpope/vim-fugitive'
" Let tab do smart things with omnicomplete
Plug 'ervandew/supertab'
" Don't run folding logic when not needed, fixes ultra slow omnicomplete
Plug 'Konfekt/FastFold'
" Better view/session restoring/saving
" Plug 'kopischke/vim-stay'
" Handle lines/columns in paths, e.g. from stacktraces
Plug 'vim-fetch'
" Smart tabularizing; also needed for vim-markdown
Plug 'godlygeek/tabular'
" Better Markdown handling
Plug 'plasticboy/vim-markdown'
" Nicer paren-colouring (useful for lisps etc)
Plug 'kien/rainbow_parentheses.vim'
" Nicer file browser
Plug 'scrooloose/nerdtree'
" Nicer comment handling
Plug 'scrooloose/nerdcommenter'
" Formatting for HCL
Plug 'fatih/vim-hclfmt'
" Highlighting etc for Terraform
Plug 'markcornick/vim-terraform'
" Auto completion
Plug 'Valloric/YouCompleteMe'
call plug#end()
" }}}
" Clipboard {{{
set clipboard=unnamed
" }}}
" Global settings {{{
syntax enable " enable syntax processing
set modeline " turn on modeline processing
set modelines=4 " look at beginning or end of file
set hidden " allow buffers to live in the background with changes
set history=1000 " remember a lot of history
set visualbell " don't beep
set noerrorbells " don't beep
set viminfo='100,<100,%,n~/.viminfo " extend amount of saved info
" }}}
" Whitespace settings {{{
set wrap " wrap lines
set linebreak " only wrap at characters in 'breakat'
set nolist " list disables linebreak
set whichwrap& " don't have left/right move to new lines
set tabstop=4 " number of visual spaces per TAB
set softtabstop=4 " number of spaces in tab when editing
" }}}
" UI settings {{{
set number " show line numbers
set relativenumber " show other line numbers relative to the current
set showcmd " show command in bottom bar
set wildmenu " visual autocomplete for command menu
set lazyredraw " redraw only when we need to
set showmatch " highlight matching [{()}]
set pastetoggle=<F2> " use F2 to switch into paste mode
set mouse=a " allow capturing the mouse for scrolling
" }}}
" Tab settings {{{
" For most everything, use a tab width of 4 space chars.
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
" Except for ruby where derp dictates we must use 2 chars.
autocmd filetype ruby set tabstop=2 shiftwidth=2 softtabstop=2 expandtab
" Ensure Makefiles use hard tabs
autocmd FileType make set tabstop=8 shiftwidth=8 softtabstop=0 noexpandtab
" }}}
" Misc keyboard shortcuts {{{
nnoremap <silent> <C-s> :update<cr> " Save with Ctrl+S
vnoremap <silent> <C-s> <C-c>:update<cr> " Save with Ctrl+S
inoremap <silent> <C-s> <C-o>:update<cr> " Save with Ctrl+S
" }}}
" GUI font and colour scheme {{{
filetype plugin indent on " load filetype-specific and plugin-specific indent files
if has('gui_running')
set guioptions-=T " Remove the toolbar
set lines=40 " 40 lines of text instead of 24
set guifont=Source_Code_Pro_for_Powerline:h14
else
if &term == 'xterm' || &term == 'screen'
set t_Co=256 " enable 256 colors
endif
endif
let g:rehash256 = 1
colorscheme molokai " awesome colorscheme solarized
" }}}
" Project shortcuts {{{
cabbrev gtf cd ~/Code/go/src/github.com/hashicorp/terraform
cabbrev gpk cd ~/Code/go/src/github.com/mitchellh/packer
cabbrev gjn cd ~/Code/go/src/github.com/jen20
" }}}
" Airline {{{
set laststatus=2 " always show the status line
let g:airline_theme='molokai'
let g:airline_powerline_fonts=1
let g:airline#extensions#whitespace#checks=['indent']
let g:airline#extensions#tabline#enabled = 1
set ttimeoutlen=50 " prevent delay switching to insert mode
" " }}}
" YouCompleteMe {{{
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_min_num_of_chars_for_completion = 1
let g:ycm_filetype_whitelist = { 'c': 1, 'cpp': 1, 'go': 1 }
" }}}
" Search settings {{{
set incsearch " search as characters are entered
set hlsearch " highlight matches
set ignorecase " ignore case when searching
set smartcase " but be smart about capitalization
" turn off search highlight with leader + space
nnoremap <leader><esc> :nohlsearch<CR>
" }}}
" Folding settings {{{
"set foldenable " enable folding
set foldlevelstart=20 " open most folds by default
set foldlevel=20 " open most folds by default
" Return to open/close folds
nnoremap <CR> za
set foldmethod=syntax " Use syntax folding, dangerous without FastFold!
" }}}
" Movement settings {{{
" move vertically by visual line rather than real line numbers
nnoremap j gj
nnoremap k gk
" move to beginning/end of line
nnoremap B ^
nnoremap E $
" highlight last inserted text
nnoremap gV `[v`]
" }}}
" Go {{{
let $GOPATH = $HOME."/Code/go"
let $PATH = $HOME."/Code/go/bin:".$PATH
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_structs = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_fmt_command = "goimports"
augroup gogroup
autocmd!
autocmd FileType go nmap <Leader>gb <Plug>(go-doc-browser)
autocmd FileType go nmap <Leader>gd <Plug>(go-describe)
autocmd FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
autocmd FileType go nmap <Leader>i <Plug>(go-info)
autocmd FileType go nmap <Leader>e <Plug>(go-rename)
augroup END
" }}}
" NERDTree {{{
let NERDTreeHijackNetrw=1
" }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment