forked from jessfraz/.vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
782 lines (628 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
set nocompatible " be iMproved, required
" Need to set a couple os specific things
let s:uname = system("uname")
if s:uname == "Darwin\n"
let g:python_host_prog = expand('~/.pyenv/versions/global/bin/python')
let g:python3_host_prog = expand('~/.pyenv/versions/global/bin/python3')
set clipboard=unnamed
else
let g:python_host_prog = $HOME.'/.pyenv/versions/global/bin/python'
let g:python3_host_prog = $HOME.'/.pyenv/versions/global/bin/python3'
set clipboard=unnamedplus
endif
" Some plugins are hosted on GitLab, thus:
let gitlab = 'https://gitlab.com/'
" ----------------------------------------- "
" Plugins "
" ----------------------------------------- "
let data_dir = '~/.vim'
if empty(glob(data_dir . '/autoload/plug.vim'))
silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim_plugins')
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
" ----------------------------------------- "
" AutoComplete / Lint "
" ----------------------------------------- "
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'wellle/tmux-complete.vim'
Plug 'w0rp/ale'
Plug 'Raimondi/delimitMate'
Plug 'othree/javascript-libraries-syntax.vim'
Plug 'tmux-plugins/vim-tmux'
Plug 'scrooloose/nerdcommenter'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-sleuth'
Plug 'dhruvasagar/vim-table-mode'
Plug 'sheerun/vim-polyglot'
Plug 'godlygeek/tabular'
Plug 'puremourning/vimspector'
Plug 'heavenshell/vim-jsdoc', { 'for': 'js' }
Plug 'leafgarland/typescript-vim', { 'for': 'ts' }
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries', 'for': 'go' }
Plug 'plasticboy/vim-markdown', { 'for': ['md', 'markdown'] }
Plug 'vim-ruby/vim-ruby', { 'for': 'ruby' }
Plug 'tpope/vim-rails', { 'for': 'ruby' }
Plug 'mattn/emmet-vim', { 'for': 'html' }
Plug 'OmniSharp/omnisharp-vim', { 'for': 'cs' }
Plug 'OrangeT/vim-csharp', { 'for': 'cs' }
" ----------------------------------------- "
" Files / Finders "
" ----------------------------------------- "
Plug 'junegunn/fzf'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'Xuyuanp/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' }
Plug 'mcchrish/nnn.vim'
" ----------------------------------------- "
" Interface / Usability "
" ----------------------------------------- "
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'moll/vim-bbye'
Plug 'ap/vim-buftabline'
Plug 'ntpeters/vim-better-whitespace'
Plug 'nekowasabi/vim-sayonara', { 'commit': '7e774f58c5865d9c10d40396850b35ab95af17c5' }
Plug 'terryma/vim-multiple-cursors'
Plug 'ryanoasis/vim-devicons'
Plug 'preservim/tagbar'
Plug 'matze/vim-move'
Plug 'tmux-plugins/vim-tmux-focus-events'
" ----------------------------------------- "
" Git Integration "
" ----------------------------------------- "
Plug 'tpope/vim-fugitive'
Plug 'christoomey/vim-conflicted'
Plug 'airblade/vim-gitgutter'
" ----------------------------------------- "
" Snippets "
" ----------------------------------------- "
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'
Plug 'garbas/vim-snipmate'
Plug 'honza/vim-snippets'
" ----------------------------------------- "
" Misc "
" ----------------------------------------- "
Plug 'wakatime/vim-wakatime'
Plug gitlab.'dbeniamine/todo.txt-vim'
Plug 'tpope/vim-dadbod'
" All of your Plugins must be added before the following line
call plug#end()
" Source My Helpers
if has("win32") || has("win16")
source ~/vimfiles/helpers.vim
else
source ~/.vim/helpers.vim
endif
"
" Settings
"
set noerrorbells " No beeps
set number " Show line numbers
set backspace=indent,eol,start " Makes backspace key more powerful.
set showcmd " Show me what I'm typing
set showmode " Show current mode.
set noswapfile " Don't use swapfile
set nobackup " Don't create annoying backup files
set nowritebackup
set splitright " Split vertical windows right to the current windows
set splitbelow " Split horizontal windows below to the current windows
set encoding=utf-8 " Set default encoding to UTF-8
set autowrite " Automatically save before :next, :make etc.
set autoread " Automatically reread changed files without asking me anything
set laststatus=2
set hidden
set ruler " Show the cursor position all the time
au FocusLost * :wa " Set vim to save the file on focus out.
set fileformats=unix,dos,mac " Prefer Unix over Windows over OS 9 formats
set noshowmatch " Do not show matching brackets by flickering
set noshowmode " We show the mode with airline or lightline
set incsearch " Shows the match while typing
set hlsearch " Highlight found searches
set ignorecase " Search case insensitive...
set smartcase " ... but not when search pattern contains upper case characters
set ttyfast
set lazyredraw " Wait to redraw "
" speed up syntax highlighting
set nocursorcolumn
set nocursorline
syntax on
syntax sync minlines=256
set synmaxcol=300
set re=1
" open help vertically
command! -nargs=* -complete=help Help vertical belowright help <args>
autocmd FileType help wincmd L
" Make Vim to handle long lines nicely.
set wrap
set textwidth=79
set formatoptions=qrn1
set autoindent
set complete-=i
set showmatch
" Fix indentation
map <F7> gg=G<C-o><C-o>
set et
set tabstop=2
set shiftwidth=2
set expandtab
set nrformats-=octal
set shiftround
" Time out on key codes but not mappings.
" Basically this makes terminal Vim work sanely.
set notimeout
set ttimeout
set ttimeoutlen=10
" Better Completion
set complete=.,w,b,u,t
set completeopt=menu,menuone,preview,noselect,noinsert
if &history < 1000
set history=50
endif
if &tabpagemax < 50
set tabpagemax=50
endif
if !empty(&viminfo)
set viminfo^=!
endif
if !&scrolloff
set scrolloff=1
endif
if !&sidescrolloff
set sidescrolloff=5
endif
set display+=lastline
" Code folding
set foldmethod=indent
set foldnestmax=10
set nofoldenable
set foldlevel=2
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
" In many terminal emulators the mouse works just fine, thus enable it.
if has('mouse')
set mouse=a
endif
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
" Also don't do it when the mark is in the first line, that is the default
" position when opening a file.
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
else
endif " has("autocmd")
" Triger `autoread` when files changes on disk
" https://unix.stackexchange.com/questions/149209/refresh-changed-content-of-file-opened-in-vim/383044#383044
" https://vi.stackexchange.com/questions/13692/prevent-focusgained-autocmd-running-in-command-line-editing-mode
autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif
" Notification after file change
" https://vi.stackexchange.com/questions/13091/autocmd-event-for-autoread
autocmd FileChangedShellPost *
\ echohl WarningMsg | echo "File changed on disk. Buffer reloaded." | echohl None
syntax enable
if has('gui_running')
set transparency=3
" fix js regex syntax
set regexpengine=1
syntax enable
endif
set background=dark
" let g:solarized_termcolors=256
" let g:solarized_termtrans=1
set t_Co=256
colorscheme PaperColor
set guifont=FiraCode:h15
set guioptions-=L
" This comes first, because we have mappings that depend on leader
" With a map leader it's possible to do extra key combinations
" i.e: <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" This trigger takes advantage of the fact that the quickfix window can be
" easily distinguished by its file-type, qf. The wincmd J command is
" equivalent to the Ctrl+W, Shift+J shortcut telling Vim to move a window to
" the very bottom (see :help :wincmd and :help ^WJ).
autocmd FileType qf wincmd J
" Some useful quickfix/location list shortcuts
":cc see the current error
":cn next error
":cp previous error
":clist list all errors
nnoremap <leader>s :cclose<CR>
nnoremap <leader>ls :lclose<CR>
nnoremap <leader>a :copen<CR>
nnoremap <leader>la :lopen<CR>
nnoremap <leader>n :cn<CR>
nnoremap <leader>ln :ln<CR>
nnoremap <leader>p :cp<CR>
nnoremap <leader>lp :lp<CR>
nnoremap <leader>l :clist<CR>
" Replace the current buffer with the given new file. That means a new file
" " will be open in a buffer while the old one will be deleted
com! -nargs=1 -complete=file Breplace edit <args>| bdelete #
function! DeleteInactiveBufs()
"From tabpagebuflist() help, get a list of all buffers in all tabs
let tablist = []
for i in range(tabpagenr('$'))
call extend(tablist, tabpagebuflist(i + 1))
endfor
"Below originally inspired by Hara Krishna Dara and Keith Roberts
"http://tech.groups.yahoo.com/group/vim/message/56425
let nWipeouts = 0
for i in range(1, bufnr('$'))
if bufexists(i) && !getbufvar(i,"&mod") && index(tablist, i) == -1
"bufno exists AND isn't modified AND isn't in the list of buffers open in windows and tabs
silent exec 'bwipeout' i
let nWipeouts = nWipeouts + 1
endif
endfor
echomsg nWipeouts . ' buffer(s) wiped out'
endfunction
command! Ball :call DeleteInactiveBufs()
" Remove search highlight
nnoremap <leader><space> :nohlsearch<CR>
" Buffer prev/next
nnoremap <C-x> :bnext<CR>
nnoremap <C-z> :bprev<CR>
" Better split switching
map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l
" Fast saving
nmap <leader>w :w!<cr>
" Center the screen
nnoremap <space> zz
" Move up and down on splitted lines (on small width screens)
map <Up> gk
map <Down> gj
map k gk
map j gj
" Just go out in insert mode
imap jk <ESC>l
nnoremap <F6> :setlocal spell! spell?<CR>
" Select search pattern howewever do not jump to the next one
nnoremap <leader>c :TComment<CR>
" Search mappings: These will make it so that going to the next one in a
" search will center on the line it's found in.
nnoremap n nzzzv
nnoremap N Nzzzv
autocmd BufEnter * silent! lcd %:p:h
" trim all whitespaces away
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
" Act like D and C
nnoremap Y y$
" Do not show stupid q: window
map q: :q
" sometimes this happens and I hate it
map :Vs :vs
map :Sp :sp
" dont save .netrwhist history
let g:netrw_dirhistmax=0
" Allow saving of files as sudo when I forgot to start vim using sudo.
cmap w!! w !sudo tee > /dev/null %
" never do this again --> :set paste <ctrl-v> :set no paste
let &t_SI .= "\<Esc>[?2004h"
let &t_EI .= "\<Esc>[?2004l"
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin()
function! XTermPasteBegin()
set pastetoggle=<Esc>[201~
set paste
return ""
endfunction
" set 80 character line limit
if exists('+colorcolumn')
set colorcolumn=80
else
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
endif
" Insert current datetime
nnoremap <leader>D :put =strftime('%a %Y-%m-%d %H:%M:%S%z') <CR>
" Get current file path
nnoremap <leader>P :let @+ = expand("%:p")<cr>
" ----------------------------------------- "
" File Type settings "
" ----------------------------------------- "
au BufNewFile,BufRead *.vim setlocal noet ts=2 sw=2 sts=2
au BufNewFile,BufRead *.txt setlocal noet ts=2 sw=2
au BufNewFile,BufRead *.md setlocal spell noet ts=2 sw=2
au BufNewFile,BufRead *.yml,*.yaml setlocal expandtab ts=2 sw=2
au BufNewFile,BufRead *.json setlocal expandtab ts=2 sw=2
au BufNewFile,BufRead *.js setlocal expandtab ts=2 sw=2
au BufNewFile,BufRead *.html setlocal expandtab ts=2 sw=2
augroup filetypedetect
au BufNewFile,BufRead .tmux.conf*,tmux.conf* setf tmux
au BufNewFile,BufRead .nginx.conf*,nginx.conf* setf nginx
augroup END
au FileType nginx setlocal noet ts=4 sw=4 sts=4
" Go settings
au BufNewFile,BufRead *.go setlocal noet ts=4 sw=4 sts=4
" Markdown Settings
autocmd BufNewFile,BufReadPost *.md setl ts=4 sw=4 sts=4 expandtab
" shell/config/systemd settings
autocmd FileType gitconfig,sh,toml set noexpandtab
" toml settings
au BufRead,BufNewFile MAINTAINERS set ft=tom
" spell check for git commits
autocmd FileType gitcommit setlocal spell
" curl bindings
au BufNewFile,BufRead *.curl setlocal filetype=curl syntax=bash
autocmd FileType curl nmap <buffer> <leader>r vipyPgvO<Esc>O<Esc>gv:!curl --config -<CR> <bar> :-1 <bar> :put =strftime('# %a %Y-%m-%d %H:%M:%S%z') <CR>
" Wildmenu completion {{{
set wildmenu
" set wildmode=list:longest
set wildmode=list:full
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.DS_Store " OSX bullshit
set wildignore+=go/pkg " Go static files
set wildignore+=go/bin " Go bin files
set wildignore+=go/bin-vagrant " Go bin-vagrant files
set wildignore+=*.orig " Merge resolution files
" ----------------------------------------- "
" Plugin configs "
" ----------------------------------------- "
" ========= Vundle ==================================== "
map :pi :PluginInstall
" ========= deoplete ================================== "
let g:deoplete#enable_at_startup = 1
call deoplete#custom#option({
\ 'auto_refresh_delay': 0,
\ 'num_processes': 5,
\ })
call deoplete#custom#option('yarp', v:true)
" <TAB>: completion.
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" ========= A.L.E ===================================== "
" AutoComplete
" Key Mapping
nnoremap <leader>gd :ALEGoToDefinition<CR>
nnoremap <leader>gr :ALEFindReferences<CR>
nnoremap <leader>gt :ALEHover<CR>
nmap <silent> <C-a> <Plug>(ale_previous_wrap)
nmap <silent> <C-s> <Plug>(ale_next_wrap)
let g:ale_fixers = {
\ 'javascript': ['eslint', 'prettier'],
\ 'go': ['gofmt', 'goimports'],
\ 'python': ['autopep8'],
\ }
let g:ale_linters = {
\ 'go': ['govet', 'gofmt', 'golint', 'gopls'],
\ 'python': ['pylint', 'flake8', 'pylsp'],
\ 'cs': ['OmniSharp'],
\ }
" Python Config
let g:ale_python_pylint_options = '--load-plugins pylint_sqlalchemy'
" Turn some things on
let g:ale_fix_on_save = 1
let g:airline#extensions#ale#enabled = 1
" AutoComplete
let g:ale_completion_enabled = 1
set omnifunc=ale#completion#OmniFunc
" ========= fzf ======================================= "
set rtp+=~/.fzf
function! s:find_git_root()
return system('git rev-parse --show-toplevel 2> /dev/null')[:-2]
endfunction
command! ProjectFiles execute 'FZF ' s:find_git_root()
map <C-p> :ProjectFiles<CR>
" ========= delimitMate =============================== "
let g:delimitMate_expand_cr = 1
let g:delimitMate_expand_space = 1
let g:delimitMate_smart_quotes = 1
let g:delimitMate_expand_inside_quotes = 0
let g:delimitMate_smart_matchpairs = '^\%(\w\|\$\)'
"========== NerdTree ================================== "
" For toggling
command! NTToggle execute 'NERDTreeToggle' s:find_git_root()
nmap <C-n> :NTToggle<CR>
nmap <C-f> :NERDTreeFind<CR>
let NERDTreeShowHidden=1
let NERDTreeIgnore=['\~$', '\.git$', '.DS_Store', 'node_modules', '.vscode','.venv','__pycache__', '.pyc', '*.egg-info']
" Close nerdtree and vim on close file
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
"========== NerdTree ================================== "
nnoremap <silent> <leader>f :NnnPicker<CR>
let g:nnn#command = 'nnn -d ' . s:find_git_root()
let g:nnn#set_default_mappings = 0
let g:nnn#layout = { 'window': { 'width': 0.9, 'height': 0.6, 'highlight': 'Debug' } }
let g:nnn#action = {
\ '<c-t>': 'tab split',
\ '<c-x>': 'split',
\ '<c-v>': 'vsplit' }
" ========= vim-airline =============================== "
let g:airline_theme='hybridline'
" set to use powerline fonts when not in a ssh session
let g:remoteSession = ($STY == "")
if !g:remoteSession
let g:airline_powerline_fonts=1
endif
" ========= vim-better-whitespace ===================== "
" auto strip whitespace except for file with extention blacklisted
let blacklist = ['diff', 'gitcommit', 'unite', 'qf', 'help', 'markdown']
autocmd BufWritePre * if index(blacklist, &ft) < 0 | StripWhitespace
" ========= vim-markdown ==================
" disable folding
let g:vim_markdown_folding_disabled = 1
" Allow for the TOC window to auto-fit when it's possible for it to shrink.
" It never increases its default size (half screen), it only shrinks.
let g:vim_markdown_toc_autofit = 1
" Disable conceal
let g:vim_markdown_conceal = 0
" Allow the ge command to follow named anchors in links of the form
" file#anchor or just #anchor, where file may omit the .md extension as usual
let g:vim_markdown_follow_anchor = 1
" highlight frontmatter
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_toml_frontmatter = 1
let g:vim_markdown_json_frontmatter = 1
" ========= Terraform ================================= "
let g:terraform_align=1
let g:terraform_fold_sections=1
let g:terraform_commentstring='//%s'
let g:terraform_fmt_on_save=1
" ========= Sayonara ================================== "
nnoremap <silent> <leader>q :Sayonara!<CR>
" ========= JsDoc ===================================== "
let g:jsdoc_allow_input_prompt = 1
let g:jsdoc_enable_es6 = 1
nnoremap <leader>jd :JsDoc<CR>
" ========= vim-multiple-cursors ====================== "
let g:multi_cursor_use_default_mapping=0
let g:multi_cursor_next_key='<C-i>'
let g:multi_cursor_prev_key='<C-y>'
let g:multi_cursor_skip_key='<C-b>'
let g:multi_cursor_quit_key='<Esc>'
" ========= SnipMate ================================== "
"to prevent clash with youcompleteme, change snippet trigger
let g:snipMate = { 'snippet_version' : 1 }
imap <C-J> <esc>a<Plug>snipMateNextOrTrigger
smap <C-J> <Plug>snipMateNextOrTrigger
" ========= TagBar ==================================== "
nmap <F8> :TagbarToggle<CR>
" ========= TableMode ================================= "
let g:table_mode_corner='|'
function! s:isAtStartOfLine(mapping)
let text_before_cursor = getline('.')[0 : col('.')-1]
let mapping_pattern = '\V' . escape(a:mapping, '\')
let comment_pattern = '\V' . escape(substitute(&l:commentstring, '%s.*$', '', ''), '\')
return (text_before_cursor =~? '^' . ('\v(' . comment_pattern . '\v)?') . '\s*\v' . mapping_pattern . '\v$')
endfunction
inoreabbrev <expr> <bar><bar>
\ <SID>isAtStartOfLine('\|\|') ?
\ '<c-o>:TableModeEnable<cr><bar><space><bar><left><left>' : '<bar><bar>'
inoreabbrev <expr> __
\ <SID>isAtStartOfLine('__') ?
\ '<c-o>:silent! TableModeDisable<cr>' : '__'
" ========= vim-jsx =================================== "
let g:jsx_ext_required = 0
" ========= Fugitive ================================== "
nnoremap <leader>gb :Gblame<CR>
nnoremap <leader>gw :Gwrite<CR>
" ========= Vim Todo.txt =========================== "
au filetype todo setlocal omnifunc=todo#Complete
" ========= Vim DadBod ============================== "
"" operator mapping
func! DBExe(...)
if !a:0
let &operatorfunc = matchstr(expand('<sfile>'), '[^. ]*$')
return 'g@'
endif
let sel_save = &selection
let &selection = "inclusive"
let reg_save = @@
if a:1 == 'char' " Invoked from Visual mode, use gv command.
silent exe 'normal! gvy'
elseif a:1 == 'line'
silent exe "normal! '[V']y"
else
silent exe 'normal! `[v`]y'
endif
execute "DB " . @@
let &selection = sel_save
let @@ = reg_save
endfunc
" Source my Config
call SourceIfExists("~/.local_config/dadbod.vim")
command! DBSelect :call popup_menu(map(copy(g:dadbods), {k,v -> v.name}), #{
\callback: 'DBSelected'
\})
func! DBSelected(id, result)
if a:result != -1
let b:db = g:dadbods[a:result-1].url
echomsg 'DB ' . g:dadbods[a:result-1].name . ' is selected.'
endif
endfunc
xnoremap <expr> <Plug>(DBExe) DBExe()
nnoremap <expr> <Plug>(DBExe) DBExe()
nnoremap <expr> <Plug>(DBExeLine) DBExe() . '_'
xmap <leader>db <Plug>(DBExe)
nmap <leader>db <Plug>(DBExe)
omap <leader>db <Plug>(DBExe)
nmap <leader>dbb <Plug>(DBExeLine)
" ================== Emmet-Vim ========================="
let g:user_emmet_leader_key='<C-c>'
" ================== OmniSharp ===================="
" Don't autoselect first omnicomplete option, show options even if there is only
" one (so the preview documentation is accessible). Remove 'preview', 'popup'
" and 'popuphidden' if you don't want to see any documentation whatsoever.
" Note that neovim does not support `popuphidden` or `popup` yet:
" https://github.com/neovim/neovim/issues/10996
if has('patch-8.1.1880')
set completeopt=longest,menuone,popuphidden
" Highlight the completion documentation popup background/foreground the same as
" the completion menu itself, for better readability with highlighted
" documentation.
set completepopup=highlight:Pmenu,border:off
else
set completeopt=longest,menuone,preview
" Set desired preview window height for viewing documentation.
set previewheight=5
endif
let g:OmniSharp_server_stdio=1
augroup omnisharp_commands
autocmd!
" Show type information automatically when the cursor stops moving.
" Note that the type is echoed to the Vim command line, and will overwrite
" any other messages in this space including e.g. ALE linting messages.
autocmd CursorHold *.cs OmniSharpTypeLookup
" The following commands are contextual, based on the cursor position.
autocmd FileType cs nmap <silent> <buffer> gd <Plug>(omnisharp_go_to_definition)
autocmd FileType cs nmap <silent> <buffer> <Leader>osfu <Plug>(omnisharp_find_usages)
autocmd FileType cs nmap <silent> <buffer> <Leader>osfi <Plug>(omnisharp_find_implementations)
autocmd FileType cs nmap <silent> <buffer> <Leader>ospd <Plug>(omnisharp_preview_definition)
autocmd FileType cs nmap <silent> <buffer> <Leader>ospi <Plug>(omnisharp_preview_implementations)
autocmd FileType cs nmap <silent> <buffer> <Leader>ost <Plug>(omnisharp_type_lookup)
autocmd FileType cs nmap <silent> <buffer> <Leader>osd <Plug>(omnisharp_documentation)
autocmd FileType cs nmap <silent> <buffer> <Leader>osfs <Plug>(omnisharp_find_symbol)
autocmd FileType cs nmap <silent> <buffer> <Leader>osfx <Plug>(omnisharp_fix_usings)
autocmd FileType cs nmap <silent> <buffer> <C-\> <Plug>(omnisharp_signature_help)
autocmd FileType cs imap <silent> <buffer> <C-\> <Plug>(omnisharp_signature_help)
" Navigate up and down by method/property/field
autocmd FileType cs nmap <silent> <buffer> [[ <Plug>(omnisharp_navigate_up)
autocmd FileType cs nmap <silent> <buffer> ]] <Plug>(omnisharp_navigate_down)
" Find all code errors/warnings for the current solution and populate the quickfix window
autocmd FileType cs nmap <silent> <buffer> <Leader>osgcc <Plug>(omnisharp_global_code_check)
" Contextual code actions (uses fzf, CtrlP or unite.vim selector when available)
autocmd FileType cs nmap <silent> <buffer> <Leader>osca <Plug>(omnisharp_code_actions)
autocmd FileType cs xmap <silent> <buffer> <Leader>osca <Plug>(omnisharp_code_actions)
" Repeat the last code action performed (does not use a selector)
autocmd FileType cs nmap <silent> <buffer> <Leader>os. <Plug>(omnisharp_code_action_repeat)
autocmd FileType cs xmap <silent> <buffer> <Leader>os. <Plug>(omnisharp_code_action_repeat)
autocmd FileType cs nmap <silent> <buffer> <Leader>os= <Plug>(omnisharp_code_format)
autocmd FileType cs nmap <silent> <buffer> <Leader>osnm <Plug>(omnisharp_rename)
autocmd FileType cs nmap <silent> <buffer> <Leader>osre <Plug>(omnisharp_restart_server)
autocmd FileType cs nmap <silent> <buffer> <Leader>osst <Plug>(omnisharp_start_server)
autocmd FileType cs nmap <silent> <buffer> <Leader>ossp <Plug>(omnisharp_stop_server)
augroup END
" ================== vim-csharp ===================="
au BufNewFile,BufRead *.razor compiler msbuild | set filetype=cshtml.html syntax=cshtml
" ================== vimspector ===================="
let g:vimspector_enable_mappings = 'HUMAN'
let g:vimspector_install_gadgets = [ 'debugpy', 'vscode-go' ]