forked from slax0rr/MyConfig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
391 lines (332 loc) · 10.4 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
" be iMproved, required
set nocompatible
"""""""""""""""""""
" BEGIN "
" Vundle settings "
" BEGIN "
"""""""""""""""""""
if !empty(glob("~/.vim/bundle/Vundle.vim"))
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'airblade/vim-gitgutter'
"Plugin 'bling/vim-airline'
"Plugin 'vim-airline/vim-airline-themes'
Plugin 'suan/vim-instant-markdown'
Plugin 'fatih/vim-go'
Plugin 'WebAPI.vim'
Plugin 'metarw'
Plugin 'fugitive.vim'
Plugin 'mattn/emmet-vim'
"Plugin 'DBGPavim'
Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
Plugin 'editorconfig/editorconfig-vim'
Plugin 'joonty/vdebug'
call vundle#end()
endif
"""""""""""""""""""
" END "
" Vundle settings "
" END "
"""""""""""""""""""
"""""""""""""""""""""""""""
" BEGIN "
" Editor related settings "
" BEGIN "
"""""""""""""""""""""""""""
" Enable filetype plugin and indent
filetype plugin indent on
" Tab and indent settings
set tabstop=4
set shiftwidth=4
set expandtab
set autoindent
" Backup file dir
set backupdir=~/tmp
" Line numbers
set relativenumber
" Set backspace to work as in other apps
set backspace=2
" Enable wmnu
set wmnu
" add custom ctags file
set tags=.tags;
" set forward slashes
set shellslash
" Disable mouse
set mouse=
" Set listchars
set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<
set list
" Disable visual bell
set t_vb=
" Reopen file on same line as it was closed
if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
" sharing is caring
command! -range=% VP execute <line1> . "," . <line2> . "w !vpaste ft=" . &filetype
command! -range=% SP silent execute <line1> . "," . <line2> . "w !curl -F 'sprunge=<-' http://sprunge.us/ | tr -d '\\n' | awk '{print $1\"?" . &filetype . "\"}' | xclip -selection clipboard"
command! -range=% IX silent execute <line1> . "," . <line2> . "w !curl -F 'f:1=<-' ix.io | tr -d '\\n' | xclip -selection clipboard"
command! CMD let @+ = ':' . @:
" hide files, instead of closing
set hidden
" set folding
set foldmethod=indent
set foldlevel=99
"""""""""""""""""""""""""""
" END "
" Editor related settings "
" END "
"""""""""""""""""""""""""""
""""""""""""""""""""""""""""""
" BEGIN "
" Graphical related settings "
" BEGIN "
""""""""""""""""""""""""""""""
" Syntax Highlighting
syntax on
" Set Search Highlighting
set hlsearch
" set background
set background=dark
" Set Colorscheme
colorscheme base16-atelierheath
" color scheme settings
highlight Search ctermbg=0 ctermfg=13 cterm=bold,underline
highlight CursorLine cterm=underline
highlight CursorLineNr ctermbg=0 ctermfg=NONE
highlight WildMenu ctermbg=12 ctermfg=10
" Spell highlight
highlight SpellBad ctermbg=0 ctermfg=13 cterm=bold,underline
highlight SpellCap ctermbg=0 ctermfg=12 cterm=bold,underline
highlight SpellRare ctermbg=0 ctermfg=0 cterm=bold,underline
highlight SpellLocal ctermbg=0 ctermfg=11 cterm=bold,underline
" higlight SpecialKey
highlight SpecialKey ctermfg=10
" statusline fg color
highlight StatusLine ctermfg=0
" Highlight 80 and 120 columns
let &colorcolumn="80,".join(range(120,999),",")
" Add cursorline and cursorcolumn
set cursorline
set cursorcolumn
""""""""""""""""""""""""""""""
" END "
" Graphical related settings "
" END "
""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""
" BEGIN "
" Autocompletion settings "
" BEGIN "
"""""""""""""""""""""""""""
" Add closing brackets when an opening bracket is written
" Squirly brackets
inoremap { {}<Left>
inoremap {<CR> {<CR>}<Esc>O
inoremap {{ {
inoremap {} {}
inoremap { {}<Left>
inoremap <expr> } strpart(getline('.'), col('.')-1, 1) == "}" ? "\<Right>" : "}"
" Parenthesis
inoremap ( ()<Left>
inoremap (<CR> (<CR>)<Esc>O
inoremap (( (
inoremap () ()
inoremap ( ()<Left>
inoremap <expr> ) strpart(getline('.'), col('.')-1, 1) == ")" ? "\<Right>" : ")"
" Square brackets
inoremap [ []<Left>
inoremap [<CR> [<CR>]<Esc>O
inoremap [[ [
inoremap [] []
inoremap [ []<Left>
inoremap <expr> ] strpart(getline('.'), col('.')-1, 1) == "]" ? "\<Right>" : "]"
" Add closing quotes when an opening bracket is written, and jump over closing
inoremap " ""<Left>
inoremap "" "
inoremap <expr> " strpart(getline('.'), col('.')-1, 1) == "\"" ? "\<Right>" : "\"\"\<Left>"
inoremap ' ''<Left>
inoremap '' '
inoremap <expr> ' strpart(getline('.'), col('.')-1, 1) == "\'" ? "\<Right>" : "\'\'\<Left>"
" Autocompletion mappings
function! InsertTabWrapper()
if pumvisible()
return "\<c-n>"
endif
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-x>\<c-o>"
endif
endfunction
inoremap <expr><tab> InsertTabWrapper()
inoremap <expr><s-tab> pumvisible()?"\<c-p>":"\<c-d>"
"""""""""""""""""""""""""""
" END "
" Autocompletion settings "
" END "
"""""""""""""""""""""""""""
""""""""""""""
" BEGIN "
" Remappings "
" BEGIN "
""""""""""""""
" spellcheck
map <leader>se :setlocal spell spelllang=en_gb<CR>
map <leader>sd :setlocal nospell<CR>
" Hide search highlights for current search
nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
" Find on PHP.net
command! -nargs=1 Pdoc !xdg-open http://php.net/<args> &
nmap <leader>pd :Pdoc <cword><CR>
" Map \j and \sj keys to search for tags
map <leader>j g<C-]>
map <leader>sj <C-W>g<C-]>
map <silent><leader>tp <C-W>g}
" Horizontal split to vertical split
map <leader>h <C-w>H
map <leader>k <C-w>K
"split navigations
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>
" Run some formatting rules on a file
map <leader>f :call FixFormatting()<cr>
" Instant markdown preview mapping
map <leader>md :InstantMarkdownPreview<CR>
" open a file in the same dir as the current one (borrowed from mgedmin)
map <expr> <leader>E ":e ".expand("%:h")."/"
""""""""""""""
" END "
" Remappings "
" END "
""""""""""""""
""""""""""""""""""""
" BEGIN "
" Helper Functions "
" BEGIN "
""""""""""""""""""""
" Fix formatting
function! FixFormatting()
" wrap logical operators with spaces if there aren't any
execute '%s/\(\S\{-}\)\([<>!]\{-}=\+\|[<>|]\+\)\(\S\{-}\)/\1 \2 \3/ge'
execute '%s/[,a-zA-Z0-9 ^I]\@<!\([a-zA-Z0-9 ^I]\+\)\(&\+\)/\1 \2 /ge'
execute '%s/< ?php/<?php/ge'
execute '%s/-\s>\(\S\)/->\1/g'
" Add a space after control structure keyword, and after closing parenthesis
execute '%s/\(if\|for\|foreach\|while\|switch\)\s\{-}\((.*)\)\s\{-}{/\1 \2 {/ge'
" Turn else if into elseif
execute '%s/}\s\{-}else\s*if\s\{-}/} elseif/ge'
" Wrap else statement with spaces if there aren't any
execute '%s/}\s\{-}else\s\{-}{/} else {/ge'
" Remove whitespace in parenthesis
execute '%s/(\s*\(.*\)\s*)/(\1)/ge'
" Remove excesive whitespace
execute '%s/\(\S\+\) \{2,}\(\S\+\)/\1 \2/ge'
execute '%s/\(\S\+\) \{2,}\(\S\+\)/\1 \2/ge'
" Add whitespace after each comma
execute '%s/,\(\S\+\)/, \1/ge'
" Properly format function definitions
execute '%s/function\s\+\(.\{-}\)\s\{-}(\(.\{-}\))\s*{/function \1(\2)\r{/ge'
" Properly format class definitions
execute '%s/\(class\|interface\)\s\+\([a-zA-Z0-9]*\)\(.\{-}\)\s*{/\1 \2\3\r{/ge'
" Remove any trailing whitespace
execute '%s/\s\+$//ge'
" Remove excesive blank lines
execute 'g/^\n\{2,}/d'
" Remove blank lines before closing curly braces
execute 'g/^\n.*}/d'
" Retab the whole file
execute 'retab'
normal gg=G
endfunction
" Change to relative numbering and back
function! NumberToggle()
if (&relativenumber == 1)
set number
set norelativenumber
else
set nonumber
set relativenumber
endif
endfunction
nnoremap <leader>n :call NumberToggle()<CR>
" Code Sniffer Command
command! PhpCS :cexpr system("phpcs --colors --standard=PSR2SlaxWeb " . expand("%:p")) | copen
" Mess Detector Command
command! PhpMD :cexpr system("phpmd " . expand("%:p") . " text ~/.ruleset.xml") | copen
""""""""""""""""""""
" END "
" Helper Functions "
" END "
""""""""""""""""""""
"""""""""""""""""""
" BEGIN "
" Plugin Settings "
" BEGIN "
"""""""""""""""""""
" FuGITive status line
set laststatus=2
set statusline=%<%f\ %h%m%r%{fugitive#statusline()}%=%-14.(%l,%c%V%)\ %P
" Airline settings
" Enable powerline symbols
"let g:airline_powerline_fonts = 1
" Show pretty tabline
"let g:airline#extensions#tabline#enabled = 1
" Change theme for cli version
"let g:airline_theme='base16'
" Turn on all python highlights of the python syntax plugin
let python_highlight_all = 1
" Disable polyglot language packages
let g:polyglot_disables = ['php']
" DBGPavim config
"let g:dbgPavimPort = 9000
"let g:dbgPavimBreakAtEntry = 0
"let g:dbgPavimPathMap = [
"\ ['/home/slax0r/dev/projects/shops/kastner/', '/var/www/html/koedocker.acl.local/',],
"\ ['/home/slax0r/dev/projects/shops/forstinger/', '/var/www/html/fordocker.acl.local/',],
"\ ['/home/slax0r/dev/projects/shops/intersport/', '/var/www/html/ispdocker.acl.local/',],
"\ ['/home/slax0r/dev/projects/shops/deutschebahn/', '/var/www/html/ubkdocker.acl.local/',],
"\ ['/home/slax0r/dev/projects/pim/elsta/data/www/', '/var/www/',]
"\]
" Vdebug settings
let g:vdebug_options = {
\ "port": 9000,
\ "timeout": 60,
\ "break_on_open": 0,
\ "path_maps": {
\ "/var/www": "/home/slax0r/dev/projects/post/shopware/data/www",
\ "/var/www/html/koedocker.acl.local": "/home/slax0r/dev/projects/shops/kastner"
\ }
\}
" Instant markdown preview settings
let g:instant_markdown_autostart = 0
" emmet config
let g:user_emmet_complete_tag = 1
" vim-go settings
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
" setup the editorconfig plugin
let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*']
"""""""""""""""""""
" END "
" Plugin Settings "
" END "
"""""""""""""""""""
" Load environment specific files, if it exists
if !empty(glob("~/.vimrc_env"))
source ~/.vimrc_env
endif
" Load private computer specific config file, if it exists
if !empty(glob("~/.vimrc_local"))
source ~/.vimrc_local
endif