-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
516 lines (455 loc) · 16.4 KB
/
vimrc
File metadata and controls
516 lines (455 loc) · 16.4 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
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.config/nvim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
Plugin 'scrooloose/syntastic'
Plugin 'alvan/vim-closetag'
Plugin 'jiangmiao/auto-pairs'
"Plugin 'tobyS/vmustache'
"Bundle 'tobyS/pdv'
Plugin 'sumpygump/php-documentor-vim'
Plugin 'captbaritone/better-indent-support-for-php-with-html'
Plugin 'gcmt/taboo.vim'
Plugin 'rayburgemeestre/phpfolding.vim'
"Plugin 'ntpeters/vim-better-whitespace'
Plugin 'craigemery/vim-autotag'
Plugin 'will133/vim-dirdiff'
Plugin 'easymotion/vim-easymotion'
Plugin 'tpope/vim-abolish'
Plugin 'tpope/vim-commentary'
Plugin 'tpope/vim-fugitive'
Plugin 'tpope/vim-surround'
"Plugin 'tpope/vim-vinegar'
Plugin 'tmhedberg/matchit'
Plugin 'tmhedberg/SimpylFold'
Plugin 'jparise/vim-graphql'
Plugin 'neo4j-contrib/cypher-vim-syntax'
Plugin 'ElmCast/elm-vim'
Plugin 'Shougo/defx.nvim'
Plugin 'roxma/nvim-yarp'
Plugin 'roxma/vim-hug-neovim-rpc'
Plugin 'StanAngeloff/php.vim'
Plugin 'vim-vdebug/vdebug'
Plugin 'chrisbra/csv.vim'
Plugin 'elixir-editors/vim-elixir'
Plugin 'alvan/vim-php-manual'
Plugin 'github/copilot.vim'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"==========
" SETTINGS
"==========
filetype plugin indent on
set tabstop=4
set softtabstop=4
set shiftwidth=4
set expandtab
set number
"set relativenumber
set noswapfile
set wildmenu
set wildmode=longest,full
set ignorecase
set smartcase
set list
set listchars=tab:>-<,trail:-,nbsp:+
set nohlsearch
set scrolloff=3
set sidescrolloff=5
set mouse=
" Status line
set laststatus=2 " always show statusbar
set statusline=
set statusline+=%-5.3n\ " buffer number
set statusline+=%f\ " filename
set statusline+=%{&bomb?'[BOM]':''} " BOM flag
set statusline+=%h%m%r%w " status flags
"set statusline+=\[%{strlen(&ft)?&ft:'none'}] " file type
set statusline+=%= " right align remainder
set statusline+=0x%-8B " character value
set statusline+=%-14(%l,%c%V%) " line, character
set statusline+=%<%P " file position
set modelines=0
set nomodeline
map Y yy
noremap <F12> <Esc>:syntax sync fromstart<CR>
inoremap <F12> <C-o>:syntax sync fromstart<CR>
" Toggle folding
nnoremap <silent> <Space> @=(foldlevel('.')?'zA':"\<Space>")<CR>
vnoremap <Space> zf
" Remove trailing whitespace
nnoremap g<F5> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar><CR>
" Line wrapping & Home to start of indent
autocmd VimEnter,BufReadPost * noremap <buffer> <silent> <Up> gk
autocmd VimEnter,BufReadPost * noremap <buffer> <silent> <Down> gj
autocmd VimEnter,BufReadPost * noremap <Home> g^
autocmd VimEnter,BufReadPost * noremap <End> g<End>
autocmd VimEnter,BufReadPost * inoremap <buffer> <silent> <Up> <C-o>gk
autocmd VimEnter,BufReadPost * inoremap <buffer> <silent> <Down> <C-o>gj
autocmd VimEnter,BufReadPost * inoremap <Home> <C-o>g^
autocmd VimEnter,BufReadPost * inoremap <End> <C-o>g<End>
" Tags
set tags=/var/www/tags,./tags;/,tags;/
" Autocorrect
iabbrev consolidaiton consolidation
iabbrev currenct currency
iabbrev presnet present
iabbrev Presnet Present
" Dahbug
nmap <F3>dd o\dahbug::dump();<ESC>hi
imap <F3>dd \dahbug::dump();<ESC>hi
nmap <F3>dp o\dahbug::dump();<ESC>hPll
imap <F3>dp \dahbug::dump();<ESC>hPlla
nmap <F3>mm o\dahbug::methods();<ESC>hi
imap <F3>mm \dahbug::methods();<ESC>hi
nmap <F3>mp o\dahbug::methods();<ESC>hPll
imap <F3>mp \dahbug::methods();<ESC>hPlla
nmap <F3>ww o\dahbug::write();<ESC>hi
imap <F3>ww \dahbug::write();<ESC>hi
nmap <F3>wp o\dahbug::write();<ESC>hPll
imap <F3>wp \dahbug::write();<ESC>hPlla
nmap <F3>tt o\dahbug::toggleTimer();<ESC>hi
imap <F3>tt \dahbug::toggleTimer();<ESC>hi
nmap <F3>tp o\dahbug::toggleTimer();<ESC>hPll
imap <F3>tp \dahbug::toggleTimer();<ESC>hPlla
function PhpSyntaxOverride()
syntax keyword phpDefine function contained
syntax keyword phpType class abstract extends interface implements static final var public private protected const trait contained
endfunction
augroup phpSyntaxOverride
autocmd!
autocmd FileType php call PhpSyntaxOverride()
augroup END
" autocmd FileType php set keywordprg=pman
"=================
" PLUGIN SETTINGS
"=================
" Netrw
"map <C-e> :Rexplore<CR>
let g:netrw_liststyle=3
let g:netrw_altv=1
let g:netrw_alto=1
autocmd FileType netrw setl bufhidden=delete
" Closetags
let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.xml"
" Copilot
imap <silent><script><expr> <S-Tab> copilot#Accept("\<CR>")
let g:copilot_no_tab_map = v:true
" Autopairs settings
let g:AutoPairsShortcutFastWrap = 'đ'
let g:AutoPairsShortcutToggle = 'ŋ'
let g:AutoPairsMultilineClose = 0
let g:AutoPairsCenterLine = 0
"au Filetype php call AutoPairsDefine({'<?=' : '?>'}, ['<?', '<?php'])
" PHP Documentor
inoremap <C-P> <ESC>:call PhpDocSingle()<CR>i
nnoremap <C-P> :call PhpDocSingle()<CR>
vnoremap <C-P> :call PhpDocRange()<CR>
let g:pdv_cfg_ClassTags = ["author", "copyright"]
let g:pdv_cfg_Type = "mixed"
let g:pdv_cfg_Package = ""
let g:pdv_cfg_Version = ""
let g:pdv_cfg_Author = " Webbhuset AB <[email protected]>"
let g:pdv_cfg_Copyright = "Copyright (C) 2018 Webbhuset AB"
let g:pdv_cfg_License = ""
" Elm-vim
autocmd FileType elm setlocal foldmethod=syntax
let g:elm_format_autosave = 0
" Syntastic
let g:syntastic_check_on_open = 1
let g:syntastic_python_python_exec = '/usr/bin/python3'
let g:syntastic_rst_checkers = ['sphinx']
" Taboo
set sessionoptions+=tabpages,globals
let g:taboo_tab_format=" %m%N: %f(%W) "
let g:taboo_renamed_tab_format=" %m%N: %l(%W) "
" Vdebug
if !exists('g:vdebug_options')
let g:vdebug_options = {}
endif
if !exists('g:vdebug_features')
let g:vdebug_features = {}
endif
let g:vdebug_options.port = 9003
let g:vdebug_options.path_maps = { '/srv/magento': '/home/andreas/work/projects/zettle/magento/' }
let g:vdebug_options.break_on_open = 0
let g:vdebug_features['max_children'] = 128
" Easymotion
let g:EasyMotion_do_mapping = 0
let g:EasyMotion_smartcase = 1
let g:EasyMotion_use_upper = 1
let g:EasyMotion_keys = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ,'
let g:EasyMotion_verbose = 0
let g:EasyMotion_skipfoldedline = 0
let g:EasyMotion_enter_jump_first = 1
map / <Plug>(easymotion-sn)
omap / <Plug>(easymotion-tn)
map ? <Plug>(easymotion-sn)
omap ? <Plug>(easymotion-tn)
nmap f <Plug>(easymotion-fl)
vmap f <Plug>(easymotion-fl)
nmap F <Plug>(easymotion-Fl)
vmap F <Plug>(easymotion-Fl)
nmap t <plug>(easymotion-tl)
vmap t <plug>(easymotion-tl)
nmap T <plug>(easymotion-Tl)
vmap T <plug>(easymotion-Tl)
nmap w <plug>(easymotion-w)
vmap w <plug>(easymotion-w)
nmap W <plug>(easymotion-W)
vmap W <plug>(easymotion-W)
nmap b <plug>(easymotion-b)
vmap b <plug>(easymotion-b)
nmap B <plug>(easymotion-B)
vmap B <plug>(easymotion-B)
nmap e <plug>(easymotion-e)
vmap e <plug>(easymotion-e)
nmap E <plug>(easymotion-E)
vmap E <plug>(easymotion-E)
nmap ge <plug>(easymotion-ge)
vmap ge <plug>(easymotion-ge)
nmap gE <plug>(easymotion-gE)
vmap gE <plug>(easymotion-gE)
nmap n <plug>(easymotion-n)
vmap n <plug>(easymotion-n)
nmap N <plug>(easymotion-N)
vmap N <plug>(easymotion-N)
" Defx
nnoremap <silent> - :Defx -listed -resume -toggle<CR>
autocmd VimEnter * command! -nargs=? Explore :Defx <args>
autocmd VimEnter * command! -nargs=? Texplore :Defx -split=tab -listed -resume <args>
autocmd VimEnter * command! -nargs=? -bang Vexplore call SplitDefx('vnew', <bang>0, <f-args>)
autocmd VimEnter * command! -nargs=? -bang Hexplore call SplitDefx('new', <bang>1, <f-args>)
function! SplitDefx(split, bang, ...)
let com = a:split . " | Defx -listed -resume " . get(a:, 1, "")
if a:bang
let com = "below " . l:com
endif
execute l:com
endfunction
hi link Defx_mark_0_readonly Comment
hi link Defx_mark_0_selected Statement
hi link Defx_filename_3_directory_icon Special
hi link Defx_filename_3_opened_icon Special
hi link Defx_filename_3_root_icon Identifier
hi link Defx_filename_3_directory PreProc
hi link Defx_filename_3_root Identifier
hi link Defx_filename_3_root_marker Constant
hi link Defx_filename_3_hidden Comment
hi link Defx_type_4_text Constant
hi link Defx_type_4_image Type
hi link Defx_type_4_archive Special
hi link Defx_type_4_executable Statement
augroup defx_settings
autocmd!
autocmd BufEnter * call s:open_defx_if_directory()
autocmd FileType defx setlocal cursorline
autocmd FileType defx call defx#custom#column('filename', 'min_width', 60)
autocmd FileType defx call defx#custom#column('icon', 'directory_icon', '+ ')
autocmd FileType defx call defx#custom#column('icon', 'file_icon', ' ')
autocmd FileType defx call defx#custom#column('icon', 'opened_icon', '- ')
autocmd FileType defx call defx#custom#column('icon', 'root_icon', '')
autocmd FileType defx call defx#custom#column('indent', 'indent', ' ')
autocmd FileType defx call s:defx_my_settings()
augroup END
let g:loaded_netrw= v:true
let g:netrw_loaded_netrwPlugin= v:true
function! s:open_defx_if_directory()
let l:full_path = expand(expand('%:p'))
if isdirectory(l:full_path)
Defx `expand('%:p')`
endif
endfunction
function! s:defx_my_settings() abort
" Define mappings
nnoremap <silent><buffer><expr> <CR>
\ defx#is_directory() ?
\ defx#do_action('open_or_close_tree') :
\ defx#do_action('open')
nnoremap <silent><buffer><expr> c
\ defx#do_action('copy')
nnoremap <silent><buffer><expr> m
\ defx#do_action('move')
nnoremap <silent><buffer><expr> p
\ defx#do_action('paste')
nnoremap <silent><buffer><expr> l
\ defx#do_action('open')
nnoremap <silent><buffer><expr> E
\ defx#do_action('open', 'vsplit')
nnoremap <silent><buffer><expr> P
\ defx#do_action('open', 'pedit')
nnoremap <silent><buffer><expr> o
\ defx#do_action('open_or_close_tree')
nnoremap <silent><buffer><expr> d
\ defx#do_action('new_directory')
nnoremap <silent><buffer><expr> %
\ defx#do_action('new_file')
nnoremap <silent><buffer><expr> M
\ defx#do_action('new_multiple_files')
nnoremap <silent><buffer><expr> C
\ defx#do_action('toggle_columns',
\ 'mark:indent:icon:filename:type:size:time')
nnoremap <silent><buffer><expr> S
\ defx#do_action('toggle_sort', 'time')
nnoremap <silent><buffer><expr> D
\ defx#do_action('remove')
nnoremap <silent><buffer><expr> r
\ defx#do_action('rename')
nnoremap <silent><buffer><expr> !
\ defx#do_action('execute_command')
nnoremap <silent><buffer><expr> x
\ defx#do_action('execute_system')
nnoremap <silent><buffer><expr> yy
\ defx#do_action('yank_path')
nnoremap <silent><buffer><expr> .
\ defx#do_action('toggle_ignored_files')
nnoremap <silent><buffer><expr> ;
\ defx#do_action('repeat')
nnoremap <silent><buffer><expr> h
\ defx#do_action('cd', ['..'])
nnoremap <silent><buffer><expr> ~
\ defx#do_action('cd')
nnoremap <silent><buffer><expr> q
\ defx#do_action('quit')
nnoremap <silent><buffer><expr> <Space>
\ defx#do_action('toggle_select') . 'j'
nnoremap <silent><buffer><expr> *
\ defx#do_action('toggle_select_all')
nnoremap <silent><buffer><expr> j
\ line('.') == line('$') ? 'gg' : 'j'
nnoremap <silent><buffer><expr> k
\ line('.') == 1 ? 'G' : 'k'
nnoremap <silent><buffer><expr> <C-l>
\ defx#do_action('redraw')
nnoremap <silent><buffer><expr> <C-g>
\ defx#do_action('print')
nnoremap <silent><buffer><expr> cd
\ defx#do_action('change_vim_cwd')
endfunction
"=================
" FOLDING
"=================
function! CustomFoldText(...)
let currentLine = v:foldstart
let lines = (v:foldend - v:foldstart + 1)
let lineString = getline(currentLine)
" See if we folded a marker
if strridx(lineString, "{{{") != -1 " }}}
" Is there text after the fold opener?
if (matchstr(lineString, '^.*{{{..*$') == lineString) " }}}
" Then only show that text
let lineString = substitute(lineString, '^.*{{{', '', 'g') " }}}
" There is text before the fold opener
else
" Try to strip away the remainder
let lineString = substitute(lineString, '\s*{{{.*$', '', 'g') " }}}
endif
" See if we folded a DocBlock
elseif strridx(lineString, '#@+') != -1
" Is there text after the #@+ piece?
if (matchstr(lineString, '^.*#@+..*$') == lineString)
" Then show that text
let lineString = substitute(lineString, '^.*#@+', '', 'g') . ' ' . g:phpDocBlockIncludedPostfix
" There is nothing?
else
" Use the next line..
let lineString = getline(currentLine + 1) . ' ' . g:phpDocBlockIncludedPostfix
endif
" See if we folded an API comment block
elseif strridx(lineString, "\/\*\*") != -1
" (I can't get search() or searchpair() to work.., therefore the
" following loop)
let s:state = 0
while currentLine < v:foldend
let line = getline(currentLine)
if s:state == 0 && strridx(line, "\*\/") != -1
" Found the end, now we need to find the first not-empty line
let s:state = 1
elseif s:state == 1 && (matchstr(line, '^\s*$') != line)
" Found the line to display in fold!
break
endif
let currentLine = currentLine + 1
endwhile
let lineString = getline(currentLine)
endif
" Some common replaces...
" if currentLine != v:foldend
let lineString = substitute(lineString, '/\*\|\*/\d\=', '', 'g')
"let lineString = substitute(lineString, '^\*\?\s*', '', 'g')
let lineString = substitute(lineString, '{$', '', 'g')
let lineString = substitute(lineString, '($', '(..);', 'g')
" endif
" Append an (a) if there is PhpDoc in the fold (a for API)
if currentLine != v:foldstart
"let lineString = lineString . " " . g:phpDocIncludedPostfix . " "
endif
" Return the foldtext
redir =>a |exe "sil sign place buffer=".bufnr('')|redir end
let signlist=split(a, '\n')
let width=winwidth(0) - ((&number||&relativenumber) ? &numberwidth : 0) - &foldcolumn - (len(signlist) > 2 ? 2 : 0)
let lineCountStr = "[" . lines . " lines]"
if strwidth(lineString) > width - strwidth(lineCountStr) - 1
let lineString = strpart(lineString, 0, width - strwidth(lineCountStr) - 1) . '…'
endif
let expansionString = repeat(" ", width - strwidth(lineString.lineCountStr))
return lineString.expansionString.lineCountStr
endfunction
"=================
" ALIGN EQUALS
"=================
function! AlignEqualsRange() range
let lineStart = line("'<")
let lineEnd = line("'>")
let equalsCol = 0
for i in range(lineStart, lineEnd)
let col = stridx(getline(i), "=")
if col > equalsCol
let equalsCol = col
endif
endfor
if &shiftwidth > 0
let equalsCol += (&shiftwidth - (equalsCol % &shiftwidth)) % &shiftwidth
endif
for i in range(lineStart, lineEnd)
let lineString = getline(i)
let col = stridx(lineString, "=")
let spaces = equalsCol - col
let lineStringEnd = strpart(lineString, col)
let lineString = strpart(lineString, 0, col)
let j = 0
while j < spaces
let lineString .= " "
let j += 1
endwhile
let lineString .= lineStringEnd
call setline(i, lineString)
endfor
endfunction
"vnoremap <F4> :call AlignEqualsRange()<CR>
"=================
" RELOAD
"=================
augroup reload_vimrc " {
autocmd!
autocmd BufWritePost $MYVIMRC source $MYVIMRC
autocmd VimEnter,BufReadPost * set foldtext=CustomFoldText()
autocmd BufRead,BufNewFile *.sls set filetype=yaml
"autocmd VimEnter *.php normal zR
augroup END " }