|
| 1 | +" Notes { |
| 2 | +" Ben Hayden, Scott Blevins, Matt Thompson, et al. Public Domain. |
| 3 | +" https://github.com/beardedprojamz/VimConf |
| 4 | +"} |
| 5 | + |
| 6 | +" Basics { |
| 7 | + set nocompatible " explicitly get out of vi-compatible mode |
| 8 | + syntax on " syntax highlighting on |
| 9 | + if has('vim_starting') |
| 10 | + set runtimepath+=~/.vim/bundle/neobundle.vim/ |
| 11 | + endif |
| 12 | + call neobundle#rc(expand('~/.vim/bundle/')) |
| 13 | + NeoBundleFetch 'Shougo/neobundle.vim' |
| 14 | + NeoBundle 'Shougo/unite.vim' |
| 15 | + NeoBundle 'airblade/vim-gitgutter' |
| 16 | + NeoBundle 'altercation/vim-colors-solarized' |
| 17 | + NeoBundle 'beardedprojamz/vim-colors-blayden' |
| 18 | + NeoBundle 'groenewege/vim-less' |
| 19 | + NeoBundle 'kchmck/vim-coffee-script' |
| 20 | + NeoBundle 'kien/ctrlp.vim' |
| 21 | + NeoBundle 'klen/python-mode' |
| 22 | + NeoBundle 'majutsushi/tagbar' |
| 23 | + NeoBundle 'nathanaelkane/vim-indent-guides' |
| 24 | + NeoBundle 'pangloss/vim-javascript' |
| 25 | + NeoBundle 'rodjek/vim-puppet' |
| 26 | + NeoBundle 'scrooloose/nerdcommenter' |
| 27 | + NeoBundle 'scrooloose/nerdtree' |
| 28 | + NeoBundle 'scrooloose/syntastic' |
| 29 | + NeoBundle 'tpope/vim-abolish' |
| 30 | + NeoBundle 'tpope/vim-fugitive' |
| 31 | + NeoBundle 'tpope/vim-repeat' |
| 32 | + NeoBundle 'tpope/vim-surround' |
| 33 | + NeoBundle 'uggedal/go-vim' |
| 34 | + NeoBundle 'vim-scripts/php.vim--Garvin' |
| 35 | + " vimproc needs a special build |
| 36 | + NeoBundle 'Shougo/vimproc', { |
| 37 | + \ 'build' : { |
| 38 | + \ 'windows' : 'make -f make_mingw32.mak', |
| 39 | + \ 'cygwin' : 'make -f make_cygwin.mak', |
| 40 | + \ 'mac' : 'make -f make_mac.mak', |
| 41 | + \ 'unix' : 'make -f make_unix.mak', |
| 42 | + \ }, |
| 43 | + \ } |
| 44 | + " the plugin indent needs to be on before neobundle runs... |
| 45 | + filetype plugin indent on " load filetype plugins/indent settings |
| 46 | + NeoBundleCheck |
| 47 | + colorscheme blayden " set our customized colorscheme |
| 48 | + set background=dark |
| 49 | + let g:solarized_termtrans=1 |
| 50 | + let g:solarized_contrast="high" |
| 51 | +" } |
| 52 | + |
| 53 | +" General { |
| 54 | + set backspace=indent,eol,start " make backspace a more flexible |
| 55 | + set backup " make backup files |
| 56 | + set backupdir=~/.vim/backup " where to put backup files |
| 57 | + set directory=~/.vim/tmp " directory to place swap files in |
| 58 | + set fileformats=unix,mac,dos " support all three, in this order |
| 59 | + set hidden " you can change buffers without saving |
| 60 | + if has("mouse") |
| 61 | + set mouse=a " use mouse everywhere |
| 62 | + endif |
| 63 | + set noerrorbells " don't make noise when something errors |
| 64 | + if has("persistent_undo") |
| 65 | + set undofile " enable file undoing |
| 66 | + set undodir=~/.vim/undo " where to put undo files |
| 67 | + endif |
| 68 | + set whichwrap=b,s,h,l,<,>,~,[,] " everything wraps |
| 69 | + " | | | | | | | | | |
| 70 | + " | | | | | | | | +-- "]" Insert and Replace |
| 71 | + " | | | | | | | +-- "[" Insert and Replace |
| 72 | + " | | | | | | +-- "~" Normal |
| 73 | + " | | | | | +-- <Right> Normal and Visual |
| 74 | + " | | | | +-- <Left> Normal and Visual |
| 75 | + " | | | +-- "l" Normal and Visual (not recommended) |
| 76 | + " | | +-- "h" Normal and Visual (not recommended) |
| 77 | + " | +-- <Space> Normal and Visual |
| 78 | + " +-- <BS> Normal and Visual |
| 79 | + set wildmenu " turn on command line completion wild style |
| 80 | + " ignore these list file extensions |
| 81 | + set wildignore=*.dll,*.o,*.obj,*.bak,*.exe,*.pyc, |
| 82 | + \*.jpg,*.gif,*.png |
| 83 | + set wildmode=list:longest " turn on wild mode huge list |
| 84 | + " Set buffer to infinity |
| 85 | + set viminfo='100,h |
| 86 | + " Re-open VIM to the last spot you had open. |
| 87 | + if has("autocmd") |
| 88 | + au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") |
| 89 | + \| exe "normal! g'\"" | endif |
| 90 | + |
| 91 | + " Jump to the top of git COMMIT_EDITMSG files. |
| 92 | + au BufReadPost COMMIT_EDITMSG |
| 93 | + \ exe "normal! gg" |
| 94 | + endif |
| 95 | + " CtrlP finds a versioned working directory |
| 96 | + let g:ctrlp_working_path_mode = 2 |
| 97 | + " Ignore uploads directory in projects for CtrlP |
| 98 | + let g:ctrlp_custom_ignore = '\.git$\|\.svn$\|\uploads$' |
| 99 | + |
| 100 | + au BufNewFile,BufRead *.save set filetype=sql |
| 101 | + |
| 102 | + " Unite settings |
| 103 | + let g:unite_enabled_start_insert=1 |
| 104 | + let g:unite_source_history_yank_enable=1 |
| 105 | + |
| 106 | + autocmd FileType unite call s:unite_settings() |
| 107 | + function! s:unite_settings() |
| 108 | + " Put settings that execute inside the unite buffer here |
| 109 | + endfunction |
| 110 | +" } |
| 111 | + |
| 112 | +" Vim UI { |
| 113 | + set cursorline " highlight current line |
| 114 | + set hlsearch " highlight searched for phrases |
| 115 | + set incsearch " highlight as you type you |
| 116 | + " search phrase |
| 117 | + set laststatus=2 " always show the status line |
| 118 | + set lazyredraw " do not redraw while running macros |
| 119 | + set linespace=0 " don't insert any extra pixel lines |
| 120 | + " betweens rows |
| 121 | + set list " we do what to show tabs, to ensure we get them |
| 122 | + " out of my files |
| 123 | + set listchars=tab:>-,trail:- " show tabs and trailing |
| 124 | + set matchtime=5 " how many tenths of a second to blink |
| 125 | + " matching brackets for |
| 126 | + set nostartofline " leave my cursor where it was |
| 127 | + set number " turn on line numbers |
| 128 | + set numberwidth=5 " We are good up to 99999 lines |
| 129 | + set report=0 " tell us when anything is changed via :... |
| 130 | + set ruler " Always show current positions along the bottom |
| 131 | + set scrolloff=10 " Keep 10 lines (top/bottom) for scope |
| 132 | + set shortmess=aOstT " shortens messages to avoid |
| 133 | + " 'press a key' prompt |
| 134 | + set showcmd " show the command being typed |
| 135 | + set showmatch " show matching brackets |
| 136 | + set sidescrolloff=10 " Keep 5 lines at the size |
| 137 | + set statusline= " clear the statusline for when vimrc is reloaded |
| 138 | + set statusline+=%-3.3n\ " buffer number |
| 139 | + set statusline+=%<%.99f\ " file name up to 99 chars |
| 140 | + set statusline+=%h%m%r%w " flags |
| 141 | + set statusline+=%{fugitive#statusline()} " Git fugitive status line |
| 142 | + set statusline+=[%{strlen(&ft)?&ft:'none'}, " filetype |
| 143 | + set statusline+=%{strlen(&fenc)?&fenc:&enc}, " encoding |
| 144 | + set statusline+=%{&fileformat}] " file format |
| 145 | + set statusline+=%= " right align |
| 146 | + set statusline+=%b,0x%-8B\ " current char |
| 147 | + set statusline+=%-14.(%l,%c%V%)\ %<%P " offset |
| 148 | + set statusline+=%#syntodo#%{SyntasticStatuslineFlag()} " Add syntastic status line |
| 149 | +" } |
| 150 | + |
| 151 | +" Text Formatting/Layout { |
| 152 | + set expandtab " no real tabs please! |
| 153 | + set formatoptions=rq " Automatically insert comment leader on return, |
| 154 | + " and let gq format comments |
| 155 | + set ignorecase " case insensitive by default |
| 156 | + set infercase " case inferred by default |
| 157 | + set nowrap " do not wrap line |
| 158 | + set shiftround " when at 3 spaces, and I hit > ... go to 4, not 5 |
| 159 | + set smartcase " if there are caps, go case-sensitive |
| 160 | + set nosmartindent " turn off smart indent so comments work in Python |
| 161 | + set shiftwidth=4 " auto-indent amount when using cindent, |
| 162 | + " >>, << and stuff like that |
| 163 | + set softtabstop=4 " when hitting tab or backspace, how many spaces |
| 164 | + "should a tab be (see expandtab) |
| 165 | + au BufNewFile,BufReadPost *.coffee setl shiftwidth=2 softtabstop=2 " For CoffeeScript |
| 166 | + au BufNewFile,BufReadPost *.go setl noexpandtab tabstop=4 nolist " For Go |
| 167 | + set tabstop=8 " real tabs should be 8, and they will show with |
| 168 | + " set list on |
| 169 | +" } |
| 170 | + |
| 171 | +" Mappings { |
| 172 | + let mapleader = "," |
| 173 | + " Mapping Unite commands |
| 174 | + nnoremap <Leader>/ :Unite grep:.<cr> |
| 175 | + nnoremap <Leader>y :Unite -buffer-name=yank history/yank<cr> |
| 176 | + nnoremap <Leader>l :Unite -buffer-name=buffers -quick-match buffer<cr> |
| 177 | + " Mapping ropevim commands |
| 178 | + nnoremap <Leader>g :call RopeGotoDefinition()<return> |
| 179 | + nnoremap <Leader>d :call RopeShowDoc()<return> |
| 180 | + nnoremap <Leader>f :call RopeFindOccurrences()<return> |
| 181 | + nnoremap <Leader>j :call RopeJumpToGlobal()<return> |
| 182 | + " Mapping tab commands |
| 183 | + nnoremap <Leader>tc :tabc<return> |
| 184 | + nnoremap <Leader>tn :tabn<return> |
| 185 | + nnoremap <Leader>tp :tabp<return> |
| 186 | + nnoremap <Leader>te :tabe<space> |
| 187 | + " Mapping Plugin commands |
| 188 | + nnoremap <Leader>nt :NERDTreeToggle<return> |
| 189 | + nnoremap <Leader>tb :TagbarToggle<return> |
| 190 | + nnoremap <Leader>e :Errors<return> |
| 191 | + nnoremap <Leader>en :lnext<return> |
| 192 | + nnoremap <Leader>ep :lprev<return> |
| 193 | + " Adding Toggle Comment |
| 194 | + nnoremap <Leader><Leader> :call NERDComment("n", "Toggle")<return> |
| 195 | + vnoremap <Leader><Leader> :call NERDComment("v", "Toggle")<return> |
| 196 | + " Add 'Sign' shortcut |
| 197 | + nnoremap <Leader>si :exec "normal A".system("echo -n ' -- '$(git config --global --get user.name) $(date +\%D)")<return> |
| 198 | + " Map Paste / No Number for copy, paste, etc. in Vim without X. |
| 199 | + nnoremap <Leader>p :set paste nonumber<return> |
| 200 | + nnoremap <Leader>np :set nopaste number<return> |
| 201 | + " X System Clipboard copy, cut, & paste shortcuts. |
| 202 | + noremap <Leader>xp "+gP<return> |
| 203 | + noremap <Leader>xy "+y<return> |
| 204 | + noremap <Leader>xx "+x<return> |
| 205 | + " Compile (make) less to new CSS file |
| 206 | + nnoremap <Leader>ml :w <BAR> !lessc % > %:t:r.css<CR><space> |
| 207 | + " Spell Checking |
| 208 | + nnoremap <Leader>sp :setlocal spell spelllang=en_us<return> |
| 209 | + nnoremap <Leader>nsp :setlocal spell spelllang=<return> |
| 210 | + " Write and Write & Quit shortcuts |
| 211 | + nnoremap <Leader>s :w<return> |
| 212 | + nnoremap <Leader>q :wq<return> |
| 213 | + " Start vertical split command with space character. |
| 214 | + nnoremap <Leader>v :vsp<space> |
| 215 | + " Start horizontal split command with space character. |
| 216 | + nnoremap <Leader>h :sp<space> |
| 217 | + " Close window |
| 218 | + nnoremap <Leader>cw :close<return> |
| 219 | + " Close buffer |
| 220 | + nnoremap <Leader>bd :bd<return> |
| 221 | + " Clear highlighting |
| 222 | + nnoremap <Leader>ch :noh<return> |
| 223 | + " Retab entire file |
| 224 | + nnoremap <Leader>rt gg=G |
| 225 | + " Insert a line above or below cursor without insert mode. |
| 226 | + nnoremap <Leader>O O<Esc> |
| 227 | + nnoremap <Leader>o o<Esc> |
| 228 | + " Make arrow keys jump by 10 lines |
| 229 | + nnoremap <S-Down> 10j |
| 230 | + nnoremap <S-Up> 10k |
| 231 | + imap <S-Down> <Esc>10ji |
| 232 | + imap <S-Up> <Esc>10ki |
| 233 | + vmap <S-Down> 10j |
| 234 | + vmap <S-Up> 10k |
| 235 | + " Send the selected hunk to IWS's hastebin |
| 236 | + vmap <Leader>hb <esc>:'<,'>:w !HASTE_SERVER=http://hastebin.britecorepro.com haste<CR> |
| 237 | + " Jump easily between open windows |
| 238 | + nnoremap <C-h> <C-w>h |
| 239 | + nnoremap <C-j> <C-w>j |
| 240 | + nnoremap <C-k> <C-w>k |
| 241 | + nnoremap <C-l> <C-w>l |
| 242 | + " Refresh syntax highlighting |
| 243 | + nnoremap <Leader>rf :syntax off<return>:syntax on<return> |
| 244 | + " Fix all the whitespace in a file. Re-tabs and removes trailing whitespace. |
| 245 | + " Usage: ,ws |
| 246 | + nnoremap <Leader>ws :TrimWS<return>gg=G |
| 247 | + " Insert a single character of your choosing and return to the right spot. |
| 248 | + " Usage: ,[spacebar][character] |
| 249 | + nnoremap <Leader><space> :exec "normal i".nr2char(getchar())."\e"<return> |
| 250 | + nnoremap <Leader>a :exec "normal a".nr2char(getchar())."\e"<return> |
| 251 | + " Write as super user |
| 252 | + command! W w !sudo tee % > /dev/null |
| 253 | + " Trim trailing whitespace |
| 254 | + command TrimWS %s/\s*$//g | noh |
| 255 | + " Visual Selection Search using * and # |
| 256 | + function! s:VSetSearch() |
| 257 | + let temp = @@ |
| 258 | + norm! gvy |
| 259 | + let @/ = '\V' . substitute(escape(@@, '\'), '\n', '\\n', 'g') |
| 260 | + let @@ = temp |
| 261 | + endfunction |
| 262 | + vnoremap * :<C-u>call <SID>VSetSearch()<CR>//<CR> |
| 263 | + vnoremap # :<C-u>call <SID>VSetSearch()<CR>??<CR> |
| 264 | + " Plugin Boolean settings for Programming Languages |
| 265 | + let coffee_compile_vert=1 " When compiling CoffeeScript, throw output into vertical split |
| 266 | + let coffee_make_options='--bare' |
| 267 | + " Auto-compile coffee files on save. |
| 268 | + au BufWritePost *.coffee silent CoffeeMake! |
| 269 | + " Auto-compile less files on save. |
| 270 | + function LessToCss() |
| 271 | + let current_file = shellescape(expand('%:p')) |
| 272 | + let filename = shellescape(expand('%:r')) |
| 273 | + let command = "silent !lessc " . current_file . " " . filename . ".css" |
| 274 | + execute command |
| 275 | + endfunction |
| 276 | + autocmd BufWritePost,FileWritePost *.less call LessToCss() |
| 277 | + let g:syntastic_check_on_open=1 " Run Syntastic when opening files |
| 278 | + let g:syntastic_python_checkers=['python', 'pyflakes'] " Be more strict in python syntax |
| 279 | + let g:pymode_folding=0 " Turn off python-mode folding |
| 280 | + let g:pymode_lint_write=0 " we have two lint plugins... |
| 281 | + let g:pymode_utils_whitespaces=0 " don't molest whitespace |
| 282 | + let g:ftplugin_sql_omni_key='<C-S>' " reset sql omni key |
| 283 | + let NERDSpaceDelims=1 " Add space delimiters |
| 284 | + let g:gitgutter_eager=0 " Only run gitgutter on read/write of files |
| 285 | + nmap gh <Plug>GitGutterNextHunk |
| 286 | + nmap gH <Plug>GitGutterPrevHunk |
| 287 | +" } |
| 288 | + |
| 289 | +" Include custom configurations via the .vimrc_custom file |
| 290 | +" which is included here: |
| 291 | +if filereadable($HOME."/.vimrc_custom") |
| 292 | + source $HOME/.vimrc_custom |
| 293 | +endif |
0 commit comments