-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
907 lines (756 loc) · 25.2 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
" {{{ Init
set encoding=utf-8
" }}}
"Plugins
" set rtp+=~/.vim/bundle/Vundle.vim
call plug#begin()
Plug 'Lokaltog/vim-easymotion' "Easily move around
Plug 'Valloric/MatchTagAlways' "A Vim plugin that always highlights the enclosing html/xml tags
Plug 'airblade/vim-gitgutter' "Git in the gutter
Plug 'airblade/vim-rooter' "Changes Vim working directory to project root
Plug 'austintaylor/vim-commaobject' "Add comma as a Vim object
Plug 'chaoren/vim-wordmotion' "More useful word motions for Vim
Plug 'chrisbra/Colorizer' "Colorizes hex codes
Plug 'christoomey/vim-sort-motion' "Vim mapping for sorting a range of text
Plug 'christoomey/vim-tmux-navigator' "Seamless navigation between tmux panes and vim splits
Plug 'christoomey/vim-tmux-runner' "Vim and tmux, sittin' in a tree...
Plug 'github/copilot.vim' "GitHub copilot
Plug 'godlygeek/tabular' "Vim script for text filtering and alignment
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'junegunn/vim-easy-align' "A Vim alignment plugin
Plug 'kkoomen/vim-doge', { 'do': { -> doge#install() } }
Plug 'lisposter/vim-blackboard' "Color scheme
Plug 'majutsushi/tagbar' "Vim plugin that displays tags in a window, ordered by scope.
Plug 'mattn/emmet-vim' "Emmet for vim: http://emmet.io/
Plug 'mileszs/ack.vim' "Ack search
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'sainnhe/sonokai'
Plug 'scrooloose/nerdcommenter' "Vim plugin for intensely orgasmic commenting.
Plug 'sheerun/vim-polyglot' "A solid language pack for Vim.
Plug 'spktklr/vim-flip-comparands' "Flip two comparands around a comparison operator in Vim
Plug 'styled-components/vim-styled-components', { 'branch': 'main' } "Vim bundle for http://styled-components.com based javascript files.
Plug 'terrastruct/d2-vim'
Plug 'terryma/vim-expand-region' "Vim plugin that allows you to visually select increasingly larger regions of text using the same key combination
Plug 'tomtom/tlib_vim' "Some utility functions for VIM
Plug 'tpope/vim-abolish' "Easily search for, substitute, and abbreviate multiple variants of a word
Plug 'tommcdo/vim-fubitive' "Extend fugitive.vim to support Bitbucket URLs in :Gbrowse.
Plug 'tpope/vim-fugitive' "A git wrapper so awesome, it should be illegal
Plug 'tpope/vim-repeat' "repeat.vim: enable repeating supported plugin maps with '.'
Plug 'tpope/vim-surround' "Quoting/parenthesizing made simple.
Plug 'tyru/open-browser.vim' "Open URI with your favorite browser from your most favorite editor
Plug 'vim-airline/vim-airline' "Lean & mean status/tabline for vim that's light as air
Plug 'rebelot/kanagawa.nvim' "A colorscheme for neovim
call plug#end()
filetype plugin indent on " ensure ftdetect et al work by including this after the Vundle stuff
"
" AutoGroups {{{
augroup configgroup
autocmd!
autocmd VimEnter * highlight clear SignColumn
autocmd BufWritePre *.php,*.py,*.js,*.txt,*.hs,*.java,*.md,*.rb :call <SID>StripTrailingWhitespaces()
autocmd BufEnter *.cls setlocal filetype=java
autocmd BufEnter *.zsh-theme setlocal filetype=zsh
" autocmd BufEnter Makefile setlocal noexpandtab
autocmd BufEnter *.sh setlocal tabstop=2
autocmd BufEnter *.sh setlocal shiftwidth=2
autocmd BufEnter *.sh setlocal softtabstop=2
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o " do not comment new lines automatically
" Automatically fmt styles on save
autocmd BufWritePre,FileWritePre *.css,*.less,*.scss,*.sass silent! :Stylefmt<CR>
" Disabled due to intelephense not detecting files if they are not just 'php':
" autocmd BufRead,BufNewFile *.php set ft=php.wordpress "use wordpress snippets on php files
" autocmd BufRead,BufNewFile *.php set ft=php "use wordpress snippets on php files
"set undofile " Contains undo information so you can undo previous actions even after you close and reopen a file.
augroup END
" }}}
" Colors {{{
syntax on
set termguicolors
if !has("gui_running")
" let &t_AB="\e[48;5;%dm"
" let &t_AF="\e[38;5;%dm"
" set background=dark
if !has('nvim')
colorscheme blackboard
else
colorscheme kanagawa-wave
" vim.cmd("colorscheme kanagawa-dragon")
endif
else
" set background=dark
if !has('nvim')
colorscheme blackboard
else
colorscheme kanagawa
endif
endif
" Color scheme customizations
" hi CursorLine ctermbg=LightBlue
hi SpecialKey term=bold cterm=bold ctermbg=0
hi MatchParen cterm=bold ctermbg=none ctermfg=magenta
" }}}
" Misc {{{
set ttyfast " faster redraw
set backspace=indent,eol,start
set hidden " hides buffers instead of closing them
set history=1000 " remember more commands and search history
set undolevels=1000 " use many muchos levels of undo
" Some servers have issues with backup files
set nobackup
set nowritebackup
"
set cmdheight=2 " Better display for messages
set updatetime=300 " Smaller updatetime for CursorHold & CursorHoldI
set shortmess+=c " don't give |ins-completion-menu| messages.
set signcolumn=yes " always show signcolumns
set noswapfile
set linebreak
set scrolloff=5
set autochdir " auto cd to current file folder
set conceallevel=1 "concealing
" }}}
" Spaces & Tabs {{{
set tabstop=2
set softtabstop=2
set shiftwidth=2
" }}}
" UI Layout {{{
set number " show line numbers
set showcmd " show command in bottom bar
set ruler " show the cursor position all the time
set nocursorline " highlight current line
set wildmenu
"set lazyredraw
set showmatch " higlight matching parenthesis
set list " show invisible chars
"set listchars=tab:?\ ,eol:¬ " map invisible chars
set listchars=tab:\ \ ,trail:·,eol:¬,nbsp:_
set mouse=a " enable mouse (for scrolling)
if !has("gui_running") " let mouse wheel scroll file contents
set mouse=a
set nocompatible
inoremap <Esc>[62~ <C-X><C-E>
inoremap <Esc>[63~ <C-X><C-Y>
nnoremap <Esc>[62~ <C-E>
nnoremap <Esc>[63~ <C-Y>
endif
if has('gui_running')
set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
set guioptions-=L "remove left-hand scroll bar
set lines=60 columns=108 linespace=0
if has('gui_win32')
"set encoding=utf-8
"set guifont=Powerline_Consolas:h11
set guifont=hack:h10
else
" set encoding=utf-8
" set guifont=Consolas:h14
set macligatures
set guifont=Fira\ Code:h16
endif
endif
" cursor for gvim
highlight Cursor guifg=black guibg=green
highlight iCursor guifg=green guibg=steelblue
set guicursor=n-v-c:block-Cursor
set guicursor+=i:ver100-iCursor
set guicursor+=n-v-c:blinkon0
set guicursor+=i:blinkwait10
" }}}
" Searching {{{
nnoremap / /\v
vnoremap / /\v
set ignorecase
set smartcase
set incsearch
set showmatch
set hlsearch
vnoremap <C-r> "hy:%s/<C-r>h//g<left><left>
vnoremap - -
vnoremap -- y/<C-R>"<CR>"
" }}}
" Folding {{{
set foldmethod=marker
set foldlevel=0
set modelines=1
nnoremap <space> za
" }}}
" Mappings {{{
nnoremap <Left> :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>
nnoremap <Tab> >>
nnoremap <s-Tab> <<
vnoremap <tab> >
" Use CTRL-S for saving, also in Insert mode
noremap <C-S> :update!<CR><Esc>
vnoremap <C-S> <C-C>:update!<CR><Esc>
inoremap <C-S> <C-O>:update!<CR><Esc>
" Visual Block Mode
nnoremap <C-x> <C-v>
" Copy & Paste from clipboard
vnoremap <C-c> "*y
nnoremap <C-v> :set paste<CR>"*p :set nopaste<CR>
inoremap <C-v> <Esc>:set paste<CR>"*p:set nopaste<CR>i
" Undo
noremap <C-z> :u<cr>
" fzf
noremap <C-p> :GFiles .<CR>
noremap <C-b> :Buffers<CR>
" Insert rows without insert mode
nmap <C-Enter> O<Esc>j
nmap <S-Enter> O<Esc>j
nmap <CR> o<Esc>k
nnoremap • :silent norm @q<cr>
nnoremap j gj
nnoremap k gk
nnoremap B ^
nnoremap E $
nnoremap $ <nop>
nnoremap ^ <nop>
nnoremap gV `[v`]
onoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
xnoremap an :<c-u>call <SID>NextTextObject('a', 'f')<cr>
onoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>
xnoremap in :<c-u>call <SID>NextTextObject('i', 'f')<cr>
onoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
xnoremap al :<c-u>call <SID>NextTextObject('a', 'F')<cr>
onoremap il :<c-u>call <SID>NextTextObject('i', 'F')<cr>
xnoremap il :<c-u>call <SID>NextTextObject('i', 'F')<cr>
" Easy navigation between splits. Instead of ctrl-w + j. Just ctrl-j
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>
"Edit scandi layout
" inoremap Ä <C-R>=AutoPairsInsert("\}")<CR>
" inoremap Ö <C-R>=AutoPairsInsert("\{")<CR>
" inoremap ä <C-R>=AutoPairsInsert("\]")<CR>
" inoremap ö <C-R>=AutoPairsInsert("\[")<CR>
nnoremap " @
nnoremap & ^
nnoremap ' \
nnoremap ( *
nnoremap ) (
" nnoremap * | " Causes mapping not found error
nnoremap + -
nnoremap - /
nnoremap / &
nnoremap = )
nnoremap ? _
nnoremap ^ }
nnoremap _ ?
nnoremap ` +
nnoremap § ~
nnoremap ¨ ]
nnoremap ´ =
nnoremap ½ `
nnoremap Ä }
nnoremap Ö {
nnoremap ä ]
nnoremap ö [
noremap ¤ $
noremap € $
vnoremap Ä }
vnoremap Ö {
vnoremap ä ]
vnoremap ö [
" }}}
" Leader mappings {{{
let mapleader=","
nnoremap <leader>1 :set number!<CR>
nnoremap <leader><space> :noh<CR>
nnoremap <silent> <space>y :<C-u>CocList -A --normal yank<cr>
nnoremap <leader>a :Ag
nnoremap <leader>r :Rg
" Search the WP Codex with WordPress Vim
nnoremap <leader>co :Wcodexsearch<CR>
" nnoremap <leader>dj :JsDoc<CR>
" type :e and pre-populate with dir of current file
nnoremap <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
nnoremap <leader>el :!el % --fix<CR>
nnoremap <leader>ev :vsp $MYVIMRC<CR>
nnoremap <leader>ez :vsp ~/.zshrc<CR>
nnoremap <leader>g :call RunGoFile()<CR>
nnoremap <leader>h :A<CR>
" Re-indents buffer.
nnoremap <silent><Leader>i :call Preserve("normal! gg=G")<CR>
nnoremap <leader>m :silent make\|redraw!\|cw<CR>
" Removes all trailing whitespace in buffer.
nnoremap <silent><Leader>o :call Preserve("%s/\\s\\+$//e")<CR>
nnoremap <leader>pp :!phpcbf % --standard=WordPress-Core<CR>
"nnoremap <leader>S ?{<CR>jV/^\s*\}?$<CR>k:sort<CR>:noh<CR> "sort CSS
nnoremap <leader>s :mksession<CR>
nnoremap <leader>sv :source $MYVIMRC<CR>
nnoremap <leader>t :call ToggleNumber()<CR>
nnoremap <leader>u :call IndentHtmlPhp()<CR>
vnoremap <leader>y "+y
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR> "strip all trailing whitespace
nnoremap <leader>v V`] "reselect the text just pasted
nnoremap <leader>q :q<CR>
" Sort SCSS
"nnoremap <F7> :g#\({\n\)\@<=#.,/\.*[{}]\@=/-1 sort
vnoremap <Leader>a y:Ag <C-r>=fnameescape(@")<CR><CR>
vnoremap <Leader>r y:Rg <C-r>=fnameescape(@")<CR><CR>
vmap v <Plug>(expand_region_expand)
vmap <C-v> <Plug>(expand_region_shrink)
vmap <Leader>y "+y
vmap <Leader>d "+d
" nmap <Leader>p "+p
nmap <Leader>P "+P
" vmap <Leader>p "+p
vmap <Leader>P "+P
" To open a new empty buffer
nnoremap <leader>T :enew<cr>
" Move to the next buffer
nnoremap <leader>l :bnext<CR>
" Move to the previous buffer
nnoremap <leader>h :bprevious<CR>
" Close the current buffer and move to the previous one
nnoremap <leader>w :bp <BAR> bd #<CR>
" }}}
" Ack {{{
let g:ackprg = 'ag --nogroup --nocolor --column'
" let g:ag_working_path_mode="r"
" Use instead of Grep
" if executable('ag')
" Note we extract the column as well as the file and line number
" let g:ackprg = 'ag --vimgrep'
" set grepprg=ag\ --nogroup\ --nocolor\ --column
" set grepformat=%f:%l:%c%m
" endif
" }}}
" PHP {{{
let g:PHP_vintage_case_default_indent = 1
" }}}
" JSX {{{
let g:jsx_ext_required = 0 " Allow JSX in normal JS files
" }}}
" Tmux {{{
let g:tmux_navigator_no_mappings = 1
nnoremap <silent> <c-h> :TmuxNavigateLeft<cr>
nnoremap <silent> <c-j> :TmuxNavigateDown<cr>
nnoremap <silent> <c-k> :TmuxNavigateUp<cr>
nnoremap <silent> <c-l> :TmuxNavigateRight<cr>
nnoremap <silent> <c-\> :TmuxNavigatePrevious<cr>
"" }}}
" Backups {{{
set backup
set backupdir=~/.vim-tmp,~/.tmp,~/tmp,/var/tmp,/tmp
set backupskip=/tmp/*,/private/tmp/*
set directory=.,$TEMP
set writebackup
" }}}
" Intelephense {{{
" if executable('intelephense')
" augroup LspPHPIntelephense
" au!
" au User lsp_setup call lsp#register_server({
" \ 'name': 'intelephense',
" \ 'cmd': {server_info->[&shell, &shellcmdflag, 'intelephense --stdio']},
" \ 'whitelist': ['php'],
" \ 'initialization_options': {'storagePath': '/tmp/intelephense'},
" \ 'workspace_config': {
" \ 'intelephense': {
" \ 'files': {
" \ 'maxSize': 1000000,
" \ 'associations': ['*.php', '*.phtml'],
" \ 'exclude': [],
" \ },
" \ 'completion': {
" \ 'insertUseDeclaration': v:true,
" \ 'fullyQualifyGlobalConstantsAndFunctions': v:false,
" \ 'triggerParameterHints': v:true,
" \ 'maxItems': 100,
" \ },
" \ 'format': {
" \ 'enable': v:false
" \ },
" \ },
" \ }
" \})
" augroup END
" endif
" }}}
" {{{ Plugin ALE
"
let g:airline#extensions#ale#enabled = 1
let g:ale_linters_explicit = 1
" \ 'javascript': ['eslint', 'prettier', 'flow-language-server'],
" \ 'json': ['prettier', 'eslint'],
" \ 'jsx': ['stylelint', 'eslint'],
" \ 'scss': ['stylelint', 'eslint'],
" \ 'yaml': ['yamllint', 'prettier'],
" \ 'php': ['intelephense', 'phpcs'],
let g:ale_linters = {
\ 'php': ['phpcs'],
\}
" \ 'javascript': ['prettier', 'eslint'],
\ 'javascript': [],
" \ 'json': ['prettier', 'eslint'],
" \ 'scss': ['prettier'],
" \ 'css': ['prettier'],
" \ 'sass': ['prettier'],
" \ 'yaml': ['prettier'],
let g:ale_fixers = {
\ 'php': ['phpcbf'],
\}
let g:ale_php_phpcs_standard = '/Users/nm/projects/enervent/phpcs.xml'
let g:ale_fix_on_save = 1
let g:ale_linter_aliases = {'jsx': 'css'}
" let g:ale_php_phpcbf_standard = 'PHPNM'
" let g:ale_php_phpcs_standard = 'PHPNM'
" let g:ale_php_phpcbf_use_global = 1
" let g:ale_php_phpcs_use_global = 1
let g:ale_sign_column_always = 1
let g:ale_cache_executable_check_failures = 1
" }}}
" Plugin Airline {{{
set laststatus=2
set ttimeoutlen=50
let g:airline#extensions#tabline#enabled = 1 " Enable the list of buffers
let g:airline#extensions#tabline#fnamemod = ':t' " Show just the filename
" Don't show seperators
let g:airline_left_sep=''
let g:airline_right_sep=''
" }}}
" Plugin Autopairs {{{
" let g:AutoPairsShortcutFastWrap=''
" }}}
" {{{ Plugin Colorizer
:let g:colorizer_auto_color = 1
" }}}
" {{{ Plugin Coc
set updatetime=300
set shortmess+=c
"For scss files, you may need use:
autocmd FileType scss setl iskeyword+=@-@
"in your vimrc for add @ to iskeyword option.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
inoremap <silent><expr> <C-x><C-z> coc#pum#visible() ? coc#pum#stop() : "\<C-x>\<C-z>"
" remap for complete to use tab and <cr>
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1):
\ <SID>check_back_space() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
inoremap <silent><expr> <c-space> coc#refresh()
hi CocSearch ctermfg=12 guifg=#18A3FF
hi CocMenuSel ctermbg=109 guibg=#13354A
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
let g:coc_snippet_next = '<tab>'
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh()
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current
" position. Coc only does snippet and additional edit on confirm.
if has('patch8.1.1068')
" Use `complete_info` if your (Neo)Vim version supports it.
inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
else
imap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
endif
" Use `[g` and `]g` to navigate diagnostics
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)
" GoTo code navigation.
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0)
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight the symbol and its references when holding the cursor.
autocmd CursorHold * silent call CocActionAsync('highlight')
" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)
" Formatting selected code.
xmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
augroup mygroup
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Update signature help on jump placeholder.
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Applying codeAction to the selected region.
" Example: `<leader>aap` for current paragraph
" xmap <leader>a <Plug>(coc-codeaction-selected)
" nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap keys for applying codeAction to the current line.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
" Introduce function text object
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap if <Plug>(coc-funcobj-i)
omap af <Plug>(coc-funcobj-a)
" Use <TAB> for selections ranges.
" NOTE: Requires 'textDocument/selectionRange' support from the language server.
" coc-tsserver, coc-python are the examples of servers that support it.
nmap <silent> <TAB> <Plug>(coc-range-select)
xmap <silent> <TAB> <Plug>(coc-range-select)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format')
" Add `:Fold` command to fold current buffer.
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" Add `:OR` command for organize imports of the current buffer.
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
" Add (Neo)Vim's native statusline support.
" NOTE: Please see `:h coc-status` for integrations with external plugins that
" provide custom statusline: lightline.vim, vim-airline.
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
" Mappings using CoCList:
" Show all diagnostics.
nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" Manage extensions.
nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
" Show commands.
nnoremap <silent> <space>c :<C-u>CocList commands<cr>
" Find symbol of current document.
nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" Search workspace symbols.
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
" Do default action for next item.
nnoremap <silent> <space>j :<C-u>CocNext<CR>
" Do default action for previous item.
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
" Resume latest coc list.
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
" instead of having ~/.vim/coc-settings.json
let s:LSP_CONFIG = {
\ 'flow': {
\ 'command': exepath('flow'),
\ 'args': ['lsp'],
\ 'filetypes': ['javascript', 'javascriptreact'],
\ 'initializationOptions': {},
\ 'requireRootPattern': 1,
\ 'settings': {},
\ 'rootPatterns': ['.flowconfig']
\ }
\}
let s:languageservers = {}
for [lsp, config] in items(s:LSP_CONFIG)
let s:not_empty_cmd = !empty(get(config, 'command'))
if s:not_empty_cmd | let s:languageservers[lsp] = config | endif
endfor
if !empty(s:languageservers)
call coc#config('languageserver', s:languageservers)
endif
" }}}
" Plugin CtrlP {{{
" let g:ctrlp_root_markers = ['.ctrlp']
" let g:ctrlp_show_hidden = 1
" let g:ctrlp_match_window = 'bottom,order:ttb'
" let g:ctrlp_switch_buffer = 'Et'
" let g:ctrlp_working_path_mode = 'r'
" let g:ctrlp_custom_ignore = '\v[\/](node_modules|.next|vagrant|build|wp-includes|wp-admin|vendor|target)|(\.(swp|ico|svn|DS_Store|ctrlp))$'
" let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
" }}}
" Plugin Easy-Align {{{
" Start interactive EasyAlign in visual mode (e.g. vip<Enter>)
vmap <Enter> <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
if !exists('g:easy_align_delimiters')
let g:easy_align_delimiters = {}
endif
let g:easy_align_delimiters['d'] = {
\ 'pattern': '(@\w+|string|int|mixed|array|\$\w+|\d+.*|[A-Z].+\.)',
\ 'left_margin': 0, 'right_margin': 0
\ }
" }}}
" Plugin EditorConfig {{{
let g:EditorConfig_exclude_patterns = ['fugitive://.*']
" }}}
" {{{ Plugin Emmet-vim
let g:user_emmet_settings = {
\ 'javascript.jsx' : {
\ 'extends' : 'jsx',
\ },
\}
" }}}
" Plugin Gitgutter {{{
let g:gitgutter_max_signs = 500
" }}}
" Plugin javascript {{{
let g:javascript_plugin_jsdoc = 1
let g:jsdoc_additional_descriptions = 1
let g:jsdoc_allow_input_prompt = 1
let g:jsdoc_enable_es6 = 1
let g:jsdoc_input_description = 1
let g:jsdoc_return_description = 1
let g:jsdoc_return_type = 1
let g:jsdoc_underscore_private = 1
let g:jsdoc_lehre_path = '/usr/local/lib/node_modules/lehre/bin/lehre'
" }}}
" Plugin Mustache-Handlebars {{{
let g:mustache_abbreviations = 1
" }}}
" Plugin NERDCommenter {{{
let NERDSpaceDelims=1
" }}}
" Plugin NERDTree / coc-explorer {{{
" let g:NERDTreeWinSize = 40
" let NERDTreeIgnore = ['\.pyc$', 'venv', 'egg', 'egg-info/', 'DS_Store']
" let NERDTreeShowHidden=1
" Toggle nerdtree with F10
" noremap <F10> :NERDTreeToggle<CR>
nmap <F10> :CocCommand explorer<CR>
" noremap <F11> :NERDTree<CR>
" Current file in nerdtree
" noremap <F9> :NERDTreeFind<CR>
" }}}
" Plugin php-doc-modded {{{
" nnoremap <leader>dp :call PhpDocSingle()<CR>
" }}}
" Plugin Tabularize {{{
nnoremap <leader>pt :Tabularize/@\w\+\s\+\zs\S\+\\|\%(@\w\+.*\)\@<=\u.*/<CR>
" }}}
" Plugin Tagbar {{{
nnoremap <F8> :TagbarToggle<CR>
" }}}
" Custom Functions {{{
" Toggle mouse plugin for quickly toggling mouse between Vim and terminal
" Maintainer: Vincent Driessen <[email protected]>
" Version: Vim 7 (may work with lower Vim versions, but not tested)
" URL: http://github.com/nvie/vim-togglemouse
"
" Only do this when not done yet for this buffer
if exists("b:loaded_toggle_mouse_plugin")
finish
endif
let b:loaded_toggle_mouse_plugin = 1
fun! s:ToggleMouse()
if !exists("s:old_mouse")
let s:old_mouse = "a"
endif
if &mouse == ""
let &mouse = s:old_mouse
echo "Mouse is for Vim (" . &mouse . ")"
else
let s:old_mouse = &mouse
let &mouse=""
echo "Mouse is for terminal"
endif
endfunction
" Add mappings, unless the user didn't want this.
" The default mapping is registered under to <F12> by default, unless the user
" remapped it already (or a mapping exists already for <F12>)
if !exists("no_plugin_maps") && !exists("no_toggle_mouse_maps")
if !hasmapto('<SID>ToggleMouse()')
noremap <F12> :call <SID>ToggleMouse()<CR>
inoremap <F12> <Esc>:call <SID>ToggleMouse()<CR>a
endif
endif
" Toggle relative line numbers.
function! ToggleNumber()
if(&relativenumber == 1)
set norelativenumber
set number
else
set relativenumber
endif
endfunction
" strips trailing whitespace at the end of files. this
" is called on buffer write in the autogroup above.
function! <SID>StripTrailingWhitespaces()
" save last search & cursor position
let _s=@/
let l = line(".")
let c = col(".")
%s/\s\+$//e
let @/=_s
call cursor(l, c)
endfunction
function! <SID>CleanFile()
" Preparation: save last search, and cursor position.
let _s=@/
let l = line(".")
let c = col(".")
" Do the business:
%!git stripspace
" Clean up: restore previous search history, and cursor position
let @/=_s
call cursor(l, c)
endfunction
" indents file
function! IndentFile()
let l:winview = winsaveview()
exec "normal gg=G"
call winrestview(l:winview)
endfunction
" A wrapper function to restore the cursor position, window position,
" and last search after running a command.
function! Preserve(command)
" Save the last search
let last_search=@/
" Save the current cursor position
let save_cursor = getpos(".")
" Save the window position
normal H
let save_window = getpos(".")
call setpos('.', save_cursor)
" Do the business:
execute a:command
" Restore the last_search
let @/=last_search
" Restore the window position
call setpos('.', save_window)
normal zt
" Restore the cursor position
call setpos('.', save_cursor)
endfunction
function! IndentHtmlPhp()
" Save the last search
let last_search=@/
" Save the current cursor position
let save_cursor = getpos(".")
" Save the window position
normal H
let save_window = getpos(".")
call setpos('.', save_cursor)
execute "normal! :set ft=html\<CR>"
execute "normal! gg=G"
execute "normal! :set ft=php\<CR>"
execute "normal! gg=G"
" Restore the last_search
let @/=last_search
" Restore the window position
call setpos('.', save_window)
normal zt
" Restore the cursor position
call setpos('.', save_cursor)
endfunction
function! s:NextTextObject(motion, dir)
let c = nr2char(getchar())
if c ==# "b"
let c = "("
elseif c ==# "B"
let c = "{"
elseif c ==# "r"
let c = "["
endif
exe "np all trailing whitespaceormal! ".a:dir.c."v".a:motion.c
endfunction
" }}}