-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_vimrc.tmpl
837 lines (693 loc) · 19.9 KB
/
dot_vimrc.tmpl
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
set nocompatible
" -----VIM-PLUG-----
" Install vim-plug automatically
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
augroup vimPlugInstall
autocmd!
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
augroup end
endif
" PLUGINS
call plug#begin('~/.vim/bundle')
if !has('nvim')
" vim-sensible - ONLY for vim
Plug 'tpope/vim-sensible'
endif
if !has('nvim-0.9')
" editorconfig is built-in as of nvim 0.9
Plug 'editorconfig/editorconfig-vim'
endif
if has('nvim')
" treesitter works only with nvim
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
endif
Plug 'airblade/vim-gitgutter'
Plug 'alvan/vim-closetag'
Plug 'arnaud-lb/vim-php-namespace'
Plug 'dense-analysis/ale'
Plug 'djoshea/vim-autoread'
Plug 'dyng/ctrlsf.vim'
Plug 'easymotion/vim-easymotion'
Plug 'gregsexton/matchtag'
Plug 'haya14busa/incsearch-easymotion.vim'
Plug 'haya14busa/incsearch.vim'
Plug 'haya14busa/vim-asterisk'
Plug 'honza/vim-snippets'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
Plug 'itchyny/lightline.vim'
Plug 'jiangmiao/auto-pairs'
Plug 'jlanzarotta/bufexplorer'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'junegunn/gv.vim'
Plug 'ludovicchabant/vim-gutentags'
Plug 'majutsushi/tagbar'
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'mattn/emmet-vim'
Plug 'maximbaz/lightline-ale'
Plug 'mbbill/undotree'
Plug 'mg979/vim-visual-multi'
Plug 'mileszs/ack.vim'
Plug 'nelsyeung/twig.vim'
Plug 'neoclide/coc.nvim', { 'branch': 'release' }
Plug 'preservim/nerdcommenter'
Plug 'qpkorr/vim-bufkill'
Plug 'scrooloose/nerdtree'
Plug 'SirVer/ultisnips'
Plug 'svermeulen/vim-subversive'
Plug 'svermeulen/vim-yoink'
Plug 'szw/vim-maximizer'
Plug 'tommcdo/vim-lion'
Plug 'tomtom/tlib_vim'
Plug 'towolf/vim-helm'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-markdown'
Plug 'tpope/vim-obsession'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-vinegar'
Plug 'vim-php/tagbar-phpctags.vim'
Plug 'vim-scripts/tinykeymap'
" COC extensions
Plug 'clangd/coc-clangd', {'do': 'yarn install --frozen-lockfile'}
Plug 'fannheyward/coc-pyright', {'do': 'yarn install --frozen-lockfile'}
Plug 'iamcco/coc-svg', {'do': 'yarn install --frozen-lockfile'}
Plug 'iamcco/coc-tailwindcss', {'do': 'yarn install --frozen-lockfile && yarn run build'}
Plug 'josa42/coc-go', {'do': 'yarn install --frozen-lockfile'}
Plug 'josa42/coc-sh', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-css', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-emmet', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-eslint', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-html', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-stylelint', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-tsserver', {'do': 'yarn install --frozen-lockfile'}
" Plug 'neoclide/coc-vetur', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-yaml', {'do': 'yarn install --frozen-lockfile'}
Plug 'yaegassy/coc-intelephense', {'do': 'yarn install --frozen-lockfile'}
Plug 'yaegassy/coc-volar', {'do': 'yarn install --frozen-lockfile'}
" COLORSCHEMES
Plug 'crusoexia/vim-monokai'
Plug 'gosukiwi/vim-atom-dark'
Plug 'joshdick/onedark.vim'
Plug 'morhetz/gruvbox'
Plug 'romainl/Apprentice'
call plug#end()
" vim-sensible
" Apply configs from vim-sensible
if !has('nvim')
runtime! plugin/sensible.vim
endif
" -----GENERAL-----
" The default leader is a backslash, but we use ','
" let mapleader = ','
set encoding=UTF-8
" Fix backspace key"
set backspace=indent,eol,start
" Set language for spell check
setlocal spell spelllang=en_us
set spell
" Fixing tabs and indentation
set autoindent
set copyindent
set noexpandtab
set preserveindent
set softtabstop=0
" Case-insensitive tab completion
set wildignorecase
" Make scrolling faster and more accurate
set ttyfast
" Refresh buffer automatically
set autoread
" Use system clipboard
set clipboard=unnamedplus
" Add mouse support
set mouse=a
" Suppress warning when changing FROM unsaved buffer
set hidden
" Demand explicit confirmation when closing unsaved buffers
set confirm
" Deactivate folding
set nofoldenable
set foldmethod=syntax
" Don't use swapfiles
set noswapfile
" Don't change default cursor
" Kudos @binaryreverse https://github.com/neovim/neovim/issues/6005
set guicursor=
" Disable some unused provider
let g:loaded_python_provider = 0
let g:loaded_perl_provider = 0
" -----MAPPINGS-----
" Quick edit ~/.vimrc
nmap <silent> <leader>ev :e $MYVIMRC<CR>
" Toggle Spell check
nnoremap <leader>s :set spell!<CR>:set spell?<CR>
" Tab navigation
nnoremap <leader>tab :tabnew<space>
nnoremap <silent> <leader>w :tabclose<CR>
nnoremap <silent> <leader>tabthis :tabnew %<CR>:tabprevious<CR>
" Better navigation with wrapped lines
noremap <silent> k gk
noremap <silent> j gj
noremap <silent> 0 g0
noremap <silent> $ g$
" Fix whitespace errors
nnoremap <leader>fwe :%s/^ //g<CR>:nohlsearch<CR>
" Unexpand 4 spaces to tab
nnoremap <leader>uex :%s/ /\t/g<CR>:nohlsearch<CR>
" Don't yank selected text after overwriting via paste
vnoremap <silent> p "_dP
" Move lines up and down in visual mode
vnoremap <silent> <C-J> :m '>+1<CR>gv
vnoremap <silent> <C-K> :m '<-2<CR>gv
" (Un-)Indent lines and preserve selection
vnoremap <silent> < <<CR>gv
vnoremap <silent> > ><CR>gv
" Toggle relative line numbers
nnoremap <silent> <leader>r :set relativenumber!<CR>:set relativenumber?<CR>
vnoremap <silent> <leader>r <ESC>:set relativenumber!<CR>gv
" Toggle folding
nnoremap <leader>f :set foldenable!<CR>:set foldenable?<CR>
" Sudo write
cmap w!! w !sudo tee > /dev/null %
" -----AUTO-COMMANDS-----
augroup generalAutocmd
autocmd!
autocmd BufEnter * :syntax sync fromstart
augroup end
" -----FUNCTIONS-----
function! s:DiffWithSaved()
let filetype=&ft
diffthis
vnew | r # | normal! 1Gdd
diffthis
exe "setlocal bt=nofile bh=wipe nobl noswf ro ft=" . filetype
endfunction
com! DiffSaved call s:DiffWithSaved()
" -----PLUGIN CONFIGURATION-----
if !has('nvim-0.9')
" editorconfig is built-in as of nvim v0.9
" editorconfig
" Show visual mark, depending on max_line_length value
let g:EditorConfig_verbose = 1
let g:EditorConfig_max_line_indicator = "line"
let g:EditorConfig_enable_for_new_buf = 1
let g:EditorConfig_preserve_formatoptions = 1
let g:EditorConfig_exclude_patterns = [
\ '.*\.diff',
\ '.*\.patch',
\ ]
else
" Neovim v0.9 and above specific config
"
" set colorcolumn explicitly, so the ruler of max_line_indicator gets
" displayed
set colorcolumn=+1
endif
" NERDTree
let NERDTreeShowHidden = 1
nnoremap <silent> <leader>d :NERDTreeToggle<CR>
nnoremap <silent> <leader>D :NERDTreeFind<CR>
let NERDTreeIgnore = [
\ '\~$',
\ '\.sw[op]$',
\'\.\=tags$', '^\.tags\.\(lock\|temp\)$',
\ '^Session.vim',
\ '^.git$[[dir]]',
\ ]
" fzf
nnoremap <silent> <C-P> :Files<CR>
nnoremap <silent> <leader>cwdp :Files <C-R>=expand('%:p:h') . '/'<CR><CR>
nnoremap <silent> <leader>p :GFiles<CR>
nnoremap <silent> <leader>gp :GFiles?<CR>
nnoremap <silent> <leader>buf :Buffers<CR>
nnoremap <silent> <leader>lin :BLines<CR>
nnoremap <silent> <leader>tag :BTags<CR>
nnoremap <silent> <leader>com :Commits<CR>
let g:fzf_layout = { 'down': '~40%' }
let g:fzf_buffers_jump = 1
" vim-gitgutter
let g:gitgutter_sign_added = '+'
let g:gitgutter_sign_removed = '-'
let g:gitgutter_sign_modified = '±'
let g:gitgutter_sign_modified_removed = '±'
if exists('&signcolumn')
set signcolumn=yes
else
let g:gitgutter_sign_column_always = 1
endif
" php.vim
let php_html_load = 0
let php_html_in_heredoc = 0
let php_html_in_nowdoc = 0
let php_sql_query = 0
let php_sql_heredoc = 0
let php_sql_nowdoc = 0
function! PhpSyntaxOverride()
hi! def link phpDocTags phpDefine
hi! def link phpDocParam phpType
endfunction
augroup phpVimAutocmd
autocmd!
autocmd FileType php call PhpSyntaxOverride()
augroup end
" vim-php-namespace
" Insert use statement
let g:php_namespace_sort_after_insert = 1
function! IPhpInsertUse()
call PhpInsertUse()
call feedkeys('a', 'n')
endfunction
" Expand Namespace
function! IPhpExpandClass()
call PhpExpandClass()
call feedkeys('a', 'n')
endfunction
augroup phpInsertUseAutocmd
autocmd!
autocmd FileType php inoremap <leader>u <Esc>:call IPhpInsertUse()<CR>
autocmd FileType php noremap <leader>u :call PhpInsertUse()<CR>
autocmd FileType php inoremap <leader>e <Esc>:call IPhpExpandClass()<CR>
autocmd FileType php noremap <leader>e :call PhpExpandClass()<CR>
augroup end
" nerdcommenter
filetype plugin on
let g:NERDSpaceDelims = 1
let g:NERDDefaultAlign = 'left'
let g:NERDCommentEmptyLines = 1
let g:NERDCommentEmptyLines = 1
" Make NERDCommenter work with vue files
let g:ft = ''
function! NERDCommenter_before()
if &ft == 'vue'
let g:ft = 'vue'
let stack = synstack(line('.'), col('.'))
if len(stack) > 0
let syn = synIDattr((stack)[0], 'name')
if len(syn) > 0
let syn = tolower(syn)
exe 'setf '.syn
endif
endif
endif
endfunction
function! NERDCommenter_after()
if g:ft == 'vue'
setf vue
let g:ft = ''
endif
endfunction
" vim-fugitive
noremap <silent> <leader>gstatus :Git<CR>
noremap <silent> <leader>gblame :Git blame -w<CR>
" tagbar
nnoremap <silent> <leader>tb :TagbarToggle<CR>
" needs manual installation/build of https://github.com/vim-php/phpctags via
" ```
" cgr techlivezheng/phpctags
" ln -s ~/.config/composer/global/techlivezheng/phpctags/vendor/bin/phpctags ~/.config/composer/vendor/bin/
" ```
let g:tagbar_autoclose = 1
" lightline
set laststatus=2
set noshowmode
let g:lightline = {
\ 'colorscheme': 'onedark',
\ 'active': {
\ 'left': [
\ ['mode', 'paste'],
\ ['gitbranch', 'readonly', 'filename', 'TreeSitterStatus'],
\ ['gutentags'],
\ ],
\ 'right': [
\ ['linter_checking', 'linter_errors', 'linter_warnings', 'linter_ok'],
\ ['lineinfo'],
\ ['fileformat', 'fileencoding', 'filetype'],
\ ],
\ },
\ 'component_function': {
\ 'gitbranch': 'FugitiveHead',
\ 'filename': 'LightlineFilename',
\ 'TreeSitterStatus': 'TreeSitterStatus',
\ },
\ 'component': {
\ 'lineinfo': '%l>%c',
\ 'tagbar': '%{tagbar#currenttag("[%s]", "", "f")}',
\ 'gutentags': '%{gutentags#statusline("[Generating...]")}',
\ },
\ 'component_expand': {
\ 'linter_checking': 'lightline#ale#checking',
\ 'linter_warnings': 'lightline#ale#warnings',
\ 'linter_errors': 'lightline#ale#errors',
\ 'linter_ok': 'lightline#ale#ok',
\ },
\ 'component_type': {
\ 'linter_checking': 'left',
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error',
\ 'linter_ok': 'left',
\ },
\ }
function! LightlineFilename()
let filename = expand('%:t') !=# '' ? expand('%:t') : '[No Name]'
let modified = &modified ? ' +' : ''
return filename . modified
endfunction
if has('nvim')
function! TreeSitterStatus()
return nvim_treesitter#statusline(500)
endfunction
else
" even tough, tree-sitter is not loaded, lightline expects this function
" just declare a noop so it doesn't break
function! TreeSitterStatus()
return ''
endfunction
endif
" gutentags
let g:gutentags_ctags_tagfile = '.tags'
set tags='.tags'
" ack.vim
let g:ackprg = 'ag --vimgrep --hidden --smart-case --ignore .git/'
cnoreabbrev Ack Ack!
nnoremap <leader>a :Ack!<space>
" ctrlsf.vim
let g:ctrlsf_regex_pattern = 1
let g:ctrlsf_auto_close = 0
nnoremap <leader>A :CtrlSF<space>
let g:ctrlsf_extra_backend_args = {
\ 'ag': '--hidden --smart-case --ignore .git/'
\ }
" vim-markdown
augroup vimMarkdownAutocmd
autocmd!
autocmd BufNewFile,BufReadPost *.md.erb set filetype=markdown
augroup end
" bufexplorer
let g:bufExplorerShowRelativePath = 1
" ultisnips
let g:UltiSnipsExpandTrigger = '<leader>st'
let g:UltiSnipsJumpForwardTrigger = '<leader>sn'
let g:UltiSnipsJumpBackwardTrigger = '<leader>sb'
" ale
nnoremap <silent> [e :ALEPreviousWrap<CR>
nnoremap <silent> ]e :ALENextWrap<CR>
let g:ale_fix_on_save = 1
let g:ale_completion_enabled = 0
let g:ale_set_highlights = 1
let g:ale_php_phpstan_level = 9
let g:ale_linter_aliases = {
\ 'vue': [
\ 'css',
\ 'javascript',
\ ]
\ }
let g:ale_linters = {
\ 'css': [
\ 'stylelint',
\ ],
\ 'go': [
\ 'gobuild',
\ 'gofmt',
\ 'golint',
\ 'gotype',
\ 'govet',
\ ],
\ 'javascript': [
\ 'eslint',
\ ],
\ 'javascriptreact': [
\ 'eslint',
\ ],
\ 'php': [
\ 'phpstan',
\ ],
\ 'sass': [
\ 'stylelint',
\ ],
\ 'scss': [
\ 'stylelint',
\ ],
\ 'typescript': [
\ 'eslint',
\ ],
\ 'vue': [
\ 'eslint',
\ 'stylelint',
\ ],
\ }
let g:ale_fixers = {
\ 'css': [
\ 'stylelint',
\ ],
\ 'go': [
\ 'gofmt',
\ 'goimports',
\ ],
\ 'javascript': [
\ 'eslint',
\ ],
\ 'javascriptreact': [
\ 'eslint',
\ ],
\ 'sass': [
\ 'stylelint',
\ ],
\ 'scss': [
\ 'stylelint',
\ ],
\ 'typescript': [
\ 'eslint',
\ ],
\ 'vue': [
\ 'eslint',
\ 'stylelint',
\ ],
\ }
" undotree
nnoremap <silent> <leader><leader>u :NERDTreeClose<CR>:UndotreeToggle<CR>
if has("persistent_undo")
set undodir=~/.undodir/
set undofile
endif
" vim-maximizer
let g:maximizer_set_default_mapping = 0
nmap <silent> <leader>m :MaximizerToggle!<CR>
" vim-closetag
let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.vue,*.twig,*.blade.php'
" vim-vue
let g:vue_disable_pre_processors = 1
" incsearch.vim, vim-asterisk & incsearch-easymotion.vim
set hlsearch
set ignorecase
let g:incsearch#auto_nohlsearch = 1
let g:asterisk#keeppos = 1
" search
map / <Plug>(incsearch-forward)
map ? <Plug>(incsearch-backward)
map g/ <Plug>(incsearch-stay)
" Search with easymotion
map z/ <Plug>(incsearch-easymotion-/)
map z? <Plug>(incsearch-easymotion-?)
map zg/ <Plug>(incsearch-easymotion-stay)
" search forth- and backwards
map n <Plug>(incsearch-nohl-n)
map N <Plug>(incsearch-nohl-N)
" search word under cursor (move)
map * <Plug>(incsearch-nohl)<Plug>(asterisk-*)
map # <Plug>(incsearch-nohl)<Plug>(asterisk-#)
map g* <Plug>(incsearch-nohl)<Plug>(asterisk-g*)
map g# <Plug>(incsearch-nohl)<Plug>(asterisk-g#)
" search word under cursor (stay)
map z* <Plug>(incsearch-nohl)<Plug>(asterisk-z*)
map z# <Plug>(incsearch-nohl)<Plug>(asterisk-z#)
map gz* <Plug>(incsearch-nohl)<Plug>(asterisk-gz*)
map gz# <Plug>(incsearch-nohl)<Plug>(asterisk-gz#)
" COC
" Config
call coc#config('suggest', {
\ 'noselect': 1,
\ 'enablePreselect': 0,
\ })
call coc#config('diagnostic', {
\ 'displayByAle': 1,
\ 'refreshOnInsertMode': 1,
\ 'signOffset': 999999,
\ })
call coc#config('yaml.schemas', {
\ 'kubernetes': '*.yaml',
\ })
" General config
" Some server have issues with backup files, see #649
set nobackup
set nowritebackup
" Better display for messages
set cmdheight=2
" Better experience as with the default 4000
set updatetime=300
" Don't give |ins-completion-menu| messages.
set shortmess+=c
" Configure completion
" Use tab for trigger completion with characters ahead and navigate.
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1):
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <silent><expr><S-TAB>
\ coc#pum#visible() ?
\ coc#pum#prev(1) :
\ "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR>
\ coc#pum#visible() ?
\ coc#pum#confirm() :
\ "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" General mappings
" Remap for rename current word
nmap <leader>rn <Plug>(coc-rename)
" Remap for format selected region
vmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
" Remap keys for gotos
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 for 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
" Using CocList
nnoremap <silent> <space>a :<C-u>CocList diagnostics<CR>
nnoremap <silent> <space>e :<C-u>CocList extensions<CR>
nnoremap <silent> <space>c :<C-u>CocList commands<CR>
nnoremap <silent> <space>o :<C-u>CocList outline<CR>
nnoremap <silent> <space>s :<C-u>CocList -I symbols<CR>
nnoremap <silent> <space>j :<C-u>CocNext<CR>
nnoremap <silent> <space>k :<C-u>CocPrev<CR>
nnoremap <silent> <space>p :<C-u>CocListResume<CR>
" Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
" vmap <leader>a <Plug>(coc-codeaction-selected)
" nmap <leader>a <Plug>(coc-codeaction-selected)
" Remap for do codeAction of current line
nmap <leader>ac <Plug>(coc-codeaction)
" Fix autofix problem of current line
nmap <leader>qf <Plug>(coc-fix-current)
" Highlight symbol under cursor on CursorHold
augroup cocCursorhold
autocmd!
" Highlight element under cursor when idle
autocmd CursorHold * silent call CocActionAsync('highlight')
" Show signature help for parameters in insert mode when idle
autocmd CursorHoldI * silent call CocActionAsync('showSignatureHelp')
augroup end
augroup coc
autocmd!
" Setup formatexpr specified filetype(s).
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" Format/re-organize imports
autocmd BufWritePre *.go :call CocAction('runCommand', 'editor.action.organizeImport')
" Update signature help on jump placeholder
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end
" Use `:Format` for format current buffer
command! -nargs=0 Format :call CocAction('format')
" Use `:Fold` for fold current buffer
command! -nargs=? Fold :call CocAction('fold', <f-args>)
" use `:OR` for organize import of current buffer
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
{{- if .vim.coc.intelephense_licensekey}}
" Coc Config (if any)
call coc#config('intelephense', {
\ 'licenceKey': '{{ .vim.coc.intelephense_licensekey }}',
\ })
{{- end }}
" lightline-ale
let g:lightline#ale#indicator_checking = "\uf110"
let g:lightline#ale#indicator_warnings = "\uf071"
let g:lightline#ale#indicator_errors = "\uf05e"
let g:lightline#ale#indicator_ok = "\uf00c"
" Tinykeymap
let g:tinykeymaps_default = []
call tinykeymap#Load('windows')
call tinykeymap#Map('windows', '<C-right>', 'wincmd >')
call tinykeymap#Map('windows', '<C-left>', 'wincmd <')
call tinykeymap#Map('windows', '<C-up>', 'wincmd +')
call tinykeymap#Map('windows', '<C-down>', 'wincmd -')
" vim-yoink
let g:yoinkMaxItems = 50
let g:yoinkIncludeDeleteOperations = 1
let g:yoinkSyncSystemClipboardOnFocus = 1
if has('nvim')
let g:yoinkSavePersistently = 1
endif
" Basic functionality
nmap [p <Plug>(YoinkPostPasteSwapBack)
nmap ]p <Plug>(YoinkPostPasteSwapForward)
nmap p <Plug>(YoinkPaste_p)
nmap P <Plug>(YoinkPaste_P)
" Swap pointer of current yank
nmap [y <Plug>(YoinkRotateBack)
nmap ]y <Plug>(YoinkRotateForward)
" vim-subversive
" For supporting yoink in visual mode
xmap s <Plug>(SubversiveSubstitute)
xmap p <Plug>(SubversiveSubstitute)
xmap P <Plug>(SubversiveSubstitute)
" vim-lion
let g:lion_squeeze_spaces = 1
" tpope/vim-markdown
let g:markdown_fenced_languages = [
\ 'bash=sh',
\ 'css',
\ 'html',
\ 'javascript',
\ 'php',
\ 'python',
\ 'vue',
\ ]
" -----VISUAL-----
" Syntax highlighting
syntax enable
set t_ut=
set t_Co=256
colorscheme onedark
" Link color definition for menu highlighting
highlight! link CocMenuSel PmenuSel
" Always display tabline
set showtabline=2
" Highlight current line
set cursorline
" Show column length
set ruler
" Show line numbers
set number
" -----END-----
" Auto sourcing the .vimrc file on safe
augroup sourcingAutocmd
autocmd!
autocmd BufWritePost $MYVIMRC nested source $MYVIMRC
" Reload lightline
call lightline#init()
call lightline#colorscheme()
call lightline#update()
augroup end