forked from snapsam/homebase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
431 lines (340 loc) · 14.2 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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
set nocompatible " be iMproved, required
filetype off " required
" you first have to
" % git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
"Plugin 'tpope/vim-fugitive'
" plugin from http://vim-scripts.org/vim/scripts.html
"Plugin 'L9'
" Git plugin not hosted on GitHub
"Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
"Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
"Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Avoid a name conflict with L9
"Plugin 'user/L9', {'name': 'newL9'}
"My bundles
Plugin 'jlanzarotta/bufexplorer'
Plugin 'YankRing.vim'
Plugin 'ack.vim'
Plugin 'ctrlp.vim'
Plugin 'syntastic'
Plugin 'kawaz/shellcheck.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'vimtodo'
Plugin 'openurl.vim'
Plugin 'vim-javascript'
Plugin 'vim-misc'
Plugin 'KurtPreston/vim-autoformat-rails'
Plugin 'Lokaltog/vim-easymotion'
Plugin 'xolox/vim-session'
Plugin 'itchyny/calendar.vim'
Plugin 'triglav/vim-visual-increment'
Plugin 'juvenn/mustache.vim'
Plugin 'bkad/CamelCaseMotion'
Plugin 'tpope/vim-git'
Plugin 'jiangmiao/auto-pairs'
Plugin 'SirVer/ultisnips'
" OMG FINALLY!!!!
Plugin 'vim-scripts/ReplaceWithRegister'
Plugin 'tommcdo/vim-exchange'
" Snippets are separated from the engine. Add this if you want them:
Plugin 'honza/vim-snippets'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" First setup variable for other variables
"let g:useNinjaTagList=1
set shell=/bin/bash
syntax on
if ( filereadable($HOME . "/.vimrc.site") )
source $HOME/.vimrc.site
endif
""""""""""""""" Global Setup """"""""""""""""""""
"First source the environment location
source $HOME/.eihooks/dotfiles/vimrc
""""""""""""""" Global Options """"""""""""""""""""
set fo+=qr " q: gq foramts with comments, see :help fo-table, r: auto insert comments on new lines
set foldcolumn=0 " turn off the foldcolumn
set history=200 " Remember 100 lines of history, for commands and searches
set hls " highlight serach terms
set list " Show tabs differently
set listchars=tab:>- " Use >--- for tabs
set nolinebreak " don't wrap at words, messes up copying
set smartcase " if any capitol in search, turns search case sensitive
set shiftwidth=2 " use 2 space idnetning
set softtabstop=2 " use 4 space indenting
set ts=2 " Default to 4 spaces for tabs
"set tags=~/.commontags,./tags " Setup the standard tags files
set textwidth=0 " turn wrapping off
set visualbell " Use a flash instead of a sound for bells
set wildmode=longest:full " Matches only to longest filename, displays to menu possible matches
set complete=.,w,b,u " complete from current file, and current buffers default: .,w,b,u,t,i trying to keep down completion time
set directory=$HOME/.vim/tmp " set directory for tmp files to be in .vim, so that .swp files are not littered
set clipboard=unnamed " Use the * register when a register is not specified - unifies with system clipboard!
set modeline " Let individual files overrise config via modeline
set modelines=2 " Check the first/last 2 lines
"set foldmethod=indent " use indent unless overridden
set foldlevel=0 " show contents of all folds
"set foldcolumn=2 " set a column incase we need it
filetype plugin on "turns on filetype plugin, lets matchit work well
colorscheme oldzeller "changes color scheme to something that looks decent on the mac
" Set the vim info options
" In order: local marks for N files are saved, global marks are saved,
" a maximum of 500 lines for each register is saved,
" command history number, search history number,
" restore the buffer list and restore global variables
"if so that older versions of vim won't barf on standard systems
if (v:version >= 603)
set viminfo='1000,f1,<500,:100,/100,%,!
endif
" Open a the quickfix window after any grep-style event
autocmd QuickFixCmdPost *grep* cwindow
""""""""""""""" Status Line """"""""""""""""""""
" Set the status line
set statusline=%f\ %y%{GetStatusEx()}[b:%n]\ %{fugitive#statusline()}\ %m%r%=(%l/%L,%c%V)\ %P
" Function for getting the file format and the encoding for the status line.
function! GetStatusEx()
let str = ' [' . &fileformat
if has('multi_byte') && &fileencoding != ''
let str = str . ':' . &fileencoding
endif
let str = str . '] '
return str
endfunction
" Setup the status line to display the tagname, if the taglist plugin has been
" loaded
autocmd VimEnter * try
autocmd VimEnter * call Tlist_Get_Tagname_By_Line()
autocmd VimEnter * set statusline=%f\ %y%{GetStatusEx()}[b:%n]\ [t:%{Tlist_Get_Tagname_By_Line()}]\ %m%r%=(%l/%L,%c%V)\ %P
autocmd VimEnter * map <silent> <Leader>tap :TlistAddFilesRecursive . *pm<CR>
autocmd VimEnter * catch
autocmd VimEnter * endt
""""""""""""""" Filetype Settings """"""""""""""""
" explicitly map file extension .t to perl syntax instead of tads
" which is auto detected by file type plug-in on
" This line should always be after file type plug-in
autocmd BufNewFile,BufRead *.t set syntax=perl
"Set an autocommand to turn off cindenting for mail types
au FileType mail set nocindent
" Turn off cursor line in mail
au Filetype mail highlight! CursorLine cterm=NONE ctermbg=NONE
" Fold the headers out of view
" au FileType mail 1,/^\s*$/fold
" Correct indenting behavior for # in non C++ code (it used to force it to the
" beginning, since # starts a preprocessor line in C++, but in perl we want to
" to be at the indent level of the code)
set cinkeys-=0#
au FileType c,cpp set cinkeys+=0#
""""""""""""""" Plugin Settings """"""""""""""""
" vim todo settings
autocmd BufNewFile,BufRead *.todo set foldlevelstart=0 "todo files have a fold level..
autocmd BufNewFile,BufRead *.todo set filetype=todo " .todo files to filetype todo
" Force folds to display
autocmd BufNewFile,BufRead *.todo normal zX
" map \dg to insearch daily goals todo at the end of the list
autocmd BufNewFile,BufRead *.todo map <Leader>dg GoTODO ds {ds} Send daily goal email<ESC>
" map tds in insert mode
autocmd BufNewFile,BufRead *.todo iab tds <C-R>=strftime("%Y-%m-%d", localtime()+86400)<CR>
autocmd BufNewFile,BufRead *.todo iab {tds} {<C-R>=strftime("%Y-%m-%d", localtime()+86400)<CR>}
let g:todo_done_file = ".todo_done_log.todo" " Set file to put done tasks in
let g:todo_browser = "open" " what browser to use to open incidents
" CamelCaseMotion mappings
" map <silent> w <Plug>CamelCaseMotion_w
" map <silent> b <Plug>CamelCaseMotion_b
" map <silent> e <Plug>CamelCaseMotion_e
" sunmap w
" sunmap b
" sunmap e
" calendar settings
" PrePad taken from stackoverflow:
" http://stackoverflow.com/questions/4964772/string-formatting-padding-in-vim
function! PrePad(s,amt,...)
if a:0 > 0
let char = a:1
else
let char = ' '
endif
return repeat(char,a:amt - len(a:s)) . a:s
endfunction
function InsertCalendarDueDate(day,month,year,week,dir)
" day : day you actioned
" month : month you actioned
" year : year you actioned
" week : day of week (Mo=1 ... Su=7)
" dir : direction of calendar
exe 'q'
exe 'normal A {' . a:year . '-' . PrePad(a:month, 2, '0') . '-' . PrePad(a:day, 2, '0') . '}'
endfunction
let calendar_action = 'InsertCalendarDueDate'
let g:calendar_no_mappings=0 " turn off default mappings
nmap <unique> <Leader>cal <Plug>CalendarH
nmap <unique> <Leader>caL <Plug>CalendarV
"rcsvers.vim settings
let g:rvSaveDirectoryType = 1 "Use single directory for all files
let g:rvSaveDirectoryName = "$HOME/.vim/RCSFiles/" "Place to save RCS files
"Setup exlcude expressions for rcs
"1. Mutt mail files
"2. p4 submit descriptions
"3. tmp files from perforce form commands
let g:rvExcludeExpression = 'muttng-srossoff-\d\+\|p4submitdesc\.txt\|\/tmp\.\d\+\.\d\+'
let g:rvRlogOptions = '-zLT' "Display log in local timezone
"YankRing settings...
"Don't remap <C-N> and <C-P>
let g:yankring_replace_n_pkey = '<F3>'
let g:yankring_replace_n_nkey = '<F2>'
"AddressComplete Settings
"automatically address complete on exit
let g:addressCompleteOnExit = 1
" setup <++> in empty header fields, redefine tab to move between them
let g:useMailFieldTabbing = 1
"Buff explorer settings
let g:bufExplorerSplitOutPathName=-1 " Don't split the path and file name.
" Large file settings in MB
let g:LargeFile = 4
" EasyMotion settings
" Use - as the leader for EasyMotion
let g:EasyMotion_leader_key = '-'
" Session settings
"When opened with a session, save the changes
let g:session_autosave = 'yes'
"When opened, use the latest session
"let g:session_default_to_last = 'yes'
"Auto open the last session
let g:session_autoload = 'no'
"Ctrlp settings
"Default to using regexes
let g:ctrlp_regexp = 1
" Use Ctrl-, rather than Ctrl-p
let g:ctrlp_map = '<C-a>'
" Keep the cache file across restarts for faster startup
let g:ctrlp_clear_cache_on_exit = 0
" Setup alternate command maps TODO: why don't they display?
nn <silent> <Leader>ab :CtrlPBuffer<CR>
nn <silent> <Leader>aq :CtrlPQuickfix<CR>
"Syntastic Settings
" Automatically open the location list when there are errors
let g:syntastic_auto_loc_list = 1
" Use my jshintrc file rather than default
let g:syntastic_javascript_jshint_args="-c ~/.jshintrc"
" Map <leader>st to SyntasticToggleMode
map <Leader>st :SyntasticReset<CR>
" Setup javascript as the only active syntax
let g:syntastic_mode_map = { 'mode': 'passive',
\ 'active_filetypes': ['javascript'],
\ 'passive_filetypes': [] }
""""""""""""""" Command mappings """"""""""""""""
"Map statements
"map comma to yank to mark a
map , y'a
"map the buff explorer open key
map <F8> \be
"Map for YRShow
map <F4> :YRShow<CR>
map <Leader>yr :YRShow<CR>
" Make enter and Sift-Enter insert lines without going to insert mode
" Next Line Doesn't work, why not?
"noremap <Shift-Enter> O<ESC>j
"nmap <Enter> o<ESC>k
"Use EnhancedCommentify for commenting
noremap <silent> - :call EnhancedCommentify('no', 'comment')<CR>j
noremap <silent> _ :call EnhancedCommentify('no', 'decomment')<CR>j
"Normal Mode Maps
"map control arrow to move between buffers
nmap <C-n> :bn<CR>
nmap <C-p> :bp<CR>
"map F1 to paste in the selection buffer (*)
nmap <F1> "*p
" Make "." go back to the starting point on the line
nmap . .`[
" Make \tp toggle paste mode
nmap \tp :set paste!<CR>
" Map \r to grab the last paragraph, copy it, select the new copy, and pipe
" it through a recs command
:nmap <leader>r GV{yGpGV{j!recs-
" Maybe if I had a real X buffer, this would be cool. Too bad.
" " X buffer cut/paste
" nmap <Leader>xp "*p
" nmap <Leader>xy :set opfunc=XBufferYank<CR>g@
"
" function! XBufferYank(type, ...)
" '[,']yank "*
" endfunction
" map \uo to open the first url on the line
map <Leader>uo :call OpenUrl()<CR>
"Visual Mode Maps
"Visual mode comment adding
"vmap <Leader>c :s/^/#/g<enter>:nohl<enter> " leader-c comments block
"vmap <Leader>x :s/^#//g<enter>:nohl<enter> " leader-x uncomments block
vmap <C-A> :Align =<enter> " Align = in block
vmap <Leader>h :Align =><enter> " Align => in block
"Insert Mode Maps
"map ctrl-a and ctrl-e to act like emacs
imap <C-A> <C-O>^
imap <C-E> <C-O>$
"Commands for perforce, from Scott Windsor
" Perforce commands
" Works, but commented out for now, want these commands elsewhere
"command -nargs=0 Diff :!p4 diff %
"command -nargs=0 Changes :!p4 changes %
"command -nargs=1 Describe :!p4 describe <args> | more
"command -nargs=0 Edit :!p4 edit %
"command -nargs=0 Revert :!p4 revert %
""""""""""""""" Syntax """"""""""""""""""""
" turn on syntax coloring
syntax on
" Add support for spitfire comments
function EnhCommentifyCallback(ft)
if a:ft == 'htmlspitfire'
let b:ECcommentOpen = '##'
let b:ECcommentClose = ''
endif
endfunction
let g:EnhCommentifyCallbackExists = 'Yes'
""""""""""""""" Version 7 Settings """"""""""""""""""""
if ( v:version >= 700 )
" Vim 7.0c+ options
"set cursorline " Get a highlight of the line the cursor is on
" Change cursor line to highlight the line
highlight! CursorLine cterm=NONE ctermbg=0
" Change spelling colors to not suck, green and brown respectively
highlight! SpellCap ctermbg=3
highlight! SpellBad ctermbg=2
endif
if ( v:version >= 703 )
set undofile " Keep undo history around, across vim reboots
set undodir=$HOME/.vim/tmp " set directory for undo files
endif
""""""""""""""" Version 7 Settings """"""""""""""""""""
" The highlight changes at least have to be at the end here... not sure why
" Highlight trailing whitespace in red so I can prevent that.
" Must be below any colorscheme setting
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
syntax match nonascii "[^\x00-\x7F]"