-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
252 lines (201 loc) · 7.71 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
" Vundle
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" Let Vundle manage Vundle (required)!
Bundle 'gmarik/vundle'
Bundle 'junegunn/fzf'
Bundle 'scrooloose/syntastic'
Bundle 'SirVer/ultisnips'
Bundle 'honza/vim-snippets'
Bundle 'tpope/vim-fugitive'
Bundle 'elzr/vim-json'
Bundle 'tpope/vim-fireplace'
Bundle 'luochen1990/rainbow'
Bundle 'nulpunkt/php-getter-setter.vim'
" The usual suspects
syntax on
filetype plugin on
set nocompatible
set number
set smartindent
set tabstop=4
set shiftwidth=4
set softtabstop=4
set ruler
set formatoptions=tcqlron
"set fileencodings=utf-8,latin2
set so=999
set showcmd
set ignorecase
set smartcase
set nohidden
set showmatch
set autoread
set suffixes=.bak,~,.o,.h,.info,.swp,.class
set dir=/tmp/
set hlsearch
set clipboard=unnamed
" Dat pesky wait between <esc>O and insert..
set timeout timeoutlen=1000 ttimeoutlen=100
set wildmenu
let mapleader=" "
" Cool search plugin
nnoremap <C-p> :FZF<cr>
" Ultisnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
let g:syntastic_php_checkers=['php']
let g:syntastic_javascript_checkers = ['jshint']
let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_cpp_compiler_options = ' -std=c++11'
" let g:syntastic_python_checkers=[]
" let g:syntastic_disabled_filetypes=['py', 'python']
let g:ctrlp_max_depth = 40
let g:ctrlp_max_files = 0
let g:rainbow_active = 1
let g:vim_json_syntax_conceal = 0
colorscheme jellybeans
set completeopt-=preview
au FileType php map <C-c> :w<CR>:!/usr/bin/php -l %<CR>
au FileType php set omnifunc=phpcomplete#CompletePHP
au FileType php nnoremap <leader>o :call RunPhpTest()<cr>
au FileType php nnoremap K :!pman <cword><cr>
au FileType php setlocal expandtab
autocmd BufWritePost *.php silent! !command -v php-cs-fixer > /dev/null && php-cs-fixer fix --rules @PSR12 -q %
au BufWritePre *.php,*.rb,*.py,*.clj,*.json,*.sql,*.yml,*.js,*.jsx,*.css,*.md,*.cpp,*.h :%s/\s\+$//e
au BufNewFile,BufRead *.tsx set filetype=typescript
au FileType javascript nnoremap <leader>o :call RunJsTest()<cr>
au FileType python nnoremap <leader>o :call RunPythonTest()<cr>
au FileType python setlocal noexpandtab
au FileType clojure nnoremap <leader>o :call RunClojureTest()<cr>
au FileType clojure setlocal expandtab | setlocal ts=2 | setlocal sts=2 | setlocal sw=2
au Filetype html setlocal expandtab | setlocal ts=2 | setlocal sts=2 | setlocal sw=2
au Filetype css setlocal expandtab | setlocal ts=2 | setlocal sts=2 | setlocal sw=2
au Filetype markdown setlocal ts=2 | setlocal sts=2 | setlocal sw=2 | setlocal tw=79
au Filetype text setlocal ts=2 | setlocal sts=2 | setlocal sw=2 | setlocal tw=79 | setlocal expandtab
au FileType ruby set omnifunc=rubycomplete#Complete
au Filetype ruby setlocal expandtab | setlocal ts=2 | setlocal sts=2 | setlocal sw=2
au FileType ruby nnoremap <leader>o :call RunRubyTest()<cr>
au Filetype cucumber setlocal expandtab | setlocal ts=2 | setlocal sts=2 | setlocal sw=2
au Filetype json setlocal expandtab | setlocal ts=2 | setlocal sts=2 | setlocal sw=2
au Filetype yaml setlocal expandtab | setlocal ts=2 | setlocal sts=2 | setlocal sw=2
au FileType c nnoremap <leader>o :!clang -lm -Wall % && ./a.out && rm a.out<cr>
au Filetype javascript setlocal expandtab | setlocal ts=2 | setlocal sts=2 | setlocal sw=2
au Filetype typescript setlocal expandtab | setlocal ts=2 | setlocal sts=2 | setlocal sw=2
au BufNewFile,BufRead COMMIT_EDITMSG setlocal spell
" Stuff for finding test files
nnoremap <Leader>bu :vs <C-R>=substitute(substitute(expand("%:p"), "backend", "backend\/test/unit", ""), "\.php", "Test.php", "")<CR> <CR>
nnoremap <Leader>au :vs <C-R>=substitute(substitute(expand("%:p"), "api", "api\/test/unit", ""), "\.php", "Test.php", "")<CR> <CR>
nnoremap <Leader>ai :vs <C-R>=substitute(substitute(expand("%:p"), "\/api", "\/api\/test/integration", ""), "\.php", "Test.php", "")<CR> <CR>
nnoremap <Leader>ad :vs <C-R>=substitute(substitute(expand("%:p"), "\/api", "\/api\/test/database", ""), "\.php", "Test.php", "")<CR> <CR>
nnoremap <Leader>cu :vs <C-R>=substitute(substitute(expand("%:p"), "\/colourbox", "\/colourbox\/tests/unit", ""), "\.php", "Test.php", "")<CR> <CR>
nnoremap <Leader>ci :vs <C-R>=substitute(substitute(expand("%:p"), "\/colourbox", "\/colourbox\/tests/integration", ""), "\.php", "Test.php", "")<CR> <CR>
nnoremap <Leader>cd :vs <C-R>=substitute(substitute(expand("%:p"), "\/colourbox", "\/colourbox\/tests/database", ""), "\.php", "Test.php", "")<CR> <CR>
nnoremap Q <nop>
" Make the directory the current file should reside in
nnoremap <Leader>m :!mkdir -p %:h<CR><CR>
" fix tmux's retarded \015 instead of line break
nnoremap <Leader>f :s/\\015/\r/g<CR>
" fix log files that are on one line
nnoremap <Leader>l :%s/#/\r#/g<CR>:%s/\\n//g<CR>
" Copy the contents of the current file into copy buffer
nnoremap <leader>cc :!cat % \| xclip -selection clipboard <cr><cr>
" Open files in a new tab
noremap gf <c-w>gF
set pastetoggle=<F11>
" Parenthesis are a pain
inoremap é (
inoremap ï )
inoremap ½ $
" Easy window navigation
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" Easy new tab
nnoremap <Leader>t :tabnew<CR>
" Easy blame
nnoremap <Leader>b :G blame -w<CR>
" Easy date
iab <expr> dts strftime("%F %T")
" Easy window resize
nnoremap L <C-w><
nnoremap H <C-w>>
" Ctags, open in new tab
nnoremap <C-]> <C-w><C-]><C-w>T
" File in the current directory
nnoremap <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
" Remove unessesary whitespace from lines of assignment
nnoremap <leader>w :'<,'>s/\s\+=/ =/<cr>
" Transpose params
nnoremap <Leader>sp :normal F(ldt,f)i, pF(lxx
" Set spell
nnoremap <Leader>se :silent! set spell spelllang=en<CR>
" More natural moving on long, wraped lines
nnoremap k gk
nnoremap j gj
nnoremap <Enter> :nohlsearch<CR><Enter>
vmap gl :<C-U>!git blame <C-R>=expand("%:p") <CR> \| sed -n <C-R>=line("'<") <CR>,<C-R>=line("'>") <CR>p <CR>
nnoremap <leader>gp :Ggrepphp
command! -nargs=* Ggrepphp call MyGGrep('<args>', "'*.php' '*.phtml'")
command! PhpscStyleFix :!patch -p0 -ui <(./vendor/bin/phpcs --report=diff --standard=PSR12 --extensions=php %)
fun! MyGGrep(p, ft)
exec ':r!git grep -in "' . a:p . '" -- ' . a:ft
endfunction
fun! RunPhpTest()
let current_name = expand('%')
if match(current_name, 'Test.php$') != -1
let s:phptestfile = current_name
endif
if exists("s:phptestfile")
exec ':!phpunit '.s:phptestfile
else
echo "No php test file set yet"
endif
endfunction
fun! RunJsTest()
let current_name = expand('%')
if match(current_name, 'test.js$') != -1
let s:jstestfile = current_name
endif
if exists("s:jstestfile")
exec ':!npm test '.s:jstestfile
else
echo "No js test file set yet"
endif
endfunction
fun! RunRubyTest()
let current_name = expand('%')
if match(current_name, '_test.rb$') != -1
let s:rbtestfile = current_name
endif
if exists("s:rbtestfile")
exec ':!ruby '.s:rbtestfile
else
echo "No ruby test file set yet"
endif
endfunction
fun! RunPythonTest()
let current_name = expand('%')
if match(current_name, '_test.py$') != -1
let s:pytestfile = current_name
endif
if exists("s:pytestfile")
exec ':!pyrg '.s:pytestfile
else
echo "No python test file set yet"
endif
endfunction
fun! RunClojureTest()
let current_name = expand('%')
if match(current_name, '_test.clj$') != -1
let s:cljtestns = substitute(substitute(substitute(substitute(current_name, ".\/test\/", "", ""), ".clj", "", ""), '\/', '.', ''), "_", '-', '')
endif
if exists("s:cljtestns")
exec ':silent %Eval'
exec ':RunTests '.s:cljtestns
else
echo "No clojure test namespace set yet"
endif
endfunction