-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvimrc
executable file
·377 lines (301 loc) · 9.35 KB
/
vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
" .vimrc
"
" Author: Dave Bolton <[email protected]>
" Source: http://github.com/lightningdb/dotfiles/blob/master/vimrc
set nocompatible
set magic
set shortmess+=I
syntax on
let mapleader = ","
let maplocalleader = "\\"
set hls
set incsearch
set showcmd
set hidden
set wildmenu
set autoread
set title
set nobackup
set nowritebackup
set smartindent
set gdefault
set ttyfast
set ruler
set history=500
set cursorline
set nu " Line numbers on
set nowrap " Line wrapping off
set directory=/tmp
set wildignore+=vendor/rails/**,teamsite/**,spec/fixtures/**
" Visual
set novisualbell " No blinking .
set noerrorbells " No noise.
set showmatch " Show matching brackets.
set mat=5 " Bracket blinking.
" Show $ at end of line and trailing space as ~
set lcs=tab:\ \ ,eol:$,trail:~,extends:>,precedes:<
" BUT, turn the above off by default
" need both for vim to start with whitespace and line-endings off
set list
:set list!
" no toolbar, no menu
set guioptions-=T
set guioptions-=m
" os x backspace fix
set backspace=indent,eol,start
" tabs -> spaces
set expandtab
set tabstop=2
set softtabstop=2
set shiftwidth=2
set scrolloff=3
set sidescroll=1
set sidescrolloff=10
set mouse=a " turn mouse on
set virtualedit+=block
" Save when losing focus
au FocusLost * :wa
" %% expands to the current directory
cnoremap %% <C-R>=expand('%:h').'/'<cr>
let g:surround_{char2nr('-')} = "<% \r %>"
let g:surround_{char2nr('=')} = "<%= \r %>"
let g:yankring_history_dir = '$HOME'
let g:yankring_manual_clipboard_check = 0
let g:yankring_replace_n_pkey = '<C-y>'
"let g:yankring_replace_n_nkey = '<C-y>'
let g:yankring_n_keys = 'Y D'
let g:ycm_key_detailed_diagnostics = ''
let g:UltiSnipsSnippetDirectories=["UltiSnips", "ldb-snippets"]
let g:UltiSnipsExpandTrigger="<F3>"
let g:UltiSnipsListSnippets="<c-F3>"
let g:UltiSnipsJumpForwardTrigger="<F3>"
let g:UltiSnipsJumpBackwardTrigger="<s-F3>"
let g:session_autoload = 'no'
let g:vimwiki_hl_headers = 1
let g:ackprg = 'ag --nogroup --nocolor --column'
let g:airline_enable_fugitive=1
" #########################
" BINDINGS
" #########################
nnoremap <leader><leader> <c-^>
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-h> <c-w>h
nnoremap <c-l> <c-w>l
noremap j gj
noremap k gk
nnoremap <CR> o<ESC>
" don't use above mapping of CR for newline in quickfix window
augroup quickfix
autocmd!
au BufReadPost quickfix nnoremap <CR> <CR>
augroup END
nnoremap .. '.zz
noremap <leader>q :BufO<CR>
" A function to search for word under cursor, using Ack plugin
function! SearchWord()
normal "zyiw
exe ':Ack! '.@z
endfunction
noremap <leader>f :Ack!<space>
noremap <leader>F :call SearchWord()<CR>
" space = pagedown, - = pageup
noremap <Space> <PageDown>
noremap - <PageUp>
nnoremap <F2><F2> :vsplit<CR>
nnoremap <F4><F4> :set invwrap wrap?<CR> " use f4f4 to toggle wordwrap
nnoremap <F5><F5> :set invhls hls?<CR> " use f5f5 to toggle search hilight
" Yankring Show
nnoremap <silent> <F2> :YRShow<cr>
inoremap <silent> <F2> <ESC>:YRShow<cr>
noremap <C-t> <Esc>:%s/[ ^I]*$//<CR>:retab<CR> " remove trailing space and retab
nnoremap <leader>sv :source ~/.vimrc<CR>
nnoremap <leader>ev <C-w>s<C-w>j<C-w>L:e $MYVIMRC<cr>
nnoremap <leader>es <C-w>s<C-w>j<C-w>L:e ~/.vim/bundle/Ultisnips-snippets/snippets<cr>
nnoremap <leader>d :NERDTreeToggle<CR>
nnoremap <S-H> :BufSurfBack<CR>
nnoremap <S-L> :BufSurfForward<CR>
" Faster Esc
inoremap jk <esc>
" Sudo to write
cmap w!! w !sudo tee % >/dev/null
" CTags
noremap <Leader>rt :!ctags --extra=+f --exclude=teamsite --exclude=public -R *<CR><CR>
" Toggle off whitespace highlighting
noremap <Leader>w :set list!<CR>
" Don't use Ex mode, use Q for formatting
noremap Q gq
nnoremap <leader>gd :Gdiff<cr>
nnoremap <leader>gs :Gstatus<cr>
nnoremap <leader>gw :Gwrite<cr>
nnoremap <leader>ga :Gadd<cr>
nnoremap <leader>gb :Gblame<cr>
nnoremap <leader>gco :Gcheckout<cr>
nnoremap <leader>gci :Gcommit<cr>
nnoremap <leader>gm :Gmove<cr>
nnoremap <leader>gr :Gremove<cr>
nnoremap <leader>gl :Shell git gl -18<cr>:wincmd \|<cr>
noremap <leader>vo :VimwikiIndex<cr>:VimwikiGoto
noremap <leader>mi :VimwikiIndex<cr>:VimwikiGoto MyInbox<cr>
nmap <leader>xx <Plug>VimwikiToggleListItem
nmap <leader>wq <Plug>VimwikiUISelect
noremap <leader>tt :read !task today<cr>
noremap <leader>ops :OpenSession inbox_and_goals_and_diary<cr>
" #########################
" END BINDINGS
" #########################
" vimwiki options
let wiki_life = {}
let wiki_life.path = '~/vimwiki_split/life'
let wiki_wha = {}
let wiki_wha.path = '~/vimwiki_split/wha'
let wiki_news = {}
let wiki_news.path = '~/vimwiki_split/news'
let wiki_westfield = {}
let wiki_westfield.path = '~/vimwiki_split/westfield'
let g:vimwiki_list = [wiki_life, wiki_wha, wiki_news, wiki_westfield]
let g:vimwiki_table_auto_fmt=0
let g:vimwiki_table_mappings=0
let g:vimwiki_use_calendar=1
"let g:vimwiki_debug=1
" #### From DestroyAllSoftware screencast on file navigation in vim
set winwidth=84 " always have enough width to view file
" ####
let html_use_css=1
filetype off " set up vundle to allow plugin bundling
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'vim-scripts/BufOnly.vim'
Plugin 'vim-scripts/calendar.vim--Matsumoto'
Plugin 'vim-scripts/YankRing.vim'
Plugin 'mileszs/ack.vim'
Plugin 'vim-scripts/genutils'
"Plugin 'vim-scripts/LustyExplorer'
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
Plugin 'godlygeek/tabular'
Plugin 'jeetsukumaran/vim-buffergator'
Plugin 'ton/vim-bufsurf'
Plugin 'altercation/vim-colors-solarized'
Plugin 'tpope/vim-cucumber'
Plugin 'tpope/vim-endwise'
Plugin 'tpope/vim-fugitive'
Plugin 'wgibbs/vim-irblack'
Plugin 'pangloss/vim-javascript'
Plugin 'tpope/vim-markdown'
Plugin 'tpope/vim-ragtag'
Plugin 'tpope/vim-rails'
Plugin 'tpope/vim-repeat'
Plugin 'vim-ruby/vim-ruby'
Plugin 'derekwyatt/vim-scala'
Plugin 'tpope/vim-surround'
Plugin 'vim-scripts/vimwiki'
Plugin 'gmarik/vundle'
Plugin 'kien/ctrlp.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'Raimondi/delimitMate'
"Plugin 'xolox/vim-session'
Plugin 'terryma/vim-expand-region'
Plugin 'terryma/vim-multiple-cursors'
Plugin 'bling/vim-airline'
Plugin 'Shougo/unite.vim'
Plugin 'Keithbsmiley/rspec.vim'
Plugin 'farseer90718/vim-taskwarrior'
Plugin 'SirVer/ultisnips'
Plugin 'lightningdb/UltiSnips-snippets'
" For debugging colorschemes
"Plugin 'gerw/vim-HiLinkTrace'
"Plugin 'vim-scripts/hexHighlight.vim'
call vundle#end()
filetype off " set up vundle to allow plugin bundling
filetype on " Enable filetype detection
filetype indent on " Enable filetype-specific indenting
filetype plugin on " Enable filetype-specific plugins
"statusline setup
set statusline=%f "tail of the filename
"display a warning if fileformat isnt unix
set statusline+=%#warningmsg#
set statusline+=%{&ff!='unix'?'['.&ff.']':''}
set statusline+=%*
"display a warning if file encoding isnt utf-8
set statusline+=%#warningmsg#
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
set statusline+=%*
set statusline+=%h "help file flag
set statusline+=%y "filetype
set statusline+=%r "read only flag
set statusline+=%m "modified flag
set statusline+=%{fugitive#statusline()}
"display a warning if &paste is set
set statusline+=%#error#
set statusline+=%{&paste?'[paste]':''}
set statusline+=%*
set statusline+=%= "left/right separator
set statusline+=%c, "cursor column
set statusline+=%l/%L "cursor line/total lines
set statusline+=\ %P "percent through file
set laststatus=2
"folding settings
set foldmethod=indent "fold based on indent
set foldnestmax=10 "deepest fold is 10 levels
set nofoldenable "dont fold by default
set foldlevel=1
command! Rroutes :R config/routes.rb
command! Rblueprints :R spec/blueprints.rb
nnoremap <Leader>aa :Tabularize /\|<CR>
vnoremap <Leader>aa :Tabularize /\|<CR>
" ### Search vimwiki
noremap <leader>ss :sb<cr>:call GetSearchInput()<cr>:VimwikiIndex<cr>:exe ":VimwikiSearch \/" . VWSearch . "\/"<cr>:lopen<cr>
if !exists('*GetSearchInput')
function GetSearchInput()
call inputsave()
let g:VWSearch = input("Search Vimwiki:")
call inputrestore()
endfunction
endif
" #### From DestroyAllSoftware screencast on file navigation in vim
function! RunTests(filename)
" Write the file and run tests for the given filename
:w
:silent !echo;echo;echo;echo;echo
exec ":!bundle exec rspec " . a:filename
endfunction
function! SetTestFile()
" Set the spec file that tests will be run for.
let t:ldb_test_file=@%
endfunction
function! RunTestFile(...)
if a:0
let command_suffix = a:1
else
let command_suffix = ""
endif
" Run the tests for the previously-marked file.
let in_spec_file = match(expand("%"), '_spec.rb$') != -1
if in_spec_file
call SetTestFile()
elseif !exists("t:ldb_test_file")
return
end
call RunTests(t:ldb_test_file . command_suffix)
endfunction
function! RunNearestTest()
let spec_line_number = line('.')
call RunTestFile(":" . spec_line_number)
endfunction
" Run this file
noremap <leader>r :call RunTestFile()<cr>
" Run only the example under the cursor
noremap <leader>R :call RunNearestTest()<cr>
" Run all test files
noremap <leader>rr :call RunTests('spec')<cr>
set t_Co=256
colorscheme ir_black
set background=dark
"colorscheme solarized
"set background=light
" toggle the background for solarized light or dark
"call togglebg#map("<F5>")
if filereadable(glob("~/.vimrc.local"))
source "~/.vimrc.local"
endif