-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
1729 lines (1475 loc) · 62.9 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
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
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
let $HOME = "/Users/Leigh.bicknell"
" Neovim segregation support
if has('nvim')
let s:editor_root=expand($HOME . "/.nvim")
let $editor_root=s:editor_root
let &runtimepath.=','.$editor_root
else
let s:editor_root=expand($HOME . "/.vim")
let $editor_root=s:editor_root
endif
" needs to be done early
let g:CommandTPreferredImplementation='ruby'
" install vimplug
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.nvim/bundle')
Plug 'shougo/vimproc'
" GENERAL
Plug 'mhinz/vim-grepper'
Plug 'overcache/NeoSolarized'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-eunuch'
Plug 'benjifisher/matchit.zip'
Plug 'mbbill/undotree'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'scrooloose/nerdtree'
Plug 'vim-scripts/Tab-Name'
Plug 'SirVer/ultisnips'
Plug 'mattn/emmet-vim'
Plug 'moll/vim-bbye'
Plug 'wincent/command-t'
Plug 'tpope/vim-dispatch'
Plug 'FlickerBean/vim-dirdiff'
" Open browser
Plug 'tyru/open-browser.vim'
" Open items from quickfix wherever i want!
Plug 'yssl/QFEnter'
" PROGRAMMING
"Plug 'scrooloose/syntastic'
"Git integration
Plug 'github/copilot.vim'
Plug 'tpope/vim-fugitive'
" Syntax, indent and filetype plugins for git, gitcommit, gitconfig
" etc Earlier versions shipped with VIM
Plug 'tpope/vim-git'
" Git details in gutter
Plug 'airblade/vim-gitgutter'
Plug 'mattn/webapi-vim'
Plug 'scrooloose/nerdcommenter'
Plug 'godlygeek/tabular'
"Plug 'vcscommand.vim'
"Plug 'vim-scripts/cscope_macros.vim'
"Plug 'Valloric/YouCompleteMe'
"Plug 'ap/vim-css-color'
"Plug 'majutsushi/tagbar'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
"Plug 'neoclide/coc-phpls', {'do': 'yarn install --frozen-lockfile'}
" PHP
Plug 'StanAngeloff/php.vim'
" "This is needed by pdv :/
Plug 'tobyS/vmustache'
" PHPDocBlocks
" Plug 'shawncplus/phpcomplete.vim'
"Plug 'm2mdas/phpcomplete-extended'
"Plug 'm2mdas/phpcomplete-extended-symfony'
"Plug 'm2mdas/phpcomplete-extended-laravel'
"Plug 'lvht/phpcd.vim'
"Plug 'taoso/phpcd.vim'
"Plug 'epii1/phpcd.vim', {'pinned': 1}
Plug 'FlickerBean/pdv'
Plug 'arnaud-lb/vim-php-namespace'
Plug 'rayburgemeestre/phpfolding.vim'
"Plug 'FlickerBean/vim-php-refactoring'
Plug 'adoy/vim-php-refactoring-toolbox'
Plug 'stephpy/vim-php-cs-fixer'
" Helper for creating php snippets
Plug 'sniphpets/sniphpets'
Plug 'jwalton512/vim-blade'
"Plug 'sniphpets/sniphpets-symfony'
" Wordpress
" Plug 'dsawardekar/wordpress.vim'
" Plug 'Garethp/vdebug'
Plug 'vim-test/vim-test'
"PYTHON
" Pick either python-mode or pyflakes & pydoc
"Plug 'klen/python-mode'
"Plug 'python.vim'
"Plug 'python_match.vim'
"JAVASCRIPT
Plug 'elzr/vim-json'
Plug 'briancollins/vim-jst'
Plug 'leafgarland/typescript-vim'
Plug 'jason0x43/vim-js-indent'
" for Syntastic typescript
Plug 'Quramy/tsuquyomi'
"CSV
Plug 'chrisbra/csv.vim'
" VUE
Plug 'posva/vim-vue'
call plug#end()
" Environment {
" Basics {
set nocompatible " Must be first line
if !(has('win16') || has('win32') || has('win64'))
"set shell=/bin/bash
set shell=/bin/bash\ -l
endif
" }
" }
" General {
set fileformats=unix,dos
" set autowrite " automatically write a file when leaving a modified buffer
set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter')
set background=dark " Assume a dark background
if !has('gui') && !has('nvim')
set term=$TERM " Make arrow and other keys work
endif
filetype plugin indent on " Automatically detect file types.
syntax on " Syntax highlighting
set mouse=a " Automatically enable mouse usage
set mousehide " Hide the mouse cursor while typing
scriptencoding utf-8
" This linux if isn't working :/
set clipboard=unnamedplus
if has ('unix') && (has ('gui') && has('nvim')) " On Linux use + register for copy-paste
set clipboard=unnamedplus
elseif has ('gui') || has ('gui_mac') " On mac and Windows, use * register for copy-paste
set clipboard=unnamed
endif
set viewoptions=folds,options,cursor,unix,slash " Better Unix / Windows compatibility
set history=1000 " Store a ton of history (default is 20)
set hidden " Allow buffer switching without saving
"set foldlevel=1
" Instead of reverting the cursor to the last position in the buffer, we
" set it to the first line when editing a git commit message
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
" http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
" Restore cursor to file position in previous editing session
" To disable this, add the following to your .vimrc.before.local file:
" let g:no_restore_cursor = 1
if !exists('g:no_restore_cursor')
function! ResCur()
if line("'\"") <= line("$")
normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
endif
" Setting up the directories {
set backup " Backups are nice ...
if has('persistent_undo')
set undofile " So is persistent undo ...
set undolevels=10000 " Maximum number of changes that can be undone
set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
endif
" }
" Diff ignore all whitespace hack {
set diffopt+=iwhite
set diffexpr=
" disable hack, this disables all whitespace vs changes in amount of
" whitespace
" So why did I disable it? re-enabled
" Disabled again because diff doesn't accept --binary flag
"set diffexpr=DiffW()
function! DiffW()
let opt = ""
if &diffopt =~ "icase"
let opt = opt . "-i "
endif
if &diffopt =~ "iwhite"
let opt = opt . "-w " " vim uses -b by default
endif
silent execute "!diff -a --binary " . opt .
\ v:fname_in . " " . v:fname_new . " > " . v:fname_out
endfunction
" }
" }
" Vim UI {
let g:LargeFile = 1024 * 1024
autocmd BufReadPre * let f=getfsize(expand("<afile>")) | if f > g:LargeFile || f == -2 | call LargeFile() | endif
function! LargeFile()
let b:LargeFile=1
endfunction
set tabpagemax=15 " Only show 15 tabs
set showmode " Display the current mode
highlight clear SignColumn " SignColumn should match background for
" things like vim-gitgutter
highlight clear LineNr " Current line number row will have same background color in relative mode.
" Things like vim-gitgutter will match LineNr highlight
"highlight clear CursorLineNr " Remove highlight color from current line number
autocmd ColorScheme * highlight! link SignColumn LineNr
if has('cmdline_info')
set ruler " Show the ruler
set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " A ruler on steroids
set showcmd " Show partial commands in status line and
" Selected characters/lines in visual mode
" This actually stops the cursor vanishing
" for some reason!
endif
set title
if has('statusline')
set laststatus=2
" Broken down into easily includeable segments
"set statusline=%<%f\ " Filename
"set statusline+=%w%h%m%r " Options
"set statusline+=%{fugitive#statusline()} " Git Hotness
"set statusline+=\ [%{&ff}/%Y] " Filetype
"set statusline+=\ [%{getcwd()}] " Current dir
"set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info
"statusline setup (scrooloose)
set statusline =%#identifier#
set statusline+=[%t] "tail of the filename
set statusline+=%*
"display a warning if fileformat isnt unix
set statusline+=%#warningmsg#
set statusline+=%{&ff!='unix'?'['.&ff.']':''}
set statusline+=%*
"display a warning if file encoding isnt utf-8
set statusline+=%#warningmsg#
set statusline+=%{(&fenc!='utf-8'&&&fenc!='')?'['.&fenc.']':''}
set statusline+=%*
set statusline+=%h "help file flag
set statusline+=%y "filetype
"read only flag
set statusline+=%#identifier#
set statusline+=%r
set statusline+=%*
"modified flag
set statusline+=%#identifier#
set statusline+=%m
set statusline+=%*
" Seriously slows down vim over network
"set statusline+=%{fugitive#statusline()}
"display a warning if &et is wrong, or we have mixed-indenting
set statusline+=%#error#
set statusline+=%{StatuslineTabWarning()}
set statusline+=%*
set statusline+=%{StatuslineTrailingSpaceWarning()}
set statusline+=%{StatuslineLongLineWarning()}
set statusline+=%#warningmsg#
"set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
"display a warning if &paste is set
set statusline+=%#error#
set statusline+=%{&paste?'[paste]':''}
set statusline+=%*
set statusline+=%= "left/right separator
set statusline+=%{StatuslineCurrentHighlight()}\ \ "current highlight
set statusline+=%c, "cursor column
set statusline+=%l/%L "cursor line/total lines
set statusline+=\ %P "percent through file
set laststatus=2
"recalculate the trailing whitespace warning when idle, and after saving
autocmd cursorhold,bufwritepost * unlet! b:statusline_trailing_space_warning
"return '[\s]' if trailing white space is detected
"return '' otherwise
function! StatuslineTrailingSpaceWarning()
if exists("b:LargeFile")
return ''
endif
if !exists("b:statusline_trailing_space_warning")
if !&modifiable
let b:statusline_trailing_space_warning = ''
return b:statusline_trailing_space_warning
endif
if search('\s\+$', 'nw') != 0
let b:statusline_trailing_space_warning = '[\s]'
else
let b:statusline_trailing_space_warning = ''
endif
endif
return b:statusline_trailing_space_warning
endfunction
"return the syntax highlight group under the cursor ''
function! StatuslineCurrentHighlight()
if exists("b:LargeFile")
return ''
endif
let name = synIDattr(synID(line('.'),col('.'),1),'name')
if name == ''
return ''
else
return '[' . name . ']'
endif
endfunction
"recalculate the tab warning flag when idle and after writing
autocmd cursorhold,bufwritepost * unlet! b:statusline_tab_warning
"return '[&et]' if &et is set wrong
"return '[mixed-indenting]' if spaces and tabs are used to indent
"return an empty string if everything is fine
function! StatuslineTabWarning()
if exists("b:LargeFile")
return ''
endif
if !exists("b:statusline_tab_warning")
let b:statusline_tab_warning = ''
if !&modifiable
return b:statusline_tab_warning
endif
let tabs = search('^\t', 'nw') != 0
"find spaces that arent used as alignment in the first indent column
let spaces = search('^ \{' . &ts . ',}[^\t]', 'nw') != 0
if tabs && spaces
let b:statusline_tab_warning = '[mixed-indenting]'
elseif (spaces && !&et) || (tabs && &et)
let b:statusline_tab_warning = '[&et]'
endif
endif
return b:statusline_tab_warning
endfunction
"recalculate the long line warning when idle and after saving
autocmd cursorhold,bufwritepost * unlet! b:statusline_long_line_warning
"return a warning for "long lines" where "long" is either &textwidth or 80 (if
"no &textwidth is set)
"
"return '' if no long lines
"return '[#x,my,$z] if long lines are found, were x is the number of long
"lines, y is the median length of the long lines and z is the length of the
"longest line
function! StatuslineLongLineWarning()
if exists("b:LargeFile")
return ''
endif
if !exists("b:statusline_long_line_warning")
if !&modifiable
let b:statusline_long_line_warning = ''
return b:statusline_long_line_warning
endif
let long_line_lens = s:LongLines()
if len(long_line_lens) > 0
let b:statusline_long_line_warning = "[" .
\ '#' . len(long_line_lens) . "," .
\ 'm' . s:Median(long_line_lens) . "," .
\ '$' . max(long_line_lens) . "]"
else
let b:statusline_long_line_warning = ""
endif
endif
return b:statusline_long_line_warning
endfunction
"return a list containing the lengths of the long lines in this buffer
function! s:LongLines()
let threshold = (&tw ? &tw : 80)
let spaces = repeat(" ", &ts)
let line_lens = map(getline(1,'$'), 'len(substitute(v:val, "\\t", spaces, "g"))')
return filter(line_lens, 'v:val > threshold')
endfunction
"find the median of the given array of numbers
function! s:Median(nums)
let nums = sort(a:nums)
let l = len(nums)
if l % 2 == 1
let i = (l-1) / 2
return nums[i]
else
return (nums[l/2] + nums[(l/2)-1]) / 2
endif
endfunction
endif
set backspace=indent,eol,start " Backspace for dummies
set diffopt+=vertical " Vertical diff
set linespace=0 " No extra spaces between rows (-1 for a few more lines on a screen)
set nu " Line numbers on
"set relativenumber " Relative numbering, slow but handy
"set cursorline " Highlight current line, slow but handy
"set cursorcolumn " Now we've got smooth scroll we may aswell go all out!
"Disable match paren because it makes command-T incredibly slow, gawd knows why!
au VimEnter * NoMatchParen
"set showmatch " Show matching brackets/parenthesis
set incsearch " Find as you type search
set hlsearch " Highlight search terms
set winminheight=0 " Windows can be 0 line high
set ignorecase " Case insensitive search
set smartcase " Case sensitive when uc present
set wildmenu " Show list instead of just completing
set wildmode=longest,list,full " Command <Tab> completion, list matches, then longest common part, then all.
" adding */.git/ to wildignore breaks fugitive Gdiff command, instead add
" it to command-t and .agignore
set wildignore=*.0,*.obj,*/cache/*,*/logs*/,*/doc/*,*/.svn/*,*/.rocketeer/checkout/*,*/nbproject/*,*/_archive/*,*/_archived/*,*/node_modules/*,*/bower_components/*,cscope.out,tags,*.DS_Store,*TEMPFOLDER*
set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
"set scrolljump=5 " Lines to scroll when cursor leaves screen
"set scrolloff=3 " Minimum lines to keep above and below cursor
set foldenable " Auto fold code
set list
set listchars=tab:>\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
set timeout " Wait for timeouts
set timeoutlen=2000 " Wait 2 seconds for mapping timeouts (ysiw etc)
set ttimeoutlen=100 " Wait 100ms for keycode mappings
set updatetime=500 " Time to wait before updating plugins
" }
" Formatting {
set wrap " Wrap because of formatoptions only wrapping comments
set formatoptions=qwbcj " gq format comments, " removed autowrap comments, due to fiblock
" autoformat comments, remove comment tags when joining lines
set textwidth=79
set autoindent " Indent at the same level of the previous line
set shiftwidth=4 " Use indents of 4 spaces
set expandtab " Tabs are spaces, not tabs
set tabstop=4 " An indentation every four columns
set softtabstop=4 " Let backspace delete indent
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set splitright " Puts new vsplit windows to the right of the current
set matchpairs+=<:> " Match, to be used with %
set comments=sl:/*,mb:*,elx:*/ " auto format comment blocks
highlight ColorColumn ctermbg=235
let &colorcolumn="81,".join(range(121,999),",") " Highlight column 81 and then 121 onwards
autocmd FileType c,cpp,css,less,scss,sass,java,go,php,php.wordpress,javascript,python,twig,xml,yml autocmd BufWritePre <buffer> if !exists('g:keep_trailing_whitespace') | call StripTrailingWhitespace() | endif
autocmd FileType go autocmd BufWritePre <buffer> Fmt
autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
autocmd BufNewFile,BufRead *.tpl set filetype=html.twig
autocmd FileType haskell setlocal expandtab shiftwidth=2 softtabstop=2
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
" Workaround vim-commentary for Haskel
autocmd FileType haskell setlocal commentstring=--\ %s
" Workaround broken colour highlighting in Haskell
autocmd FileType haskell setlocal nospell
" Make all diffs set wrap
autocmd FilterWritePre * if &diff | setlocal wrap< | endif
" }
" Key (re)Mappings {
" The default leader is '\', but many people prefer ',' as it's in a standard
" location. To override this behavior and set it back to '\' (or any other
" character) add the following to your .vimrc.before.local file:
" let g:leader='\'
if !exists('g:leader')
let mapleader = ','
else
let mapleader=g:leader
endif
" Fix syntax highlighting
noremap <F12> <Esc>:syntax sync fromstart<CR>
inoremap <F12> <C-o>:syntax sync fromstart<CR>
nmap <c-s> :update<CR>
vmap <c-s> <Esc><c-s>gv
imap <c-s> <Esc><c-s>
" Yank from the cursor to the end of the line, to be consistent with C and D.
noremap Y y$
" Code folding options
nmap <leader>f0 :set foldlevel=0<CR>
nmap <leader>f1 :set foldlevel=1<CR>
nmap <leader>f2 :set foldlevel=2<CR>
nmap <leader>f3 :set foldlevel=3<CR>
nmap <leader>f4 :set foldlevel=4<CR>
nmap <leader>f5 :set foldlevel=5<CR>
nmap <leader>f6 :set foldlevel=6<CR>
nmap <leader>f7 :set foldlevel=7<CR>
nmap <leader>f8 :set foldlevel=8<CR>
nmap <leader>f9 :set foldlevel=9<CR>
" Most prefer to toggle search ighlighting rather than clear the current
" search results. To clear search highlighting rather than toggle it on
" and off, add the following to your .vimrc.before.local file:
" let g:clear_search_highlight = 1
if exists('g:clear_search_highlight')
nmap <silent> <leader>/ :nohlsearch<CR>
else
nmap <silent> <leader>/ :set invhlsearch<CR>
endif
" Find merge conflict markers
map <leader>fc /\v^[<\|=>]{7}( .*\|$)<CR>
" Shortcuts
" Change Working Directory to that of the current file
cabbr cwd lcd %:p:h
cabbr cd. lcd %:p:h
" For when you forget to sudo.. Really Write the file.
cabbr w!! w !sudo tee % >/dev/null
" Some helpers to edit mode
" http://vimcasts.org/e/14
cnoremap %% <C-R>=expand('%:h').'/'<CR>
map <leader>ew :e %%
map <leader>es :sp %%
map <leader>ev :vsp %%
map <leader>et :tabe %%
" Adjust viewports to the same size
map <Leader>= <C-w>=
" Map <Leader>ff to display all lines with keyword under cursor
" and ask which one to jump to
nmap <Leader>ff [I:let nr = input("Which one: ")<Bar>exe "normal " . nr ."[\t"<CR>
" Easier horizontal scrolling
map zl zL
map zh zH
" Multipage (scrollbind)
"nmap <silent> <Leader>ef :vsplit<bar>wincmd l<bar>exe "norm! Ljz<c-v><cr>"<cr>:set scb<cr>:wincmd h<cr> :set scb<cr>
" NeoVim Mappings {
if has('nvim')
" Terminal esc
tnoremap <Esc> <C-\><C-N>
" Terminal window change mappings
tnoremap <A-h> <C-\><C-n><C-w>h
tnoremap <A-j> <C-\><C-n><C-w>j
tnoremap <A-k> <C-\><C-n><C-w>k
tnoremap <A-l> <C-\><C-n><C-w>l
nnoremap <A-h> <C-w>h
nnoremap <A-j> <C-w>j
nnoremap <A-k> <C-w>k
nnoremap <A-l> <C-w>l
endif
" }
" }
" Plugins {
" Misc {
let g:NERDShutUp=1
let b:match_ignorecase = 1
" vim-css-color for scss and sass (and less)
"autocmd FileType less,sass,scss,stylus,vim syn cluster sassCssAttributes add=@cssColors
" }
" Ack-grep {
"nnoremap <Leader>pa :Ack --php <c-r><c-w><CR>
" }
" Bbye {
nnoremap <Leader>q :Bdelete<CR>
nnoremap <Leader>Q :Bdelete!<CR>
" }
" Command-T {
" }
" Cscope {
"set cst
"set cscopequickfix=s-,c-,d-,i-,t-,e-
if filereadable("cscope.out")
"shut up msgs
set nocsverb
cs add cscope.out -C
"msgs back on
set csverb
"I'd rather do these separately and know which is comeing from
"where
set nocscopetag
endif
" Create cscope connection (we only want one connection at once, due to
" multiple projects open at once (one per tab) we could auto add
" connection on tab change but it isn't worth the slowdown
nnoremap <F9> :cs kill -1<CR>
\:cs add cscope.out . -C<CR>
"Automatically generate cscope database, Takes a while due to slow remote
"network drives :(
nnoremap <F10> :Start find . -name '*.php' > cscope.files
\-not -path "*/_archive/*"
\-not -path "*/_archived/*"
\-not -path "*/.git/*"
\-not -path "*/.svn/*"
\-not -path "*/node_modules/*"
\-not -path "*/bower_components/*"
\-not -path "*/.rocketeer/checkout/*"
\&& cscope -b -i ./cscope.files -f ./cscope.out
\&& rm ./cscope.files -f<CR>
"tags
nnoremap <F11> :Start -title='ctags' ctags -R
\--php-kinds=cfit
\--fields=+aimlS
\--languages=php
\--exclude="\.svn"
\--exclude="\.git"
\--exclude="*.CVS"
\--exclude="_archive"
\--exclude="_archived"
\--exclude="node_modules"
\--exclude="bower_components"
\--exclude="\.rocketeer"
\--tag-relative=yes
\--totals=yes<CR>
" These are mapped in the CSCOPE-maps plugin to <C-@> which is
" interpreted as <NUL> which for some reason doesn't work
nmap <C-Space>s :scs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space>g :scs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space>c :scs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space>t :scs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space>e :scs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space>f :scs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-Space>i :scs find i <C-R>=expand("<cfile>")<CR><CR>
nmap <C-Space>d :scs find d <C-R>=expand("<cword>")<CR><CR>
" Hitting CTRL-space *twice* before the search type does a vertical
" split instead of a horizontal one (vim 6 and up only)
nmap <C-Space><C-Space>s :vert scs find s <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space><C-Space>g :vert scs find g <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space><C-Space>c :vert scs find c <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space><C-Space>t :vert scs find t <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space><C-Space>e :vert scs find e <C-R>=expand("<cword>")<CR><CR>
nmap <C-Space><C-Space>f :vert scs find f <C-R>=expand("<cfile>")<CR><CR>
nmap <C-Space><C-Space>i :vert scs find i <C-R>=expand("<cfile>")<CR><CR>
nmap <C-Space><C-Space>d :vert scs find d <C-R>=expand("<cword>")<CR><CR>
" }
" Ctags {
set tags=./tags,tags,../tags
" Make tags placed in .git/tags file available in all levels of a repository
let gitroot = substitute(system('git rev-parse --show-toplevel'), '[\n\r]', '', 'g')
if gitroot != ''
let &tags = &tags . ',' . gitroot . '/.git/tags'
endif
" }
" delimitMate {
au FileType php let b:delimitMate_expand_cr = 1
au FileType php let b:delimitMate_expand_space = 1
au FileType php.wordpress let b:delimitMate_expand_cr = 1
au FileType php.wordpress let b:delimitMate_expand_space = 1
au FileType css let b:delimitMate_expand_cr = 1
au FileType css let b:delimitMate_expand_space = 1
au FileType scss let b:delimitMate_expand_cr = 1
au FileType scss let b:delimitMate_expand_space = 1
au FileType less let b:delimitMate_expand_cr = 1
au FileType less let b:delimitMate_expand_space = 1
au FileType sass let b:delimitMate_expand_cr = 1
au FileType sass let b:delimitMate_expand_space = 1
" }
" DirDiff {
" ignore white space in diff
let g:DirDiffAddArgs = "-w"
let g:DirDiffEnableMappings = 1
" }
" dispatch {
"let g:dispatch_compilers =
nnoremap <Leader>D :Dispatch<CR>
nnoremap <Leader>nbb :Start npm run build<CR>
nnoremap <Leader>nbc :Start npm run build:css<CR>
nnoremap <Leader>nbj :Start npm run build:js<CR>
nnoremap <Leader>nbw :Start npm run watch<CR>
nnoremap <leader>gbu :Dispatch gulp --file % build-and-upload<CR>
nnoremap <leader>nbu :call DeployToNetsuiteSdf()<CR>
function! DeployToNetsuiteSdf()
let b:pubpath = substitute(expand('%:p:.'), 'sdf/src/FileCabinet', '', 'g')
let b:pubpath = substitute(b:pubpath, '.ts$', '.js', '')
"echo b:pubpath
execute "Dispatch cd sdf && npm run devdeploy-manual -- " . b:pubpath
endfunction
" }
" Emmet {
let g:user_emmet_leader_key = '<c-e>'
" }
" Fugitive {
nnoremap <silent> <leader>gs :Git<CR>
nnoremap <silent> <leader>gd :Gdiff<CR>
nnoremap <silent> <leader>gc :Git commit<CR>
nnoremap <silent> <leader>gb :Git blame<CR>
nnoremap <silent> <leader>gl :Gclog<CR>
nnoremap <silent> <leader>gp :Git push<CR>
nnoremap <silent> <leader>gr :Gread<CR>:GitGutter<CR>
nnoremap <silent> <leader>gw :Gwrite<CR>:GitGutter<CR>
nnoremap <silent> <leader>ge :Gedit<CR>
nnoremap <silent> <leader>gg :GitGutterToggle<CR>
nnoremap <silent> <leader>ga :GitGutterStageHunk<CR>
nmap [g <Plug>(GitGutterPrevHunk)
nmap ]g <Plug>(GitGutterNextHunk)
" Auto remove fugitive buffers
autocmd BufReadPost fugitive://* set bufhidden=delete
" Go to parent directory when browsing a tree:
autocmd User fugitive
\ if fugitive#buffer().type() =~# '^\%(tree\|blob\)$' |
\ nnoremap <buffer> .. :edit %:h<CR> |
\ endif
" }
" vim-grepper {
" Mimic :grep and make ag the default tool. Also ,G switches tool (I
" want my auto completion!)
let g:grepper = {
\ 'tools': ['ag', 'git', 'grep'],
\ 'open': 1,
\ 'jump': 0,
\ 'ag': {
\ 'grepprg': 'ag --vimgrep',
\ 'wordanchors': ['', ''],
\ }
\ }
let g:grepper.prompt_mapping_tool='<S-Tab>'
nnoremap <leader>git :Grepper -tool git -noswitch<cr>
nnoremap <leader>ag :Grepper -tool ag -noswitch -cword<cr>
nnoremap <leader>* :Grepper -tool ag -noswitch -cword -noprompt<cr>
nnoremap <leader>G :Grepper -tool ag -noswitch -cword<cr>
cnoreabbrev Ag GrepperAg
" }
" JSON {
nmap <leader>jt <Esc>:%!python -m json.tool<CR><Esc>:set filetype=json<CR>
" }
" mirror.vim {
let g:mirror#spawn_command = ':Start '
nnoremap <leader>mp :MirrorPush<cr>
nnoremap <leader>mg :MirrorPull<cr>
nnoremap <leader>md :MirrorDiff<cr>
nnoremap <leader>mc :MirrorConfig<cr>
nnoremap <leader>mr :MirrorConfigReload<cr>
nnoremap <leader>ms :MirrorSSH<cr>
" Mirror diff quit (diffoff, buffer delete, window quit, diffoff in original window
nnoremap <leader>dq :diffoff<cr>:Bdelete<cr>:q<cr>:diffoff<cr>
" }
" NerdTree {
nmap <leader>on :NERDTreeToggle<CR>
nmap <leader>oN :NERDTreeFind<CR>
let NERDTreeShowBookmarks=0
let NERDTreeIgnore=['\.pyc', '\~$', '\.swo$', '\.swp$', '\.git', '\.hg', '\.svn', '\.bzr', 'nbproject']
let NERDTreeChDirMode=0
let NERDTreeMouseMode=1
let NERDTreeShowHidden=0
let NERDTreeKeepTreeInNewTab=0
let NERDTreeHighlightCursorline=0
let NERDTreeHijackNetrw=0
let g:nerdtree_tabs_open_on_gui_startup=0
" Force NERDTree to open file in current tab regardless of if it is
" already open in another.
function! NERDTreeMyOpenFile(node)
call a:node.activate({'reuse': 'currenttab', 'where': 'p'})
endfunction
autocmd VimEnter * :call NERDTreeAddKeyMap({ 'key': 'o', 'callback': 'NERDTreeMyOpenFile', 'scope': 'FileNode', 'override': 1 })
" }
" OmniComplete {
if has("autocmd") && exists("+omnifunc")
autocmd Filetype *
\if &omnifunc == "" |
\setlocal omnifunc=syntaxcomplete#Complete |
\endif
endif
hi Pmenu guifg=#000000 guibg=#F8F8F8 ctermfg=black ctermbg=Lightgray
hi PmenuSbar guifg=#8A95A7 guibg=#F8F8F8 gui=NONE ctermfg=darkcyan ctermbg=lightgray cterm=NONE
hi PmenuThumb guifg=#F8F8F8 guibg=#8A95A7 gui=NONE ctermfg=lightgray ctermbg=darkcyan cterm=NONE
" Some convenient mappings
"inoremap <expr> <Esc> pumvisible() ? "\<C-e>" : "\<Esc>"
"inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
inoremap <expr> <C-d> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<C-d>"
inoremap <expr> <C-u> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<C-u>"
" Automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set complete-=i
set complete-=t
set completeopt=menu
" }
" PDV {
let g:pdv_template_dir = $HOME ."/.vim/custom-snippets/pdv"
nnoremap <leader>pd :call pdv#DocumentWithSnip()<CR>
" }
" phpComplete {
let g:phpcomplete_enhance_jump_to_definition = 1
let g:phpcomplete_parse_docblock_comments = 1
"extended {
"autocmd FileType php setlocal omnifunc=phpcomplete_extended#CompletePHP
let g:phpcomplete_index_composer_command='composer'
" }
" }
" phpcd {
" Auto restart the deamon after every buffer switch
let g:phpcd_auto_restart=1
" }
" php-cs-fixer {
" use ,pcd for PhpCsFixerFixDirectory and ,pcf for PhpCsFixerFixFile
"let g:php_cs_fixer_level = "psr12" " which level ? Deprecated?
let g:php_cs_fixer_config = "default" " configuration
let g:php_cs_fixer_rules = "@Symfony" " options: --rules (default:@PSR2)
let g:php_cs_fixer_php_path = "php" " Path to PHP
" If you want to define specific fixers:
" let g:php_cs_fixer_fixers_list = "linefeed,short_tag,indentation" " deprecated?
let g:php_cs_fixer_enable_default_mapping = 1 " Enable the mapping by default (<leader>pcd)
let g:php_cs_fixer_dry_run = 0 " Call command with dry-run option
let g:php_cs_fixer_verbose = 1 " Return the output of command if 1, else an inline information.
" }
" phpfolding.vim {
let g:DisableAutoPHPFolding = 1
"map <F5> <Esc>:EnableFastPHPFolds<Cr>
map <F6> <Esc>:EnablePHPFolds<Cr>
map <F7> <Esc>:DisablePHPFolds<Cr>
" }
" PHPMAN {
" (my own, PIV is too heavy, don't need folding, syntax (7.4
" includes syntax, etc)
" Set help for php files properyly
autocmd FileType php set kp=:help
autocmd FileType php.wordpress set kp=:help
" }
" PyMode {
let g:pymode_lint_checker = "pyflakes"
let g:pymode_utils_whitespaces = 0
let g:pymode_options = 0
" }
" PhpNamespace {
let g:php_namespace_sort_after_insert = 1
autocmd FileType php noremap <Leader>ni :call PhpInsertUse()<CR>
autocmd FileType php noremap <Leader>ne :call PhpExpandClass()<CR>
" }
" PythonMode {
" Disable if python support not present
if !has('python')
let g:pymode = 1
endif
" }
" Rainbow {
let g:rainbow_active=0
noremap <Leader>R :RainbowToggle<Cr>
" }
" Surround {
" yss- = php tags
autocmd FileType php let b:surround_45 = "<?php \r ?>"
" }
" syntastic {
let g:syntastic_check_on_open=0
let g:syntastic_auto_jump=0
let g:syntastic_auto_loc_list=1
" typescript {
let g:tsuquyomi_disable_quickfix = 1
let g:tsuquyomi_disable_default_mappings = 1
let g:syntastic_typescript_checkers=['tsuquyomi', 'eslint']
let g:syntastic_javascript_eslint_exec = 'eslint_d'
autocmd FileType typescript nnoremap <buffer> <C-]> :YcmCompleter GoTo<CR>
" }
" javascript {
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_javascript_eslint_exec = 'eslint_d'
" }
" SCSS {
" Doesn't seem to work with sassc for some reason, use sass for now
" remember:
" sudo apt-get install ruby-dev
" sudo gem install --no-user-dir compass
let g:syntastic_scss_scss_sass_exe="/usr/local/bin/sass"
let g:syntastic_scss_scss_lint_exe="/usr/local/bin/scss-lint"
let g:syntastic_scss_checkers=['scss_lint', 'sass']
let g:syntastic_scss_error_checkers = ['sass']
let g:syntastic_scss_syntax_checkers = ['scss_lint', 'sass']
" }
" PHP {
let g:syntastic_php_phpcs_args="--standard=PSR12"
let g:syntastic_php_phpmd_post_args="~/.phpmd/ruleset.xml"
let g:syntastic_php_phpstan_args="--level=0"
let g:syntastic_php_checkers = ['php', 'phpstan', 'phpcs', 'phpmd']
let g:syntastic_php_error_checkers = ['php', 'phpstan']
let g:syntastic_php_syntax_checkers = ['php', 'phpstan', 'phpcs', 'phpmd']
let g:syntastic_wordpress_checkers = ['php']
let g:syntastic_syntax_mode = 0
" }
let g:syntastic_mode_map = { 'mode': 'active',
\ 'active_filetypes': [],
\ 'passive_filetypes': [] }
nmap <Leader>sc :SyntasticCheck<CR>