forked from tempire/dotvim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
386 lines (319 loc) · 9.63 KB
/
vimrc
File metadata and controls
386 lines (319 loc) · 9.63 KB
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
" slimv options
let g:slimv_keybindings=1
let g:lisp_rainbow=1
let g:slimv_leader=',s'
" Gist options - put code in clipboard
let g:gist_clip_command = 'pbcopy'
let g:gist_detect_filetype = 1
let g:gist_open_browser_after_post = 1
" Use our user unless we have a sudo user, then is it
let luser = substitute(system('whoami'), '\n', '', '')
if strlen($SUDO_USER)
let luser = $SUDO_USER
endif
" pathogen
call pathogen#infect()
"silent! call pathogen#runtime_append_all_bundles()
"silent! call pathogen#helptags()
set number
set nocompatible
set wildignore+=*CVS
" snipmate
filetype on
filetype plugin on
filetype indent on
" folding
"let perl_fold=1
"let perl_extended_vars = 1
set laststatus=2
" backspaces over everything in insert mode
set backspace=indent,eol,start
" Indent
set autoindent
set tabstop=2
set shiftwidth=2
set smartindent
set expandtab
syntax on
set textwidth=79
set formatoptions=qrn1
"if version >= 703
if exists('+colorcolumn')
set colorcolumn=80
endif
" folding
set foldmethod=indent
" mojo
let mojo_highlight_data = 1
" Sidebar folder navigation
let NERDTreeShowLineNumbers=1
let NERDTreeShowBookmarks=1
let NERDTreeChDirMode=2
let NERDTreeWinSize=35
let NERDTreeIgnore=['CVS']
set incsearch
set ignorecase
set smartcase
set visualbell
set noerrorbells
set hlsearch
set history=500
" scrolling
set ruler
set scrolloff=10 " Scroll with 10 line buffer
" clear recent search highlighting with space
:nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
" save files as root without prior sudo
cmap w!! w !sudo tee % >/dev/null
set nobackup
set noswapfile
" git branch
set statusline=%f " tail of the filename
"set statusline+=%{fugitive#statusline()}
set statusline+=%= "left/right separator
set statusline+=%{StatuslineCurrentHighlight()}\ \ "current highlight
set statusline+=%c, "cursor column
set statusline+=%l/%L "cursor line/total lines
set statusline+=\ %P "percent through file
set laststatus=2 " Always show status line
" warning for mixed indenting
set statusline+=%#error#
set statusline+=%{StatuslineTabWarning()}
set statusline+=%*
set statusline+=%h "help file flag
set statusline+=%y "filetype
set statusline+=%r "read only flag
set statusline+=%m "modified flag
set list
set listchars=tab:.\ ,trail:.,extends:#,nbsp:.
" font
if has("gui_gnome")
set guifont=Monospace\ 8
set list
set listchars=tab:▸\ ,eol:¬,extends:#,nbsp:.,trail:.
elseif has("gui_macvim")
"set guifont=Menlo:h12
set guifont=Monaco:h12
set list
set listchars=tab:▸\ ,eol:¬,extends:#,nbsp:.,trail:.
endif
if &t_Co >= 256 || has("gui_running")
set guifont=Monaco:h12
colorscheme kraihlight
set guioptions-=r
set go-=L
set go-=T
else
colorscheme ir_black
endif
" line tracking
set numberwidth=5
set cursorline
set cursorcolumn
" turn off cursor blinking
set guicursor+=a:blinkon0
function! StatuslineCurrentHighlight()
let name = synIDattr(synID(line('.'),col('.'),1),'name')
if name == ''
return ''
else
return '[' . name . ']'
endif
endfunction
" shortcuts
inoremap jj <Esc>
nnoremap ; :
let mapleader = ','
nnoremap <Leader>a :Ack
noremap <Leader>, :NERDTreeToggle<cr>
map <Leader>t :tabnew<cr>
map <Leader>h :tabprevious<cr>
map <Leader>l :tabnext<cr>
map <Leader>w :tabclose<cr>
map <Leader>pd :!perldoc %<cr>
map <Leader>cs :colorscheme sri<cr>
map <Leader>f :TlistToggle<cr>
map <Leader>M :!morbo %<cr>
map <Leader>x :!perl -Ilib %<cr>
map <leader>H :call HexHighlight()<cr>
map <leader>tts :%s/\s\+$//<cr>
map <leader>term :ConqueTerm bash<cr>
map <leader>b :TagbarToggle<cr>
"
" cd to directory of current file
map <leader>cd :cd %:p:h<cr>
map <leader>F :NERDTreeFind<cr>
map <leader>R :source ~/.vimrc<cr>
map <leader>pull :silent !sandbox pull %<cr>
map <leader>push :silent !sandbox push %<cr>
map <leader>same :!sandbox same %<cr>
map <leader>rt :!sandbox rtest %<cr>
map <leader>diff :!sandbox diff %<cr>
nnoremap <F5> :GundoToggle<cr>
" http://vim.wikia.com/wiki/Redirect_g_search_output
nmap <leader>s :redir @a<cr>:g//<cr>:redir END<cr>:new<cr>:put! a<cr><cr>zRggd<cr>
" Move single lines up-down
nmap <c-up> ddkP
nmap <c-down> ddp
"nmap <c-up [e
"nmap <c-down> ]e
" Resize vertical windows
nmap + <c-w>+
nmap _ <c-w>-
" Resize horizontal windows
nmap > <c-w>>
nmap < <c-w><
" Move multiple lines up-down
vmap <c-up> xkP`[V`]
vmap <c-down> xp`[V`]
"vmap <c-up> [egv
"vmap <c-down> ]egv
"Insert on empty line, with lines above and below (for mojocasts)
nmap oo o<Esc>O
" autocompletion
imap <Leader><Tab> <C-X><C-O>
" Autocomplpop perl autocompletion
let g:acp_behaviorPerlOmniLength = 4
let g:acp_completeoptPreview = 0
" local set in perlomni.vim plugin does not work as expected..set globally
set omnifunc=PerlComplete
" perldoc for module || perl command
noremap K :!perldoc <cword> <bar><bar> perldoc -f <cword><cr>
" Opens nerdtree and puts focus in edited file
"autocmd VimEnter * NERDTree
"autocmd VimEnter * wincmd p
" file types
au BufRead,BufNewFile *.asd,*.lisp set filetype=lisp
au BufRead,BufNewFile *.t,*.cgi set filetype=perl
au BufRead,BufNewFile *.conf set filetype=apache
au BufRead,BufNewFile *.app set filetype=erlang
" haskell support
au BufEnter *.hs,*.lhs compiler ghc
let g:haddock_browser = "open"
let g:haddock_browser_callformat = "%s %s"
let g:haddock_docdir = "/Users/glen/.cabal/share/doc"
autocmd BufEnter *.hs,*.lhs nmap gfw <C-W><C-F><cr>
" compile erlang files
autocmd BufRead,BufNewFile *.erl nmap <Leader>C :!erlc %<cr>
" save/retrieve folds automatically
au BufWinLeave * silent! mkview
au BufWinEnter * silent! loadview
" ,T perl tests
"nmap <Leader>T :let g:testfile = expand("%")<cr>:echo "testfile is now" g:testfile<cr>:call Prove (1,1)<cr>
function! Prove ( verbose, taint )
if ! exists("g:testfile")
let g:testfile = "t/*.t"
endif
if g:testfile == "t/*.t" || g:testfile =~ "\.t$"
let s:params = "lrc"
if a:verbose
let s:params = s:params . "v"
endif
" if a:taint
" let s:params = s:params . "t"
" endif
"execute !HARNESS_PERL_SWITCHES=-MDevel::Cover prove -" . s:params . " " . g:testfile
execute "!prove --timer --normalize --state=save -" . s:params . " " . g:testfile
"TEST_VERBOSE=1 prove -lvc --timer --normalize --state=save
else
call Compile ()
endif
endfunction
function! Compile ()
if ! exists("g:compilefile")
let g:compilefile = expand("%")
endif
execute "!perl -wc -Ilib " . g:compilefile
endfunction
autocmd BufRead,BufNewFile *.t,*.pl,*.plx,*.pm nmap <Leader>te :let g:testfile = expand("%")<cr>:echo "testfile is now" g:testfile<cr>:call Prove (1,1)<cr>
" markdown
augroup mkd
autocmd BufRead *.mkd set ai formatoptions=tcroqn2 comments=n:>
augroup END
" open installed perl modules
au FileType perl command! -nargs=1 PerlModuleSource :tabnew `perldoc -lm <args>`
au FileType perl setlocal iskeyword+=:
au FileType perl noremap <leader>P :PerlModuleSource <cword><cr>zR<cr>
" perltidy
au FileType perl command! -range=% -nargs=* Tidy <line1>,<line2>!perltidy
au FileType perl nmap <Leader>pt mz:Tidy<cr>'z:delmarks z<cr> " normal mode
au FileType perl vmap <Leader>pt :Tidy<cr> " visual mode
" json tidy
au FileType json set filetype=javascript foldmethod=syntax
au FileType json command! -range=% -nargs=* Tidy <line1>,<line2>!json_xs -f json -t json-pretty
au FileType json nmap <Leader>pt :Tidy<cr> " normal mode
au FileType json vmap <Leader>pt :Tidy<cr> " visual mode
" xmlfolding
"au BufNewFile,BufRead *.xml,*.htm,*.html so bundle/plugin/XMLFolding.vim
" ack shortcut
let g:ackprg="ack-grep -H --nocolor --nogroup --column"
" Show syntax highlighting groups for word under cursor
nmap <C-S-P> :call <SID>SynStack()<CR>
function! <SID>SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfunc
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
" Automagic tabularize
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
function! StatuslineTabWarning()
if !exists("b:statusline_tab_warning")
let tabs = search('^\t', 'nw') != 0
let spaces = search('^ ', 'nw') != 0
if tabs && spaces
let b:statusline_tab_warning = '[mixed-indenting]'
elseif (spaces && !&et) || (tabs && &et)
let b:statusline_tab_warning = '[&et]'
else
let b:statusline_tab_warning = ''
endif
endif
return b:statusline_tab_warning
endfunction
" return the syntax highlight group under the cursor ''
function! StatuslineCurrentHighlight()
let name = synIDattr(synID(line('.'),col('.'),1),'name')
if name == ''
return ''
else
return '[' . name . ']'
endif
endfunction
function! ScreencastPrep()
" disable blinking cursor
set guicursor+=n:hor10-blinkon0
" disable autocomplete
AcpDisable
" disable colorcolumn
set colorcolumn=0
"set guifont=Menlo:h14
set guifont=Monaco:h14
set ts=2
set sw=2
NoMatchParen "opposite: DoMatchParen
endfunction
function! ScreencastPrep1080()
" disable blinking cursor
set guicursor+=n:hor10-blinkon0
" disable autocomplete
AcpDisable
" disable colorcolumn
set colorcolumn=0
"set guifont=Menlo:h20
"set guifont=Monaco:h26
set guifont=Consolas:h29
set ts=2
set sw=2
NoMatchParen "opposite: DoMatchParen
endfunction