-
Notifications
You must be signed in to change notification settings - Fork 0
/
my.vimrc
812 lines (646 loc) · 23.7 KB
/
my.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
" SECTIONS:
"Type find key "/" which is regular slash and type section name with #"
"#General
"#Vundle
"#Plugins
"#Colors
"#Airline
"#fzf.vim
"#Keymapping
"#vim-todo
"#YouCompleteME
"#syntastic
"#YouCompleteMe
"#Python
"#lua
"#Bufonly.vim
"#love2d
"
" "Installed plugins
"-delimitMate'
"-indentLine'
"-vim-colors-solarized'
"-opengl.vim'
"-nerdtree-git-plugin'
"-Vundle.vim'
"-vim-codefmt'
"-vim-glaive'
"-vim-maktaba'
"-vim-obsession'
"-vim-surround'
"-coc.nvim' " alternative
"-fzf.vim'
"-vim-devicons' "enable if you have nerd-font
"-vim-jsx-pretty'
"-vim-js'
"-vim-nerdtree-tabs'
"-vim-misc'
"-vim-lua-ftplugin'
"-Zenburn'
"-ctrlp.vim'
"-tagbar'
"-vim-asm_ca65'
"-lua-support'
"-gruvbox'
"-vim-flake8'
"-nerdtree'
"-vim-glsl'
"-SimpylFold'
"-fugitive'
"-vim-airline'
"-vim-airline-themes'
"-indentpython.vim'
"-syntastic'
"-vim-todo-lists'
"-dart-vim-plugin'
"-vim-lsc'
"-vim-lsc-dart'
"Leader key is ","
"##########################################
"# #General #
"##########################################
" Added to fix fzf background -> my terminal profile is dracula that why it
" put below line to your .gimvrc
" set termguicolors
" use this if you do not use gui vim
let g:dracula_colorterm = 0
set tws=22x0 "size of terminal window "30x0" uses 30 rows and the current window width.
set encoding=UTF-8
" It is a deadly sin for vim users to delete this minus symbol
set mouse-=a
set guioptions= "hide scrollbars left & right
set relativenumber
set number
set ignorecase "case-insensitive search
set ruler "to enable right-bottom numbers in statusbar
set splitright
"set lasststatus=2
"set listchars=tab:\|., trail:., extends:#, nbsp:. "",nbsp:·,trail:·
set listchars=tab:\|.,trail:·,extends:#,nbsp:\|,trail:·,precedes:\|
"command line completion
set wildmode=longest:full,full
set wildmenu
set showcmd
set showmatch
set smartcase
set autowrite "autowrite : write file if it has been modified
"no visualbell
set noerrorbells
set vb t_vb=
" Give more space for displaying messages.
set cmdheight=2
set lazyredraw "when this option is set, the screen will not be redrawn executing macros, registers and other commands that have not typed.
set showmatch "when a bracket is inserted, briefly jump to the matching one.
set matchtime=0 "tenths of a second to show the matching paren, when 'showmatch' is
set magic "changes the special characters that can be used in search patterns.
set autoindent " copy indent from current line when starting a new line
set copyindent "copy the structure of the existing lines indent when autoindenting new line
set smartindent " do smart autoindenting when starting a new line
set wrap "when on, lines longer than the width of the window will wrap displaying continues on the next line
set undolevels=300 "maximum number of changes that can be undone
set visualbell "if it is on vim will flash its screen instead of sounding a beep
set noerrorbells "vim will either beep or flash its screen when an error message is displayed
" Some servers have issues with backup files
set nowritebackup
set nobackup "when this option is on vim makes a backup before overwriting a file.
set noswapfile " .swp files store changes were made to the buffer. recoverable if even vim crashes
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
" delays and poor user experience.
set updatetime=300
" Don't pass messages to |ins-completion-menu|.
set shortmess+=c
set cursorline "highlight the text line of the cursor with CursorLine
"set cursorlineopt=both "to highlight current line, and line number
set cursorlineopt=number "to highlight only line number
"set cursorlineopt=screenline
set autochdir "change cd whenever a new file is opened such as buffers, tabs
set shortmess+=c "this option helps to avoid all the hit-enter promts
" +=c => avoid ins-completion-menu messages such as "Pattern Not Found
"I DO NOT RECOMMEND TO USE TOGGLE BACKGROUND MODE (DARK, LIGHT)
"MY RECOMMENDATION IS USE DARK WHICH IS DEFAULT
"enable below one if you want to toggle bt dark&light modes.
"call togglebg#map("<YOUR KEY>")
set clipboard=unnamed "Vim will use the clipboard register for all yank, delete, change and put operations would normally go to the unnamed register
set completeopt+=noinsert "Prevents unwanted autocompletes"
"WARNING OS X USERS
"Those lines break NERDTree on MacVim
"So do not use !!!
"save and load view automatically
"FIXME au BufWinLeave * mkview
"FIXME au BufWinEnter * silent loadview
:set hlsearch "to enable highlighting when searching for patterns
:set incsearch "to enable highlighting when starting a search
"to enable backspace over auto-indentation
"it prevents accidential indentation removals
:set backspace=indent,eol,start
filetype on "when this option is set, the FileType autocommand event is triggered.
au FileType markdown setlocal noexpandtab tabstop=4 sw=4 sts=4 "markdown indentation
"map leader was "\" by default
let mapleader = ","
"my todo path
let $TODO = '~/.todo.md'
"my .vimrc path for macOS
let $MYVIMRC = '~/.vimrc'
"UBUNTU USERS!!
"IF YOU GET AN ERROR FOR DRACULA THEME
"PLACE THEM TO CALL VUNDLE#END()
"############# (END) ###############
:set list "show tabs as CTRL-I is displayed, display $ after end of line
":set listchars=tab:\|\
"add below line to change end of line char
"RECOMMENDED if you do not like pipe character -> ,eol:↲
:set encoding=utf-8
:set tabstop=4 "number of space characters that will be inserted when the tab key is pressed
:set shiftround
:set shiftwidth=4
:set expandtab "to insert space characters whenever the tab key is pressed
"##########################################
"# #Airline #
"##########################################
"remove airline whitespace feedback on bottom bar
let g:airline_detect_whitespace=0
let g:airline_powerline_fonts = 1 " disable it if you did not install font for powerline
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
"smarter tab line
let g:airline#extensions#tabline#enabled = 1
" Show just the filename
let g:airline#extensions#tabline#fnamemod = ':t'
"############# (END) ###############
"
"
"
"##########################################
"# #fzf.vim #
"##########################################
" This is the default option:
" - Preview window on the right with 50% width
" - CTRL-/ will toggle preview window.
" - Note that this array is passed as arguments to fzf#vim#with_preview function.
" - To learn more about preview window options, see `--preview-window` section of `man fzf`.
let g:fzf_preview_window = ['right:50%', 'ctrl-/']
" Empty value to disable preview window altogether
"let g:fzf_preview_window = []
" [Buffers] Jump to the existing window if possible
let g:fzf_buffers_jump = 1
" [[B]Commits] Customize the options used by 'git log':
let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"'
" [Tags] Command to generate tags file
let g:fzf_tags_command = 'ctags -R'
" [Commands] --expect expression for directly executing the command
let g:fzf_commands_expect = 'alt-enter,ctrl-x'
"############# (END) ###############
"
"##########################################
"# #Flutter #
"##########################################
let g:lsc_auto_map = v:true
"############# (END) ###############
"
"
"##########################################
"# #NERDTree #
"##########################################
"
"let g:NERDTreeDirArrows=0
let NERDTreeMinimalUI = 1
let NERDTreeDirArrows = 1
let NERDTreeShowHidden=1
let g:NERDTreeHijackNetrw=0 "to disable NERDTree to popup for every buffer automatically
let g:NERDTreeWinSize=40 "default size for NERDTree window
let g:NERDTreeWinPos = "right" "NERDTree windows position is left by default
let g:NERDTreeChDirMode = 2 "change directory
let g:NERDTreeGlyphReadOnly = "RO"
let NERDTreeQuitOnOpen = 1
let NERDTreeAutoDeleteBuffer = 1
"let NERDTreeMinimalUI = 1
"let NERDTreeDirArrows = 1
autocmd! BufWinEnter * if(winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
nnoremap <silent> <Leader>v :NERDTreeFind<CR>
"##########################################
"# #YouCompleteMe #
"##########################################
let g:ycm_autoclose_preview_window_after_completion=1
let g:ycm_global_ycm_extra_conf='/Users/gurcanbadin/.vim/bundle/youcompleteme/cpp/.ycm_extra_conf.py'
" setup for ycm
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py'
let g:ycm_python_binary_path = 'python'
let g:ycm_complete_in_comments = 1
let g:ycm_autoclose_preview_window_after_completion = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_semantic_triggers = {
\ 'c': ['->', '.'],
\ 'objc': ['->', '.', 're!\[[_a-zA-Z]+\w*\s', 're!^\s*[^\W\d]\w*\s',
\ 're!\[.*\]\s'],
\ 'ocaml': ['.', '#'],
\ 'cpp,cuda,objcpp': ['->', '.', '::'],
\ 'perl': ['->'],
\ 'php': ['->', '::'],
\ 'cs,d,elixir,go,groovy,java,javascript,julia,perl6,python,scala,typescript,vb': ['.'],
\ 'ruby,rust': ['.', '::'],
\ 'lua': ['.', ':'],
\ 'erlang': [':'],
\ }
"############# (END) ###############
"##########################################
"# #syntastic #
"##########################################
" setup for syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 0
let g:syntastic_auto_loc_list = 0
let g:syntastic_check_on_open = 0
let g:syntastic_check_on_wq = 0
let g:syntastic_python_checkers = ['flake8']
"############# (END) ###############
"##########################################
"# #Keymapping #
"##########################################
"run console
map <leader>te :terminal <CR>
map <leader>w :w <CR>
map <leader>qq :q <CR>
"open every lua file in tabs for current dir
map <leader>lua :Tabe *.lua<CR>
"It has a collision with incrementer (<c-a>) **not recommended.**
"ctrl-a select all doc
"nmap <C-a> <esc>ggVG<CR>
"indent
map <leader>ii <esc> gg=G 2<C-o> <CR>
"run *.py <F9>
au FileType python noremap <buffer> <F9> :w<CR>:exec '!python3' shellescape(@%, 1)<CR> :call ClearCmdwin() <CR>
au FileType python noremap <buffer> <F9> <esc>:w<CR>:exec '!python3' shellescape(@%, 1)<CR>
au! BufNewFile,BufRead *.vs,*.fs set ft=glsl
au Filetype lua nmap <buffer> <F10> :call LuaExecCurrent() <CR>
"delete all buffers except current one
nmap <buffer> <leader>bb :BufOnly <CR>
"toggle NERDTree window
map <leader>nt :NERDTreeToggle <CR>
" Open .vimrc in a new tab
nmap <silent> <leader>vr :tabnew $MYVIMRC<CR>
" Open .todo file
nmap <silent> <leader>td :tabnew $TODO<CR>
au FileType lua call SetLovePrefs()
au StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif "refresh memory
"run when you editing lua file -- this RunLove() function
"automatically detects your bufffer's current directory
"and call love /path/your/game
"!!!! do not forget to set your love $PATH variable !!!!!!
" FOR macOS put this export PATH=$PATH:/Applications/love.app/Contents/MacOS/
" to your ~/.bash_profile
au Filetype lua nmap <buffer> § :call RunLove() <CR>
"I had a problem with F keys on my macbook, these mappings
"solved that problem.
map <Esc>OP <F1>
map <Esc>OQ <F2>
map <Esc>OR <F3>
map <Esc>OS <F4>
map <Esc>[16~ <F5>
map <Esc>[17~ <F6>
map <Esc>[18~ <F7>
map <Esc>[19~ <F8>
map <Esc>[20~ <F9>
map <Esc>[21~ <F10>
map <Esc>[23~ <F11>
map <Esc>[24~ <F12>
map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
nnoremap <esc> :noh<return><esc>
map <F2> :NERDTreeToggle <CR>
"############# (END) ###############
highlight BadWhitespace ctermfg=253 ctermbg=9 guifg=#000000 guibg=#ff0000
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
"##########################################
"# #love2d #
"##########################################
function! SetLovePrefs()
setlocal dictionary-=~/.vim/love-dictionary/love.dict dictionary+=~/.vim/love-dictionary/love.dict
setlocal iskeyword+=.
endfunction
"!!!! do not forget to set your love $PATH variable !!!!!!
" FOR macOS put this export PATH=$PATH:/Applications/love.app/Contents/MacOS/
" to your ~/.bash_profile
" This function is totally mine
" just #%!@ 2 lines of code and works well
function! RunLove()
call ClearCmdwin()
lcd %:p:h
!love `pwd`
endfunction
"############# (END) ###############
"##########################################
"# #Vundle #
"##########################################
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"let g:airline_theme='onedark'
"let g:onedark_termcolors=256"call vundle#begin('~/some/path/here')
"##########################################
"# #Plugins #
"##########################################
" let Vundle manage Vundle, required
Bundle 'Valloric/YouCompleteMe'
Plugin 'dracula/vim', { 'name': 'dracula' }
Plugin 'Raimondi/delimitMate'
Plugin 'Yggdroot/indentLine'
Plugin 'altercation/vim-colors-solarized'
Plugin 'beyondmarc/opengl.vim'
Plugin 'Xuyuanp/nerdtree-git-plugin'
Plugin 'gmarik/Vundle.vim'
Plugin 'google/vim-codefmt'
Plugin 'google/vim-glaive'
Plugin 'google/vim-maktaba'
Plugin 'tpope/vim-obsession'
Plugin 'tpope/vim-surround'
"Plugin 'neoclide/coc.nvim' " intellisense engine for vim (>= 8.1)
Plugin 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plugin 'junegunn/fzf.vim'
"Plugin 'ryanoasis/vim-devicons' " enable if you have nerd-font
Plugin 'maxmellon/vim-jsx-pretty'
Plugin 'yuezk/vim-js'
"nerdtreetabs caused err on my mvim
"Plugin 'jistr/vim-nerdtree-tabs'
Plugin 'xolox/vim-misc'
Plugin 'xolox/vim-lua-ftplugin'
Plugin 'jnurmine/Zenburn'
Plugin 'kien/ctrlp.vim'
Plugin 'majutsushi/tagbar'
Plugin 'maxbane/vim-asm_ca65'
"Plugin 'wolfgangmehner/lua-support'
Plugin 'morhetz/gruvbox'
Plugin 'nvie/vim-flake8'
Plugin 'scrooloose/nerdtree'
Plugin 'tikhomirov/vim-glsl'
Plugin 'tmhedberg/SimpylFold'
Plugin 'tpope/vim-fugitive'
Plugin 'vim-airline/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'vim-scripts/indentpython.vim'
Plugin 'vim-syntastic/syntastic'
Plugin 'aserebryakov/vim-todo-lists'
Plugin 'dart-lang/dart-vim-plugin'
Plugin 'natebosch/vim-lsc'
Plugin 'natebosch/vim-lsc-dart'
" add all your plugins here (note older versions of Vundle
" used Bundle instead of Plugin)
" ...
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
"##############END###############
"##########################################
"# #Python #
"##########################################
au BufNewFile,BufRead *.py
\ set tabstop=4
\ softtabstop=4
\ shiftwidth=4
\ textwidth=79
\ expandtab
\ autoindent
let python_highlight_all=1
syntax on
"############# (END) ###############
"##########################################
"# #vim-todo #
"##########################################
let g:VimTodoListsDatesEnabled = 1
let g:VimTodoListsDatesFormat = "%a %d, %Y"
"############# (END) ###############
"##########################################
"# #lua #
"##########################################
"this snippet clears cmdwin before running scripts
"extremely useful 2 lines of code
function! ClearCmdwin()
silent !clear
redraw!
endfunction
function! LuaExecCurrent()
call ClearCmdwin()
w! expand("%")
!lua %
"execute ":!lua" exists("g:mainfile") ? g:mainfile : expand("%")
endfunction
"au CmdwinLeave * :Silent clear
"############# (END) ###############
"########################################################################
"# BuffOnly.vim #
"########################################################################
" BufOnly.vim - Delete all the buffers except the current/named buffer.
"
" Copyright November 2003 by Christian J. Robinson <[email protected]>
"
" Distributed under the terms of the Vim license. See ":help license".
"
" Usage:
"
" :Bonly / :BOnly / :Bufonly / :BufOnly [buffer]
"
" Without any arguments the current buffer is kept. With an argument the
" buffer name/number supplied is kept.
command! -nargs=? -complete=buffer -bang Bonly
\ :call BufOnly('<args>', '<bang>')
command! -nargs=? -complete=buffer -bang BOnly
\ :call BufOnly('<args>', '<bang>')
command! -nargs=? -complete=buffer -bang Bufonly
\ :call BufOnly('<args>', '<bang>')
command! -nargs=? -complete=buffer -bang BufOnly
\ :call BufOnly('<args>', '<bang>')
function! BufOnly(buffer, bang)
if a:buffer == ''
" No buffer provided, use the current buffer.
let buffer = bufnr('%')
elseif (a:buffer + 0) > 0
" A buffer number was provided.
let buffer = bufnr(a:buffer + 0)
else
" A buffer name was provided.
let buffer = bufnr(a:buffer)
endif
if buffer == -1
echohl ErrorMsg
echomsg "No matching buffer for" a:buffer
echohl None
return
endif
let last_buffer = bufnr('$')
let delete_count = 0
let n = 1
while n <= last_buffer
if n != buffer && buflisted(n)
if a:bang == '' && getbufvar(n, '&modified')
echohl ErrorMsg
echomsg 'No write since last change for buffer'
\ n '(add ! to override)'
echohl None
else
silent exe 'bdel' . a:bang . ' ' . n
if ! buflisted(n)
let delete_count = delete_count+1
endif
endif
endif
let n = n+1
endwhile
if delete_count == 1
echomsg delete_count "buffer deleted"
elseif delete_count > 1
echomsg delete_count "buffers deleted"
endif
endfunction
filetype plugin on
"##########################################
"# #Colors #
"##########################################
"ONEDARK THEME
"syntax on
":set background=dark
"colorscheme onedark
"let g:airline_theme='onedark'
"let g:onedark_termcolors=256
"enable italic
let &t_ZH="\e[3m"
let &t_ZR="\e[23m"
highlight Comment cterm=italic
""DRACULE THEME
"manual installation (not needed)
"packadd! dracula
"syntax enable
"colorscheme dracula
"AirlineTheme dracula
"set it to 1 if your terminal supports italic
let g:dracula_italic = 1
colorscheme dracula
"enable 256colors
if $TERM == "xterm-256color"
set t_Co=256
endif
"hi Folded ctermfg=15\ guifg=#378787 ctermbg=20 "my custom color for folded lines
"It lookin great with dracula -> ~ tilde color
"177 for purple (HIGHLY RECOMMENDED) , 11 for yellow , 62 for blueviolet
highlight NonText ctermfg=177
"####################END#####################
"################ #Tabe Function ####################
"a function to open spesific files on current dir
command! -complete=file -nargs=* Tabe call Tabe(<f-args>)
function! Tabe(...)
let t = tabpagenr()
let i = 0
for f in a:000
for g in glob(f, 0, 1)
exe "tabe " . fnameescape(g)
let i = i + 1
endfor
endfor
if i
exe "tabn " . (t + 1)
endif
endfunction
"####################END#####################
"
"
"
"
"###################### coc.nvim configurations "################################
" Always show the signcolumn, otherwise it would shift the text each time
" diagnostics appear/become resolved.
if has("patch-8.1.1564")
" Recently vim can merge signcolumn and number column into one
set signcolumn=number
else
set signcolumn=yes
endif
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
" inoremap <silent><expr> <TAB>
" \ pumvisible() ? "\<C-n>" :
" \ <SID>check_back_space() ? "\<TAB>" :
" \ coc#refresh()
" inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
" inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
" \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
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>
" enable if coc.vim
" function! s:show_documentation()
" if (index(['vim','help'], &filetype) >= 0)
" execute 'h '.expand('<cword>')
" else
" call CocActionAsync('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 buffer.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
" Map function and class text objects
" NOTE: Requires 'textDocument.documentSymbol' support from the language server.
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)
xmap ic <Plug>(coc-classobj-i)
omap ic <Plug>(coc-classobj-i)
xmap ac <Plug>(coc-classobj-a)
omap ac <Plug>(coc-classobj-a)
" Use CTRL-S for selections ranges.
" Requires 'textDocument/selectionRange' support of language server.
nmap <silent> <C-s> <Plug>(coc-range-select)
xmap <silent> <C-s> <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.
" enable if coc.vim
" set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
"####################END#####################