-
Notifications
You must be signed in to change notification settings - Fork 1
/
vimrc
328 lines (290 loc) · 10.5 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
" ----------------------------------------------------------------------------
" Initial stuff
" ----------------------------------------------------------------------------
set nocompatible
filetype off
set encoding=utf-8
" ----------------------------------------------------------------------------
" Plugins
" ----------------------------------------------------------------------------
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle
call vundle#begin()
Plugin 'VundleVim/vundle'
Plugin 'noah/molokai'
Plugin 'bling/vim-airline'
Plugin 'bronson/vim-trailing-whitespace'
Plugin 'scrooloose/nerdtree'
Plugin 'joonty/vdebug'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-repeat'
Plugin 'mileszs/ack.vim'
Plugin 'tpope/vim-commentary'
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'easymotion/vim-easymotion'
Plugin 'svermeulen/vim-easyclip'
Plugin 'ervandew/supertab'
Plugin 'shawncplus/phpcomplete.vim'
Plugin 'joonty/vim-phpqa.git'
Plugin 'junegunn/fzf'
Plugin 'junegunn/fzf.vim'
Plugin 'morhetz/gruvbox'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'tpope/vim-dispatch'
Plugin 'tpope/vim-fugitive'
Plugin 'int3/vim-extradite'
Plugin 'stephpy/vim-php-cs-fixer'
Plugin 'junegunn/vim-easy-align'
call vundle#end()
filetype plugin indent on
Bundle 'tobyS/vmustache'
Bundle 'tobyS/pdv'
" ----------------------------------------------------------------------------
" Basic stuff
" ----------------------------------------------------------------------------
" Disable ex mode
map q: <Nop>
map Q <Nop>
" security
set modelines=0
" this allows buffers to be hidden if you've modified a buffer.
set hidden
" display line numbers
:set nu
" make them relative
set relativenumber
" allow per project vimrc
set exrc
set secure
" highlight column 80
set colorcolumn=80
set nowrap
" copy indent from previous line
set autoindent
" do smart indenting when starting a new line
set smartindent
au FocusLost * :wa
set undodir=~/tmp/vim/undo//
set backupdir=~/tmp/vim/backup//
set directory=~/tmp/vim/swap//
set backup
set noswapfile
:set expandtab ts=2 sw=2 ai
autocmd BufWritePre * :%s/\s\+$//e
" for php files 4 spaces
autocmd Filetype php setlocal ts=4 sw=4 sts=0 expandtab
" for xml files 4 spaces
autocmd Filetype xml setlocal ts=4 sw=4 sts=0 expandtab
" for ruby files 2 spaces
autocmd Filetype rb setlocal ts=2 sw=2 sts=0 expandtab
" autogenerate tag file when saving
" au BufWritePost *.php silent! !ctags -R --fields=+aimS --languages=php --exclude=var --exclude=pub &
" styling
colorscheme gruvbox
set background=dark
" ----------------------------------------------------------------------------
" Key Bindings
" ----------------------------------------------------------------------------
" use space as leader key
let mapleader=" "
" map jj to esc
imap jj <Esc>
" map F1 to ESC
inoremap <F1> <ESC>
nnoremap <F1> <ESC>
vnoremap <F1> <ESC>
" goto definition with leader; <Space>+g
nmap <leader>g g<c-]>
" Goto Defintion switch default; open first match automatically if there is
" only one
" http://stackoverflow.com/questions/7640663/use-tjump-instead-of-tag-vim-on-pressing-ctrl
" nnoremap <c-]> g<c-]>
" vnoremap <c-]> g<c-]>
" nnoremap g<c-]> <c-]>
" vnoremap g<c-]> <c-]>
" FZF as CTRL-P replacement: so used to Ctrl+P, so open FZF instead
nmap <C-p> :FZF<CR>
" ----------------------------------------------------------------------------
" Searching
" ----------------------------------------------------------------------------
set hlsearch "Highlight matches
set incsearch "Incremental searching
set showmatch
set ignorecase "ignore case when searching
set smartcase "search with case possible
set gdefault " :%s/foo/bar/g -> :%s/foo/bar/
" leader + space to clear search
nnoremap <leader><space> :noh<cr>
" ----------------------------------------------------------------------------
" Buffer Management
" ----------------------------------------------------------------------------
" open a new empty buffer with Ctrl+t
nmap <C-t> :enew<cr>
" move to the next buffer with Tab
map <C-i> :bnext<CR>
" move to the previous buffer with Shift+Tab
map <S-Tab> :bprevious<CR>
" close current buffer with CTRL+x
nmap <C-x> :bp <BAR> bd #<CR>
" Move to previous edited buffer
map <C-z> :e#<CR>
" ----------------------------------------------------------------------------
" Split Pane Management
" ----------------------------------------------------------------------------
" close current split pane with ALT+q
execute "set <M-q>=\eq"
map <M-q> :q<CR>
" map crtl-movement key for navigation
map <C-k> <C-w><Up>
map <C-j> <C-w><Down>
map <C-l> <C-w><Right>
map <C-h> <C-w><Left>
" Use Arrow Keyz to resize window
noremap <up> <C-W>+
noremap <down> <C-W>-
noremap <left> 3<C-W><
noremap <right> 3<C-W>>
" ----------------------------------------------------------------------------
" Airline Config
" ----------------------------------------------------------------------------
" Enable the list of buffers
let g:airline#extensions#tabline#enabled = 1
" Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'
" ----------------------------------------------------------------------------
" NerdTree Config
" ----------------------------------------------------------------------------
" NerdTree Toggle
nmap <silent> <leader><tab> :NERDTreeToggle<CR>
" highlight current buffer in NERDTREE
map <leader>r :NERDTreeFind<CR>
" trigger save with CTRL+s
nmap <c-s> :w<CR>
vmap <c-s> <Esc><c-s>gv
imap <c-s> <Esc><c-s>
" save and exit shortcut with CTRL+e
nmap <c-e> :wq!<CR>
vmap <c-e> <Esc>:wq!<CR>
imap <c-e> <Esc>:wq!<CR>
" ----------------------------------------------------------------------------
" SnipMate Config
" ----------------------------------------------------------------------------
let g:snipMate = {}
let g:snipMate.scope_aliases = {}
let g:snipMate.scope_aliases['php'] = 'php'
let g:snips_author='Bernhard Leers'
let g:author='Bernhard Leers'
let g:snips_email='[email protected]'
let g:email='[email protected]'
let g:snips_github='https://github.com/bka'
let g:github='https://github.com/bka'
" trigger SnipMate, it also gets trigger on <tab> because of supertab
imap <C-k> <esc>a<Plug>snipMateNextOrTrigger
smap <C-k> <Plug>snipMateNextOrTrigger
" ----------------------------------------------------------------------------
" Easy Motion Config
" ----------------------------------------------------------------------------
let g:EasyMotion_do_mapping = 0 " Disable default mappings
nmap s <Plug>(easymotion-s)
" ----------------------------------------------------------------------------
" easyclip config
" ----------------------------------------------------------------------------
set clipboard=unnamedplus
let g:EasyClipAlwaysMoveCursorToEndOfPaste = 1
" let g:EasyClipShareYanks = 1
let g:EasyClipUsePasteToggleDefaults = 0
nmap <c-f> <plug>EasyClipRotateYanksForward
nmap <c-d> <plug>EasyClipRotateYanksBackward
nmap <silent> gs <plug>SubstituteOverMotionMap
nmap gss <plug>SubstituteLine
xmap gs <plug>XEasyClipPaste
nnoremap gm m
" ----------------------------------------------------------------------------
" PDV config
" ----------------------------------------------------------------------------
let g:pdv_template_dir = $HOME ."/.vim/bundle/pdv/templates"
nmap <leader>c :call pdv#DocumentCurrentLine()<CR>
" ----------------------------------------------------------------------------
" vdebug config
" ----------------------------------------------------------------------------
let g:vdebug_keymap = {
\ "run" : "<F5>",
\ "run_to_cursor" : "<F9>",
\ "step_over" : "<F2>",
\ "step_into" : "<F3>",
\ "step_out" : "<F4>",
\ "close" : "<F6>",
\ "detach" : "<F7>",
\ "set_breakpoint" : "<F8>",
\ "get_context" : "<F11>",
\ "eval_under_cursor" : "<F12>",
\ "eval_visual" : "<Leader>e"
\}
let g:vdebug_options = {
\ "break_on_open" : 0,
\ "path_maps" : {
\ },
\ "watch_window_style" : "compact",
\ "debug_file" : "~/vdebug.log",
\ "debug_file_level" : "2",
\ "timeout" : 300,
\ "continuous_mode" : 1
\}
" ----------------------------------------------------------------------------
" phpcomplete config
" ----------------------------------------------------------------------------
autocmd FileType php setlocal omnifunc=phpcomplete#CompletePHP
" don't auto-insert first item, show menu even with only one entry
set completeopt=longest,menuone
" ----------------------------------------------------------------------------
" SuperTab Config
" ----------------------------------------------------------------------------
" navigate completion menu from top to bottom
let g:SuperTabDefaultCompletionType = "<c-x><c-o>"
" ----------------------------------------------------------------------------
" Ultisnip Config
" ----------------------------------------------------------------------------
" Trigger configuration. Do not use <tab> if you use
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
" ----------------------------------------------------------------------------
" phpqa config
" ----------------------------------------------------------------------------
" https://github.com/joonty/vim-phpqa
" <Leader>qa " Show/hide code sniffer and mess detector violations
" <Leader>qc " Show/hide code coverage markers
let g:phpqa_codesniffer_args = "--standard=PSR2"
let g:phpqa_messdetector_ruleset = "~/.vim/php/phpmd-ruleset.xml"
" ----------------------------------------------------------------------------
" Vim-php-cs-fixer
" https://github.com/stephpy/vim-php-cs-fixer
" ----------------------------------------------------------------------------
let g:php_cs_fixer_level = "psr2" " which level ?
let g:php_cs_fixer_fixers_list = "unused_use" " fixers
" <Leader>1 for fixing current file
nnoremap <silent><leader>1 :call PhpCsFixerFixFile()<CR><CR>
" ----------------------------------------------------------------------------
" ack config
" ----------------------------------------------------------------------------
" spawn in background, thanks to vim.dispatch
let g:ack_use_dispatch = 1
" space+f start project search
nmap <leader>f :Ack <space>
" find word under cursor
noremap <Leader>F :Ack <cword><cr>
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
if version > 580
if exists("syntax_on")
syntax on
endif
endif
syntax on