-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc.dot
780 lines (683 loc) · 23.5 KB
/
vimrc.dot
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
set nocompatible " be iMproved, required
filetype off " required
call plug#begin('~/.vim/plugged')
Plug 'VundleVim/Vundle.vim'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-surround'
Plug 'fatih/vim-go'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'junegunn/fzf'
Plug 'ntpeters/vim-better-whitespace'
Plug 'christoomey/vim-tmux-navigator'
Plug 'Yggdroot/indentLine'
Plug 'flazz/vim-colorschemes'
Plug 'joshdick/onedark.vim'
Plug 'scrooloose/nerdtree'
"NOTE TRY ME and compare again YouCompleteMe for py complet
Plug 'davidhalter/jedi-vim'
" Use gS, gJ
Plug 'AndrewRadev/splitjoin.vim' "
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
" Need by vim-go for :GoDecls, :GoDeclsDir
Plug 'ctrlpvim/ctrlp.vim'
Plug 'ekalinin/Dockerfile.vim'
Plug 'itchyny/lightline.vim'
" Slow as hell
Plug 'airblade/vim-gitgutter'
Plug 'majutsushi/tagbar'
Plug 'w0rp/ale'
" yaml
Plug 'chase/vim-ansible-yaml'
" Python
Plug 'python-mode/python-mode'
Plug 'vim-scripts/indentpython.vim'
" trial plugins
"Plug 'tmhedberg/SimpylFold'
"Plug 'TaskList.vim'
"Plug 'jceb/vim-orgmode'
Plug 'sheerun/vim-polyglot'
Plug 'ervandew/supertab', {'on':[]}
if has ('nvim')
Plug 'Shougo/deoplete.nvim', { 'on':[], 'do': ':UpdateRemotePlugins' }
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
Plug 'deoplete-plugins/deoplete-jedi'
Plug 'deoplete-plugins/deoplete-go', { 'do': 'make'}
Plug 'junegunn/vader.vim' "Added for vimscript testing
Plug 'sebdah/vim-delve'
call plug#end()
"{{{
set exrc
set secure
set showcmd "show last command enter of bottom right
set cmdheight=2 "Give more space for displaying messages
"SLOW
" Show a line under the cursor, but its annoying
"set cursorline "highlight current line
set wildmenu "visual auto complete for command menu
set lazyredraw "redraw only when we need to
"}}}
"
"{{{ cpp stuff
augroup project
autocmd!
autocmd BufRead,BufNewFile *.h,*.c set filetype=c.doxygen
augroup END
"}}}
"{{{ encoding
set encoding=utf-8
set fileencoding=utf-8
scriptencoding utf-8
"}}}
filetype on
filetype plugin indent on " required
syntax on
if !has('nvim')
set ttyfast " Indicate fast termina; conn for faster redraw
set ttymouse=xterm " Indicate terminal type for mouse codes
set ttyscroll=3 " Speedup scrolling
endif
"{{{ Common setings
let mapleader=","
"set clipboard=unamed "CHECKME: Is copying working
set nowrap " don't wrap lines
set tabstop=4 " a tab is four spaces
set shiftwidth=4 " number of spaces to use for autoindenting
set softtabstop=4 " a tab is four spaces
set backspace=indent,eol,start "Makes backspace more powerful
" allow backspacing over everything in insert mode
set expandtab " always expand, noexpandtab is required only for makefile
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set number " always show line numbers
set relativenumber " Show relative number
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set showmatch " set show matching parenthesis
set matchtime=0 " Avoid cursor to jump
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase,
" case-sensitive otherwise
set smarttab " insert tabs on the start of a line according to
" shiftwidth, not tabstop
set hlsearch " highlight search terms
set incsearch " show search matches as you type
set history=1000 " remember more commands and search history
set undolevels=1000 " use many muchos levels of undo
set wildignore=*.swp,*.bak,*.pyc,*.class
set wildignore+=*.a,*.o,
set wildignore+=.git,*.bmp,*.gif,*.jpg,*.png
set title " change the terminal's title
set visualbell " don't beep
set noerrorbells " don't beep
set confirm " Display confirmation when closing an unsaved file
set nobackup
set nowritebackup
set noswapfile
set ruler "Show cursor's current col and line number
set autoread "Reload buffer if file was modified in another buffer
set shortmess+=I "Suppress startup message on vim
set shortmess+=c "Dont passs message to |ins-completion-menu|
set signcolumn=yes
set list
set hidden "Buffer should still exists if window is closed
set listchars=tab:→\ ,trail:∙,nbsp:•,eol:¬
autocmd filetype html,xml set listchars-=tab:>.
" #NOTE, #CHECKME
"set noshowmatch "Do not show matching brackets by flickering
"set noshowmode "We show the mode with airline or lightline
"
" Autocmd for aterating defaults {{{
" }}}
"
"
" Mapped Keys {{{
nmap <leader>l :set list!<cr>
nmap <leader>w :w<cr> "Write file
nmap <leader>wq :wq<cr> "Write and quiteifile
nmap <leader>q :q<cr> "Quit file
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>
" }}}
"
"
" UltiSnips not working with paste set
"set paste
"
"tagbar plugin
noremap <Leader>T :TagbarToggle<Enter>
"
" vim-markdown-preview {{{
" pip install grip
" 0 - depends on markdown perl plugin
" 1 - for github style
let vim_markdown_preview_github=1
" 0, not on buffer write 1 - display image on ctrl-p, 2 - preview on write
" with image, 3- preview on write without image rendering
let vim_markdown_preview_toggle=0
"}}}
"
"{{{
" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview
au BufNewFile,BufRead,BufEnter *.cpp,*.hpp set omnifunc=omni#cpp#complete#Main
""}}}
" {{{
" For IdentLine plugin
" :IndentToggle
set softtabstop=4 " makes the spaces feel like real tabs
let g:indentLine_color_term = 140
let g:indentLine_char = '|'
" }}}
" {vim-go customization
" https://github.com/fatih/vim-go-tutorial#quick-setup
" gofmt and rewrite the import declarations
" vendor packages not working, trying with -srcdir .
let g:go_fmt_command = "goimports"
"let g:go_autodetect_gopath = 1
" Use only quickfix list not location list
let g:go_list_type = "quickfix"
" Write the file automatically, if we call :make eg, :GoBuild,GoTest etc, it will
" automatically savea the file before compiling
set autowrite
" To make it easier to jump between errors in quickfix list:
map <C-n> :cnext<cr>
map <C-m> :cprevious<cr>
nnoremap <leader>a :cclose<cr>
" run :GoBuild or :GoTestCompile based on the go file
function! s:build_go_files()
let l:file = expand('%')
if l:file =~# '^\f\+_test\.go$'
call go#test#Test(0, 1)
elseif l:file =~# '^\f\+\.go$'
call go#cmd#Build(0)
endif
endfunction
" create a go doc comment based on the word under the cursor
function! s:create_go_doc_comment()
norm "zyiw
execute ":put! z"
execute ":norm I// \<Esc>$"
endfunction
"ui -> generate document
nnoremap <leader>ui :<C-u>call <SID>create_go_doc_comment()<CR>
" Shortcuts for building Go programs
"
autocmd BufNewFile,BufRead *.go setlocal expandtab tabstop=4 softtabstop=4 shiftwidth=4
autocmd filetype go, set listchars-=tab:
autocmd FileType go nmap <leader>b :<C-u>call <SID>build_go_files()<cr>
autocmd FileType go nmap <leader>r <Plug>(go-run)
autocmd FileType go nmap <leader>t <Plug>(go-test)
autocmd FileType go nmap <leader>c <Plug>(go-coverage-toggle)
autocmd FileType go nmap <leader>i <Plug>(go-info)
au Filetype go nmap <leader>ga <Plug>(go-alternate-edit)
au Filetype go nmap <leader>gah <Plug>(go-alternate-split)
au Filetype go nmap <leader>gav <Plug>(go-alternate-vertical)
"au BufRead *.go execute ":TagbarOpen"
autocmd FileType go nmap <C-]> :GoDef<cr>
autocmd FileType go nmap <C-t> :GoDefPop<cr>
"FIXME, Puts go files in REPLACE mode
"autocmd FileType go nmap <C-[> :GoDefStack<cr>
autocmd FileType go nmap <C-c> :GoCallers<cr>
autocmd FileType go nmap <C-s> :GoCallStack<cr>
" Open :GoDeclsDir with ctrl-g
autocmd FileType go nmap <C-g> :GoDeclsDir<cr>
autocmd FileType go imap <C-g> <esc>:<C-u>GoDeclsDir<cr>
autocmd Filetype go command! -bang A call go#alternate#Switch(<bang>0, 'edit')
autocmd Filetype go command! -bang AV call go#alternate#Switch(<bang>0, 'vsplit')
autocmd Filetype go command! -bang AS call go#alternate#Switch(<bang>0, 'split')
autocmd Filetype go command! -bang AT call go#alternate#Switch(<bang>0, 'tabe')
" vim-go default is snake_case
let g:go_addtags_transform = "camelcase"
" highligt types, fields
let g:go_highlight_types = 1
let g:go_highlight_fields = 1
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_function_calls = 1
let g:go_highlight_operators = 1
let g:go_highlight_extra_types = 1
let g:go_highlight_build_constraints = 1
" default settings, add if more
" Use golangci-lint
let g:go_metalinter_command='gometalinter'
let g:go_metalinter_enabled = ['vet', 'golint', 'errcheck']
" Run on every save
let g:go_metalinter_autosave = 0 "1 - Disabled
let g:go_metalinter_autosave_enabled = ['vet', 'golint']
let g:go_metalinter_deadline = "25s"
" Problem with ~/go/src/ and ~/git/<goproject> i.e a package not under GOPATH
let g:go_def_mode = 'gopls'
let g:go_auto_type_info = 1
let g:go_auto_sameids = 1
" 20/2/19
let g:go_gocode_propose_source = 1
" 20/7/19
" Check if autocomplete is enabled
" :verbose setlocal omnifunc?
" \
" omnifunc=go#complete#Complete
autocmd FileType go set omnifunc=go#complete#Complete
"au filetype go inoremap <buffer> . .<C-x><C-o>
"}}}
" For SirVer/ultisnips
filetype plugin indent on
let g:SuperTabDefaultCompletionType = '<C-n>'
""TRY use omnicomplete
let g:SuperTabDefaultCompletionType = '<C-x><C-o>'
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<c-j>"
let g:UltiSnipsJumpBackwardTrigger="<c-k>"
let g:UtliSnipsListSnippets = "<c-l>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
" Check :help go-settings
colorscheme gruvbox
"colorscheme zenburn
"colorscheme molokai
"colorscheme onedark
" For lightline
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'active': {
\ 'left': [['mode', 'paste'], ['filename', 'modified']],
\ 'right': [['lineinfo'], ['percent'], ['readonly', 'linter_warnings', 'linter_errors', 'linter_ok']]
\ },
\ 'component_expand': {
\ 'linter_warnings': 'LightlineLinterWarnings',
\ 'linter_errors': 'LightlineLinterErrors',
\ 'linter_ok': 'LightlineLinterOK'
\ },
\ 'component_type': {
\ 'readonly': 'error',
\ 'linter_warnings': 'warning',
\ 'linter_errors': 'error'
\ },
\ }
function! LightlineLinterWarnings() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
let g:ale_sign_warning = '
return l:counts.total == 0 ? '' : printf('%d ⚠', all_non_errors)
endfunction
function! LightlineLinterErrors() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? '' : printf('%d ✗', all_errors)
endfunction
function! LightlineLinterOK() abort
let l:counts = ale#statusline#Count(bufnr(''))
let l:all_errors = l:counts.error + l:counts.style_error
let l:all_non_errors = l:counts.total - l:all_errors
return l:counts.total == 0 ? '✓ ' : ''
endfunction
autocmd User ALELint call lightline#update()
set laststatus=2
" close help buffer using q
autocmd FileType help noremap <buffer> q :q<cr>
" }}}
"
" {{{
" Whitespace
highlight BadWhitespace ctermbg=red guibg=red
au BufRead,BufNewFile *.py,*.pyw,*.c,*.h match BadWhitespace /\s\+$/
" }}}
"
"
" New split windows, at bottom
set splitbelow
set splitright
" Yaml
au! BufNewFile,BufReadPost *.{yaml,yml} set filetype=yaml foldmethod=indent
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" VIM, navigating between the panes
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-h> <C-w>h
nnoremap <C-l> <C-w>l
" Or may be <cr> itself>
nnoremap <cr> <C-w><C-w>
" {{{
" Python IDE
"
"
"python with virtualenv support
"py3 << EOF
"import os
"import sys
"if 'VIRTUAL_ENV' in os.environ:
" project_base_dir = os.environ['VIRTUAL_ENV']
" activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
" execfile(activate_this, dict(__file__=activate_this))
"EOF
set nofoldenable
"set foldmethod=indent
"set foldlevel=99
"nnoremap <space> za
au BufNewFile, BufRead *.py
\ set tabstop=4
\ set softtabstop=4
\ set shiftwidth=4
\ set textwidth=100
\ set expandtab
\ set autoindent
\ set fileformat=unix
\ set smartindent
let python_highlight_all=1
"
"python formatter:
" What to choose? yapf vs autopep8 vs black
" Seems like black is good, similar to gofmt ( without options)
" autopep8 definitely no, Choose between yapf or black
"
" Few pints of ale
" Run only after save,
let g:ale_lint_on_text_change = 'never'
let g:ale_lint_on_enter = 0
let g:ale_linters = {}
let g:ale_linters.python = ['flake8', 'pylint', 'pycodestyle']
let g:ale_python_pylint_options = '--rcfile ~/git/dotfiles/pylintrc'
" Ale settings
let g:ale_sign_error = '✘'
let g:ale_sign_warning = '⚠'
highlight ALEErrorSign ctermbg=NONE ctermfg=red
highlight ALEWarningSign ctermbg=NONE ctermfg=yellow
let g:ale_fix_on_save=1
let g:ale_fixers = {
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
\ 'python': ['isort', 'black', 'autopep8'],
\ 'sh': ['shfmt'],
\ }
let g:ale_sh_shell_default_shell='bash'
let g:ale_fixers.python = ['black', 'autopep8', 'isort' ]
nmap <silent> [w <Plug>(ale_previous_wrap)
nmap <silent> ]w <Plug>(ale_next_wrap)
nmap <leader>f <Plug>(ale_fix)
nmap <leader>+ :let b:ale_enabled=1<cr>
"Disable Ale for the following file patterns
let g:ale_pattern_options = {
\ '.*\.txt$': { 'ale_enabled': 0 },
\ '.*\.rst$': { 'ale_enabled': 0 },
\}
"
" Plugins need to be added to runtimepath before helptags can be generated.
packloadall
" Load all of the helptags now, after plugins have been loaded.
" All messages and errors will be ignored.
silent! helptags ALL
"
"
let g:pymode=1
let g:pymode_python='python'
let g:pymode_syntax=1
let g:pymode_syntax_all=1
let g:pymode_syntax_indent_errors=1
let g:pymode_syntax_space_errors=1
let g:pymode_options_colorcolumn = 1
let g:pymode_doc = 1
let g:pymode_doc_bind = 'K'
let g:pymode_virtualenv = 1
let g:pymode_lint = 0 "Disabled in favour of ALE
let g:pymode_rope = 0
let g:pymode_rope_lookup_project = 0
let g:pymode_rope_completion = 0
let g:pymode_rope_completion_on_dot = 0
let g:pymode_rope_completion_bind = '<C-space>'
let g:pymode_rope_autoimport = 1
let g:pymode_rope_goto_definition_bind = '<C-c>g'
let g:pymode_rope_rename_bindi = '<C-c>rr'
let g:pymode_rope_organize_imports_bind = '<C-c>ro'
""
"My lessons on vim!
"* Learn to use :help, Google at last resort
"* Look for common mistakes, repetitive tasks, annoyances. Fix them using .vimrc
"* Use vimawesome.com, before installing any plugin.
"* Update your self, check the trends https://github.com/trending/vim-script
"* Learn vimscript, learnvimscriptthehardway.stevelosh.com
"* Maintain ~/.vimrc, remove unused plugin or bindings
"* remap <ESC>
"
"{{{ Remap esc
inoremap jk <esc>
inoremap kj <esc>
" Note: If its enabled, i get garabage terminal stuff in a line
" https://stackoverflow.com/questions/21618614/vim-shows-garbage-characters
"inoremap <esc> <nop>
"}}}
"
"{{{
" Yggdroot/identLine
" Dont conceal quotes in json
let g:vim_json_syntax_conceal = 0
let g:indentLine_concealcursor = 'inc'
let g:indentLine_conceallevel = 2
"}}}
" show invisible
set list listchars=tab:▸\ ,trail:·,precedes:←,extends:→,eol:↲,nbsp:␣
" }}}
" TODO:
" Use TaskList
" Use CtrlP
" Use python-mode
" Use ale
" check if python-mode rope conflict with ycm
"
"
" wayneye.com/vimrc
"***Language specified***
" shell (tab width 2 chr)
autocmd FileType json setlocal ts=2 sts=2 sw=2 textwidth=0 expandtab
autocmd FileType sh map <buffer> <C-S-e> :w<CR>:!/bin/sh % <CR>
" Json (tab width 2 chr)
autocmd FileType json setlocal ts=2 sts=2 sw=2 textwidth=0 expandtab
" Setup Omnicompletion
" Messing with pymode?
" TRYME disabled now to check jedi
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType c set omnifunc=ccomplete#Complete
"improve autocomplete menu color
highlight Pmenu ctermbg=238 gui=bold
"
"
" Abbrevations
iabbrev @@ ennc0d3@gmail.com
"{{{ GitGutter, too slow
set updatetime=100
nmap ]h <Plug>GitGutterNextHunk
nmap [h <Plug>GitGutterPrevHunk
nmap <Leader>ha <Plug>GitGutterStageHunk
nmap <Leader>hu <Plug>GitGutterUndoHunk
nmap <Leader>hv <Plug>GitGutterPreviewHunk
omap ih <Plug>GitGutterTextObjectInnerPending
omap ah <Plug>GitGutterTextObjectOuterPending
xmap ih <Plug>GitGutterTextObjectInnerVisual
xmap ah <Plug>GitGutterTextObjectOuterVisual
autocmd BufWritePost * GitGutter
" Default is against staging
"let g:gitgutter_diff_base = 'origin/master'
" Try this valuesjk
"let g:gitgutter_realtime = 0
"let g:gitgutter_eager = 0
" Profile it
"profile start gitter.log
"profile! file */vim-gitgutter/*
"autocmd BufWritePost * GitGutter
"}}}
"{{{
map <leader>N :NERDTreeToggle %<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
"}}}
"
"
"{{{
"" This enables us to undo files even if you exit Vim.
if has('persistent_undo')
set undofile
set undodir=~/.config/vim/tmp/undo//
endif
"}}}
"
"{{{
"" Enter automatically into the files directory
autocmd BufEnter * silent! lcd %:p:h
""}}}
"{{{
" Occasional tabuser tis 26 feb 2019 23:48:13 CET
nmap <silent> tt :tabnew<CR>
nmap <silent> [g :tabprevious<CR>
nmap <silent> ]g :tabnext<CR>
nmap <silent> [G :tabrewind<CR>
nmap <silent> ]G :tablast<CR>
""}}}
"""JEDI
let g:jedi#completions_enabled = 0 "Not using jedi auto-completions
let g:jedi#show_call_signatures = "1"
let g:jedi#use_splits_not_buffers = "right"
"" Highlight long lines > 120
highlight ColorColumn ctermbg=magenta
call matchadd('ColorColumn', '\%81v', 120)
" NOTES:
" q: - Dynamic list of commands run in command mode aka history
" :e <C-d> - List directories
" [count] {operator} {[count] motion|text object}
"
" ISSUES
" shift-K in vim-go enters to mode which writes jkjk
"
" Install pynvim in virtualenv .neovim
" Enable python 3 interface: pip3 install --user pynvim
let g:python3_host_prog="~/.neovim3/bin/python3.8.1"
if has('nvim')
" Enable deoplete on startup
let g:deoplete#enable_at_startup = 1
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.
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>
" Use U to show documentation in preview window
nnoremap <silent> U :call <SID>show_documentation()<CR>
" Added July 2020
au FileType go nmap <F10> :GoTest -short<cr>
au FileType go nmap <F9> :GoCoverageToggle -short<cr>
au FileType go nmap <F12> <Plug>(go-def)
"colorscheme zenburn
" To fix disappearing background color in vim when using kitty (xterm-kitty
" TERM)
let &t_ut=''