This repository was archived by the owner on Mar 17, 2025. It is now read-only.
forked from trq/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
491 lines (428 loc) · 14 KB
/
vimrc
File metadata and controls
491 lines (428 loc) · 14 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
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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
Bundle 'arnaud-lb/vim-php-namespace'
Bundle 'beberlei/vim-php-refactor'
Bundle 'benmills/vimux'
Bundle 'bling/vim-airline'
Bundle 'bling/vim-bufferline'
Bundle 'christoomey/vim-tmux-navigator'
Bundle 'coderifous/textobj-word-column.vim'
Bundle 'docteurklein/vim-symfony'
Bundle 'edkolev/tmuxline.vim'
Bundle 'gmarik/vundle'
Bundle 'godlygeek/tabular'
Bundle 'gregsexton/gitv'
Bundle 'groenewege/vim-less'
Bundle 'joonty/vdebug.git'
Bundle 'justinmk/vim-sneak'
Bundle 'kien/ctrlp.vim'
Bundle 'majutsushi/tagbar'
Bundle 'mattn/emmet-vim'
Bundle 'mhinz/vim-signify'
Bundle 'msanders/snipmate.vim'
Bundle 'rking/ag.vim'
Bundle 'rodjek/vim-puppet'
Bundle 'scrooloose/nerdtree'
Bundle 'scrooloose/syntastic'
Bundle 'sjl/clam.vim'
Bundle 'sjl/gundo.vim'
Bundle 'tacahiroy/ctrlp-funky'
Bundle 'terryma/vim-multiple-cursors'
Bundle 'tpope/vim-abolish'
Bundle 'tpope/vim-commentary'
Bundle 'tpope/vim-eunuch'
Bundle 'tpope/vim-fugitive'
Bundle 'tpope/vim-markdown'
Bundle 'tpope/vim-obsession'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-unimpaired'
Bundle 'troydm/pb.vim'
Bundle 'Valloric/YouCompleteMe'
Bundle 'vim-scripts/bufexplorer.zip'
Bundle 'vim-scripts/L9'
set cindent
set smartindent
set autoindent
set expandtab
set lazyredraw
set tabstop=2
set shiftwidth=2
set cinkeys=0{,0},:,0#,!^F
"set showcmd
set relativenumber
set numberwidth=3
set shiftwidth=4
set tabstop=4
set softtabstop=4
set smarttab
set encoding=utf-8 nobomb " BOM often causes trouble
set history=1000
set showmatch
set nohlsearch
set nowrap
set whichwrap=b,s,<,>,[,],~
set hlsearch
set incsearch
set shortmess=I
set laststatus=2
set foldmethod=marker
set number
set nocompatible
set nottybuiltin term=$TERM
set formatprg=par-format\ -w80
set wmh=0
set term=xterm-256color
"set statusline=%F%m%r%h%w\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
set hidden
set backspace=indent,eol,start
set whichwrap+=<,>,[,]
set noswapfile
set nobk
set grepprg=ack\ --nogroup\ --column\ $*
set grepformat=%f:%l:%c:%m
set scrolloff=40
set sidescrolloff=40
set splitbelow " New window goes below
set splitright " New windows goes right
set suffixes=.bak,~,.swp,.swo,.o,.d,.info,.aux,.log,.dvi,.pdf,.bin,.bbl,.blg,.brf,.cb,.dmg,.exe,.ind,.idx,.ilg,.inx,.out,.toc,.pyc,.pyd,.dll
set ttimeoutlen=20
set noshowmode
set fillchars+=stl:\ ,stlnc:\
set encoding=utf-8
set tags+=tags,vendor.tags
" highlight conflict markers
match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$'
" shortcut to jump to next conflict marker
nnoremap <silent> <leader>c /^\(<\\|=\\|>\)\{7\}\([^=].\+\)\?$<CR>
" mouse :(
set ttyfast
set mouse=a
set ttymouse=xterm2
" appearance
syntax on
syntax enable
set background=dark
set t_Co=256 " 256 colors in terminal
set cursorline
colorscheme molokai_custom
" powerline
let g:airline_powerline_fonts = 1
let g:airline_theme = 'powerlineish'
let g:airline_enable_branch = 1
let g:bufferline_echo = 0
let g:airline_enable_syntastic = 1
let g:airline_left_sep = '⮀'
let g:airline_left_alt_sep = '⮁'
let g:airline_right_sep = '⮂'
let g:airline_right_alt_sep = '⮃'
let g:airline_symbols = {}
let g:airline_symbols.branch = '⭠'
let g:airline_symbols.readonly = '⭤'
let g:airline_symbols.linenr = '⭡'
let g:airline#extensions#bufferline#enabled = 0
let g:airline#extensions#ctrlp#color_template = 'normal'
let g:airline#extensions#tmuxline#enabled = 0
" Yggdroot/indentLine
"set list lcs=tab:\|\
"let g:indentLine_color_term=234
"let g:indentLine_char = '┆'
" Sort paragraphs
vnoremap <leader>s !sort -f<CR>gv
nnoremap <leader>s vip!sort -f<CR><Esc>
"Buffer line
let g:bufferline_echo = 0
" Nerdtree
nnoremap <leader>- :NERDTreeToggle<CR>
" Tagbar
nnoremap <silent> <leader>= :TagbarToggle<cr>
let g:tagbar_autofocus = 1
let g:tagbar_left = 1
let g:tagbar_compact = 1
let g:tagbar_indent = 1
" Highlight whitespace.
highlight ExtraWhitespace ctermbg=96
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()
" 'php', 'phpcs', 'phpmd'
let g:syntastic_php_checkers=['php']
"ctrlp
let g:ctrlp_user_command = 'ag %s -l --nocolor --ignore app/cache --ignore vendor -g ""'
let g:ctrlp_switch_buffer = 'Et'
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:20,results:20'
let g:ctrlp_extensions = ['funky']
nnoremap <silent> <leader>b :CtrlPBuffer<cr>
nnoremap <silent> <leader>t :CtrlPTag<cr>
nnoremap <silent> <leader>q :CtrlPQuickfix<cr>
nnoremap <silent> <leader>f :CtrlPFunky<cr>
nnoremap <silent> <leader>l :CtrlPMRUFiles<cr>
" Vdebug
let g:vdebug_keymap = {
\ "run" : "<Leader>/",
\ "run_to_cursor" : "<Down>",
\ "step_over" : "<Up>",
\ "step_into" : "<Left>",
\ "step_out" : "<Right>",
\ "close" : "q",
\ "detach" : "x",
\ "set_breakpoint" : "<Leader>p",
\ "get_context" : "<F11>",
\ "eval_under_cursor" : "<F12>",
\ "eval_visual" : "<Leader>e"
\}
let g:vdebug_options = {
\ "port" : 9000,
\ "timeout" : 20,
\ "server" : 'localhost',
\ "on_close" : 'detach',
\ "break_on_open" : 0,
\ "ide_key" : '',
\ "debug_window_level" : 0,
\ "debug_file_level" : 0,
\ "debug_file" : "",
\ "path_maps" : {},
\ "watch_window_style" : 'expanded',
\ "marker_default" : '⬦',
\ "marker_closed_tree" : '▸',
\ "marker_open_tree" : '▾',
\ "continuous_mode" : 1
\}
" Wildmenu
if has("wildmenu")
set wildignore+=*.a,*.o,*.tbz,*.selfbk
set wildignore+=*.bmp,*.gif,*.ico,*.jpg,*.png
set wildignore+=.DS_Store,.git,.hg,.svn
set wildignore+=*~,*.swp,*.tmp
set wildignore+=*/app/cache/*
set wildmenu
set wildmode=longest,list
endif
" Disable arrow keys entirely.
noremap <Up> <nop>
noremap <Down> <nop>
noremap <Left> <nop>
noremap <Right> <nop>
" Custom mappings
nnoremap <silent> <leader>my :!mysql -t %:r:r < %<cr>
vnoremap <silent> <leader>my :My<cr>
nnoremap <silent> <leader>v :vsplit $MYVIMRC<cr>
nnoremap <silent> <leader>; :BufExplorer<cr>
nnoremap <silent> <leader>g :GundoToggle<cr>
nnoremap <silent> <leader>1 :Tabularize /=<cr>
nnoremap <silent> <leader>2 :Tabularize /=><cr>
vnoremap <silent> <leader>1 :Tabularize /=<cr>
vnoremap <silent> <leader>2 :Tabularize /=><cr>
inoremap jk <esc>
" https://github.com/arnaud-lb/vim-php-namespace
inoremap <Leader>u <c-o>:call PhpInsertUse()<cr>
noremap <Leader>u :call PhpInsertUse()<cr>
inoremap <Leader>q <c-o>:call PhpExpandClass()<cr>
noremap <Leader>q :call PhpExpandClass()<cr>
" sudo write
noremap <leader>W :w !sudo tee %<CR>
" see http://vimcasts.org/episodes/the-edit-command
cnoremap %% <C-R>=expand('%:h').'/'<cr>
map <leader>ew :e %%
map <leader>es :sp %%
map <leader>ev :vsp %%
" lookup a php function interface
function! PHPMan(func)
execute ':!php --rf ' . a:func
endfunction
command! -nargs=1 Pm :call PHPMan("<args>")
" Attempt at a symfony console
function! SymfonyConsole(...)
if a:0 > 0
execute ':!./app/console ' . a:1
else
execute ':!./app/console'
endif
endfunction
command! Symfony :call SymfonyConsole("<args>")
function! MySQL() range
echo system("mysql -t " . expand('%:r:r') . " -e " . shellescape(join(getline(a:firstline, a:lastline), "\n")))
endfunction
command! -range=% -nargs=0 My :<line1>,<line2>call MySQL()
" ack
let g:ackprg="ack-grep -H --nocolor --nogroup --column"
" save a hostname variable.
" let hostname = substitute(system('hostname'), '\n', '', '')
filetype plugin on
syntax on
setlocal spelllang=en_au
" Uncomment the following to have Vim jump to the last position when
" reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
if has("autocmd")
filetype plugin indent on
endif
" Remove fugitive buffers as they are closed.
autocmd BufReadPost fugitive://* set bufhidden=delete
" Switch from block-cursor to vertical-line-cursor when going into/out of
" insert mode
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
augroup chmodandshebang
autocmd!
autocmd BufWritePost ~/bin/*,*.sh,*.pl,*.rb,*.py :exe "silent !chmod 700 <afile>" | silent :w!
autocmd BufEnter *.sh if getline(1) == "" | :call setline(1, "#!/usr/bin/env bash") | endif
autocmd BufEnter *.pl if getline(1) == "" | :call setline(1, "#!/usr/bin/env perl") | endif
autocmd BufEnter *.pb if getline(1) == "" | :call setline(1, "#!/usr/bin/env ruby") | endif
autocmd BufEnter *.py if getline(1) == "" | :call setline(1, "#!/usr/bin/env python") | endif
augroup END
" Turn on spell checking when writting a GIT commit.
autocmd FileType gitcommit set spell
" Common Indentation.
if has("autocmd")
" Enable file type detection
filetype on
" auto source .vimrc on write
"au BufWritePost .vimrc source $MYVIMRC
au BufRead,BufNewFile *.json setfiletype=json syntax=javascript
au BufRead,BufNewFile *.less setfiletype=css syntax=css
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType html setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType javascript setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType python setlocal ts=4 sts=4 sw=4 expandtab
autocmd FileType ruby setlocal ts=4 sts=4 sw=4 expandtab
autocmd FileType bash setlocal ts=4 sts=4 sw=4 expandtab
au BufRead,BufNewFile *.opm setfiletype sh
au BufRead,BufNewFile *.opm setlocal ts=4 sts=4 sw=4 expandtab
endif
" Conditional based on location.
"
" My computers / servers.
if hostname() == 'dev'
" proem
autocmd BufEnter $HOME/src/proem/lib/Proem/*.php 0r $HOME/.vim-templates/proem.class.php
autocmd BufEnter $HOME/src/proem/tests/Proem/*.php 0r $HOME/.vim-templates/proem.test.php
endif
au BufRead,BufNewFile Vagrantfile let is_ruby=1|setfiletype ruby
au BufRead,BufNewFile Phakefile let is_php=1|setfiletype php
au BufRead,BufNewFile *.twig set filetype=htmljinja
" Set the minimal split width
set winwidth=24
set winminwidth=24
function! SplitToggle()
if(&winwidth == &winminwidth)
set winwidth=999
else
set winwidth=24
wincmd =
endif
endfunc
"nnoremap <leader>- :call SplitToggle()<cr>
" Toggle the quickfix window
" From Steve Losh, http://learnvimscriptthehardway.stevelosh.com/chapters/38.html
nnoremap <C-q> :call <SID>QuickfixToggle()<cr>
let g:quickfix_is_open = 0
function! s:QuickfixToggle()
if g:quickfix_is_open
cclose
let g:quickfix_is_open = 0
execute g:quickfix_return_to_window . "wincmd w"
else
let g:quickfix_return_to_window = winnr()
copen
let g:quickfix_is_open = 1
endif
endfunction
" templates.
" autocmd BufEnter $HOME/bin/*.php 0r $HOME/.vim/templates/a.txt
" autocmd BufNewFile *.sh 0r $HOME/.vim/templates/b.txt
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" PHP Stuff.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
:autocmd Filetype php call Filetype_Php()
function! Filetype_Php()
" PHP parser check (CTRL-L)
nmap <Leader>pl :!/usr/bin/php -l %<CR>
set keywordprg=pman
"If you like SQL syntax hightlighting inside Strings: >
let php_sql_query = 1
""Enable HTML syntax highlighting inside strings: >
let php_htmlInStrings = 1
"For highlighting parent error ] or ): >
let php_parent_error_close = 1
setlocal ts=4 sts=4 sw=4 expandtab
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"end PHP Stuff
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""s
" Strip trailing white space.
function! StripTrailingWhitespaces()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%s/\s\+$//e
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
" call the above function automatically when saving files of certain type.
autocmd BufWritePre *.py,*.js,*.php,*.gpx,*.rb,*.tpl :call StripTrailingWhitespaces()
" php code sniffer via :Rhpcs
function! RunPhpcs()
let l:filename=@%
let l:phpcs_output=system('phpcs --report=csv --standard=Zend '.l:filename)
let l:phpcs_list=split(l:phpcs_output, "\n")
unlet l:phpcs_list[0]
cexpr l:phpcs_list
cwindow
endfunction
set errorformat+=\"%f\"\\,%l\\,%c\\,%t%*[a-zA-Z]\\,\"%m\"
command! Rhpcs execute RunPhpcs()
" Use <Leader>ee to execute a command under the cursor within a file.
function! EC()
let l:Command = getline(".")
execute "!" . l:Command
endfunction
command! Ec execute EC()
nmap <Leader>x :Ec<CR>
function! BufSel(pattern)
let bufcount = bufnr("$")
let currbufnr = 1
let nummatches = 0
let firstmatchingbufnr = 0
while currbufnr <= bufcount
if(bufexists(currbufnr))
let currbufname = bufname(currbufnr)
if(match(currbufname, a:pattern) > -1)
echo currbufnr . ": ". bufname(currbufnr)
let nummatches += 1
let firstmatchingbufnr = currbufnr
endif
endif
let currbufnr = currbufnr + 1
endwhile
if(nummatches == 1)
execute ":buffer ". firstmatchingbufnr
elseif(nummatches > 1)
let desiredbufnr = input("Enter buffer number: ")
if(strlen(desiredbufnr) != 0)
execute ":buffer ". desiredbufnr
endif
else
echo "No matching buffers"
endif
endfunction
"Bind the BufSel() function to a user-command
command! -nargs=1 Bs :call BufSel("<args>")
function! QuickfixFilenames()
" Building a hash ensures we get each buffer only once
let buffer_numbers = {}
for quickfix_item in getqflist()
let buffer_numbers[quickfix_item['bufnr']] = bufname(quickfix_item['bufnr'])
endfor
return join(map(values(buffer_numbers), 'fnameescape(v:val)'))
endfunction
" command! -nargs=0 -bar Qargs execute 'args' QuickfixFilenames()