-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathvimrc
416 lines (383 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
" .vimrc by Jordan Lewis
"
" Settings {{{
" General {{{
set autowrite " Flush to disk when using :make and stuff
set autoread " Reload safely if outside change detected
set backspace=indent,eol,start " Allow backspacing over everything
set confirm " Confirm various potentially dangerous actions
set gdefault " use s///g by default - s///gg to reverse
set hidden " Enable hidden buffers - :bn w/ changes!
set magic " Allows extended regexes
set nocompatible " Don't use Vi settings!
set noerrorbells " No annoying beeping
set nojoinspaces " Don't put extra spaces on joining sentences.
set nostartofline " Don't move to start of line on buffer next
set shell=/bin/bash " zsh screws up
set ttimeoutlen=50 " 50 milliseconds for esc timeout instead of 1000
set ttyfast " We are always going to be using a fast terminal.
call pathogen#infect()
filetype plugin indent on " File type detection on, (cindent for .c etc)
" }}}
" Appearance {{{
set background=light " Dark term bg (but bg=dark is gross)
set display=lastline " Display as much of the last line as possible, not @
set hlsearch " Hilight /search results!
set incsearch " do incremental searching
set list " Display listchars (see below)
set listchars=tab: ,trail:_ " display tabs as nbsps and trailing spaces as _
set matchtime=1 " 1/10 of a second for showmatch
set nomore " No spacing through messages!
set nonumber " Don't display line numbers on the side
set notitle " Don't display name of file and stuff in term title
set report=0 " Show a 'N lines were changed' report always
set ruler " Show current cursor position
set rulerformat=%25(%=%M%R\ (%n)%l,%c\ %P%)
set scrolloff=3 " Scroll screen at 3 lines from top/bottom
" o overwrite message for writing a file with subsequent message
" O message for reading a file overwrites any previous message.
" t truncate file message at the start if it is too long to fit. -> <
" T truncate other messages in the middle if they are too long. -> ...
" I don't give the intro message when starting Vim |:intro|.
set shortmess=aIoOTt " a=terse(s/[modified]/[+]/),I=nointro,oO=:bn no message
" set showcmd " display info on current selected visual field
set showmatch " Hilight the other bracket
set showmode " Show the current mode
set vb t_vb= " Turns off all belly things
set wildchar=<TAB> " Use tab as the tab key!
set wildmenu " Display a tab-completion menu for most things
set wildignore+=*.pyc,*.zip,*.gz,*.tar,*.o,*.so " Don't open these files
syntax on " Do syntax hilighting
" }}}
" Tabs and margins {{{
set tabstop=4 " Tab characters = 4 spaces when displayed
set shiftwidth=4 " Use 4 spaces for each insertion of (auto)indent
set expandtab " <tab> -> spaces in insert mode
set autoindent " always set autoindenting on
set smarttab " Smart tabbing!
set shiftround " < and > will hit indent levels instead of +-4 always
" set tw=80 " Make hard CR every 80 lines
" }}}
" Inter-session stuff {{{
" set viminfo='50,/50,:50,<50,n~/.viminfo
set history=100 " keep 100 lines of command line history
set nobackup " Don't back up stuff. (makes nasty files~)
" }}}
" Folding {{{
set foldmethod=marker " Fold on 3 {, commenstring -> don't include " in title
"set foldclose=all " Close folds when you leave them
"set foldenable " All folds closed by default
" }}}
" Tags {{{
set tags+='./.tags,.tags' " add .tags files
set tags+='./../tags,../tags,./../.tags,../.tags' " look in the level above
"}}}
" Miscellaneous {{{
"set commentstring="%s
set dict=/usr/share/dict/words
set tildeop " Turn ~ into an operator
set switchbuf=useopen " Jump to open window containing jump target if available
let g:gitgutter_sign_added = '·'
let g:gitgutter_sign_modified = '.'
let g:gitgutter_sign_removed = '.'
let g:gitgutter_sign_modified_removed = '.'
"let g:go_highlight_functions = 1
"let g:go_highlight_methods = 1
"let g:go_highlight_fields = 1
"let g:go_highlight_structs = 1
"let g:go_highlight_interfaces = 1
"let g:go_highlight_operators = 1
"let g:go_highlight_build_constraints = 1
" These are kind of slow, let's turn them off for now
" let g:go_auto_type_info = 1
" let g:go_auto_sameids = 1
let g:go_fmt_command = "goimports"
"autocmd FileType go set number fo+=croq tw=100
"autocmd Filetype go set makeprg=go\ build\ .
"autocmd Filetype go let g:neocomplete#enable_at_startup = 1
"autocmd Filetype golet g:neocomplete#enable_smart_case = 1
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
let g:session_autoload = 'no'
let g:session_autosave = 'yes'
"}}}
" Persistent undo {{{
if exists("+undofile")
set udf
set undodir=~/.vimundo
endif
" }}}
" }}}
" Mappings {{{
" Map Q to format line
map Q gq
" Make space pagedown
nmap <Space> <C-D>
" F5 -> toggle :set paste
set pastetoggle=<f5>
" F11 -> spellcheck hilighting on
map <F11> :call <SID>spell()<CR>
imap <F11> <Esc>:call <SID>spell()<CR>
" F12 -> toggle :set number
map <F12> :set number!<CR>
nmap gu :silent GundoToggle<CR>
nnoremap ! :Clam<space>
vnoremap ! :ClamVisual<space>
let g:clam_autoreturn = 1
nmap <leader>c <Plug>CommentaryLine
xmap <leader>c <Plug>Commentary
let g:ctrlp_map = '<C-F>'
" Make ctrl-n and ctrl-p cycle through buffers in cmd mode
nnoremap <C-N> :bn<Enter>
nnoremap <C-P> :bp<Enter>
" Make ctrl-j and ctrl-k cycle through split windows in cmd mode
"nnoremap <C-J> :wincmd w<Enter>
"nnoremap <C-K> :wincmd W<Enter>
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" :w!! sudo-saves the current buffer
cmap w!! w !sudo tee % >/dev/null
vmap <C-c> y:call system("pbcopy", getreg("\""))<CR>
nmap `/ :nohl<CR>
nmap <silent> <Leader>e :NERDTreeToggle<CR>
nmap <F8> :TagbarToggle<CR>
nmap <C-F> :Files<CR>
nmap <C-_> :Ag<CR> " vim sees _ as / - this is binding for C-/
au FileType go nmap <Leader>i <Plug>(go-info)
au FileType go nmap <Leader>gd <Plug>(go-doc)
au FileType go nmap <Leader>r <Plug>(go-run)
au FileType go nmap <F6> <Plug>(go-rename)
au FileType go nmap <F7> <Plug>(go-referrers)
au FileType go nmap <S-Down> <Plug>(go-implements)
au FileType go nmap <Leader>b <Plug>(go-build)
au FileType go nmap <Leader>t <Plug>(go-test)
au FileType go nmap gd <Plug>(go-def-tab)
" }}}
" Autocommands {{{
" Jump to last known cursor position on file edit {{{
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
" }}}
" Auto +x {{{
au BufWritePost *.sh silent !/bin/bash -c 'if [ -x % ]; then exit; else /bin/chmod +x %; fi'
au BufWritePost *.pl silent !/bin/bash -c 'if [ -x % ]; then exit; else /bin/chmod +x %; fi'
au BufWritePost *.py silent !/bin/bash -c 'if [ -x % ]; then exit; else /bin/chmod +x %; fi'
"}}}
" Language specific things (Thanks doy!) {{{
" Perl {{{
" :make does a syntax check
autocmd FileType perl setlocal makeprg=$VIMRUNTIME/tools/efm_perl.pl\ -c\ %\ $*
autocmd FileType perl setlocal errorformat=%f:%l:%m
" look up words in perldoc rather than man for K
autocmd FileType perl setlocal keywordprg=perldoc\ -f
" treat use lines as include lines (for tab completion, etc)
" XXX: it would be really sweet to make gf work with this, but unfortunately
" that checks the filename directly first, so things like 'use Moose' bring
" up the $LIB/Moose/ directory, since it exists, before evaluating includeexpr
autocmd FileType perl setlocal include=\\s*use\\s*
autocmd FileType perl setlocal includeexpr=substitute(v:fname,'::','/','g').'.pm'
autocmd FileType perl exe "setlocal path=" . system("perl -e 'print join \",\", @INC;'") . ",lib"
" }}}
" Python {{{
" look up words in python rather than man for K
autocmd FileType python setlocal keywordprg=pydoc
autocmd FileType python set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"
autocmd FileType python set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
"autocmd FileType python set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
"autocmd FileType python so ~/.vim/python_fold.vim
" }}}
" Latex {{{
" :make converts to pdf
if strlen(system('which xpdf')) && strlen(expand('$DISPLAY'))
autocmd FileType tex setlocal makeprg=(cd\ %:h\ &&\ pdflatex\ %:t\ &&\ xpdf\ $(echo\ %:t\ \\\|\ sed\ \'s/\\(\\.[^.]*\\)\\?$/.pdf/\'))
elseif strlen(system('which evince')) && strlen(expand('$DISPLAY'))
autocmd FileType tex setlocal makeprg=(cd\ %:h\ &&\ pdflatex\ %:t\ &&\ evince\ $(echo\ %:t\ \\\|\ sed\ \'s/\\(\\.[^.]*\\)\\?$/.pdf/\'))
else
autocmd FileType tex setlocal makeprg=(cd\ %:h\ &&\ pdflatex\ %:t)
endif
" see :help errorformat-LaTeX
autocmd FileType tex setlocal errorformat=\%E!\ LaTeX\ %trror:\ %m,
\%E!\ %m,
\%+WLaTeX\ %.%#Warning:\ %.%#line\ %l%.%#,
\%+W%.%#\ at\ lines\ %l--%*\\d,
\%WLaTeX\ %.%#Warning:\ %m,
\%Cl.%l\ %m,
\%+C\ \ %m.,
\%+C%.%#-%.%#,
\%+C%.%#[]%.%#,
\%+C[]%.%#,
\%+C%.%#%[{}\\]%.%#,
\%+C<%.%#>%.%#,
\%C\ \ %m,
\%-GSee\ the\ LaTeX%m,
\%-GType\ \ H\ <return>%m,
\%-G\ ...%.%#,
\%-G%.%#\ (C)\ %.%#,
\%-G(see\ the\ transcript%.%#),
\%-G\\s%#,
\%+O(%f)%r,
\%+P(%f%r, ") <-- add a comment to fix syntax highlighting
\%+P\ %\\=(%f%r,
\%+P%*[^()](%f%r,
\%+P[%\\d%[^()]%#(%f%r,
\%+Q)%r,
\%+Q%*[^()])%r,
\%+Q[%\\d%*[^()])%r\
" }}}
" Lua {{{
" :make does a syntax check
autocmd FileType lua setlocal makeprg=luac\ -p\ %
autocmd FileType lua setlocal errorformat=luac:\ %f:%l:\ %m
" set commentstring
autocmd FileType lua setlocal commentstring=--%s
" treat require lines as include lines (for tab completion, etc)
autocmd FileType lua setlocal include=\\s*require\\s*
autocmd FileType lua setlocal includeexpr=substitute(v:fname,'\\.','/','g').'.lua'
autocmd FileType lua exe "setlocal path=" . system("lua -e 'local fpath = \"\" for path in package.path:gmatch(\"[^;]*\") do if path:match(\"\?\.lua$\") then fpath = fpath .. path:gsub(\"\?\.lua$\", \"\") .. \",\" end end print(fpath:gsub(\",,\", \",.,\"):sub(0, -2))'")
" }}}
" Vim {{{
autocmd FileType {vim,help} setlocal keywordprg=:help
" }}}
" Java {{{
au Filetype java setlocal omnifunc=javacomplete#Complete
" }}}
" OCaml {{{
autocmd FileType ocaml source /Users/jordan/.opam/system/share/ocp-indent/vim/indent/ocaml.vim
" }}}
" Rust {{{
autocmd FileType rust setlocal sw=2
autocmd FileType rust setlocal ts=2
autocmd FileType rust setlocal sts=2
" }}}
" Use levdes syntax for .des files {{{
au BufRead,BufNewFile *.des set syntax=levdes
au BufRead,BufNewFile *.frag,*.vert,*.fp,*.vp,*.glsl set syntax=glsl
" }}}
autocmd BufNewFile,BufRead */sql/logictest/testdata/* set filetype=crlogictest tw=0
" }}}
" }}}
" Colors {{{
"autocmd BufWinEnter * syn match EOLWS excludenl /[ \t]\+$/
"highlight EOLWS ctermbg=red
"highlight Pmenu ctermfg=grey ctermbg=darkblue
"highlight PmenuSel ctermfg=red ctermbg=darkblue
"highlight PmenuSbar ctermbg=cyan
"highlight PmenuThumb ctermfg=red
"highlight Folded ctermbg=black ctermfg=darkgreen
"highlight Search None ctermfg=lightred
let g:vimclojure#HighlightBuiltins = 1
let g:vimclojure#HighlightContrib = 1
let g:vimclojure#DynamicHighlighting = 1
let g:vimclojure#FuzzyIndent = 1
let g:vimclojure#ParenRainbow = 1
let g:vimclojure#WantNailgun = 1
let g:vimclojure#NailgunClient = "/usr/local/bin/ng"
let g:solarized_visibility="normal"
let g:solarized_underline=0
"let g:solarized_termcolors=256
if $ITERM_PROFILE=="Default light"
set bg=light
else
set bg=dark
endif
colorscheme gruvbox
let python_hilight_all=1
" Rainbowy parens, braces, and brackets thanks to Eidolos{{{
let g:rainbow = 1 " Must be a more compact way of setting all these
let g:rainbow_nested = 1
let g:rainbow_paren = 1
let g:rainbow_brace = 1
let g:rainbow_bracket = 1
autocmd BufReadPost,BufNewFile *.ss source $HOME/.vim/scripts/rainbow_paren.vim
autocmd BufReadPost,BufNewFile *.scm source $HOME/.vim/scripts/rainbow_paren.vim
"}}}
" }}}
" Functions {{{
" Add spelling stuff, invoke by f11 {{{
function s:spell()
if !exists("s:spell_check") || s:spell_check == 0
echo "Spell check on"
let s:spell_check = 1
setlocal spell spelllang=en_us
else
echo "Spell check off"
let s:spell_check = 0
setlocal spell spelllang=
endif
endfunction " }}}
" diff between current file and its original state {{{
let s:foldmethod = &foldmethod
let s:foldenable = &foldenable
function s:diffstart(read_cmd)
let s:foldmethod = &foldmethod
let s:foldenable = &foldenable
vert new
set bt=nofile
try
exe a:read_cmd
catch /.*/
echoerr v:exception
call s:diffstop()
return
endtry
diffthis
wincmd p
diffthis
endfunction
function s:diffstop()
diffoff!
if winnr('$') != 1
wincmd t
quit
endif
let &foldmethod = s:foldmethod
let &foldenable = s:foldenable
endfunction
function s:vcs_orig(file)
if filewritable('.svn')
return system('svn cat ' . a:file)
elseif filewritable('CVS')
return system("AFILE=" . a:file . "; MODFILE=`tempfile`; DIFF=`tempfile`; cp $AFILE $MODFILE && cvs diff -u $AFILE > $DIFF; patch -R $MODFILE $DIFF 2>&1 > /dev/null && cat $MODFILE; rm $MODFILE $DIFF")
elseif finddir('_darcs', '.;') =~ '_darcs'
return system('darcs show contents ' . a:file)
elseif finddir('.git', '.;') =~ '.git'
return system('git show ' . a:file)
else
throw 'No vcs found'
endif
endfunction
nmap <silent> ds :call <SID>diffstart('read # <bar> normal ggdd')<CR>
nmap <silent> dc :call <SID>diffstart('call append(0, split(s:vcs_orig(expand("#")), "\n", 1)) <bar> normal Gdddd')<CR>
nmap <silent> de :call <SID>diffstop()<CR>
" }}}
" }}}
" vim:fdm=marker commentstring="%s