-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_vimrc
More file actions
911 lines (737 loc) · 25.8 KB
/
Copy pathdot_vimrc
File metadata and controls
911 lines (737 loc) · 25.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
" Vim configuration file
" Author: Jonathan Filip
" Enhancements: Robert Forler
" ============================================================================
" Setup:
" ============================================================================
set nocompatible
" Set location so we can set variables accordingly
let location = "home_osx"
if exists("$CITADEL_ENV")
if has("win32") || has("win64")
let location="work_win"
else
let location="work_linux"
endif
elseif has("win32") || has("win64")
let location="home_win"
endif
function! InLocation(...)
for l in a:000
if g:location == l
return 1
endif
endfor
return 0
endfunction
" ============================================================================
" General Options:
" ============================================================================
set shortmess=flmnrxIstToO
set showmode
set history=1000
set nofoldenable foldmethod=manual
set browsedir=buffer
set shellslash
set hidden
set tags=./tags;/.
set signcolumn=auto " automatically closes the bar on the left if no errors
if has("gui_running")
set rtp+=$HOME\vimfiles\bundle\Vundle.vim\
else
set rtp+=~/.vim/bundle/Vundle.vim,~/.local/share/vim
endif
let $GIT_SSL_NO_VERIFY='true'
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.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
" Begin Vundle plugin management
call plug#begin('~/.vim/plugged')
Plug 'dense-analysis/ale'
Plug 'gmarik/Vundle.vim'
Plug 'kien/ctrlp.vim'
Plug 'FelikZ/ctrlp-py-matcher' " speeds up ctrlp search considreably
"Plug 'scrooloose/syntastic' " flake8-vim is much faster and easier to use
"Plug 'ervandew/supertab'
if !has("gui_running") && !has("nvim")
Plug 'SirVer/ultisnips'
endif
Plug 'phubaba/vim-snippets'
Plug 'bkad/CamelCaseMotion'
Plug 'hdima/python-syntax'
"Plug 'hynek/vim-python-pep8-indent'
Plug 'bling/vim-airline'
Plug 'jonathanfilip/vim-lucius'
Plug 'tpope/vim-abolish'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-fugitive'
Plug 'terryma/vim-multiple-cursors'
Plug 'mileszs/ack.vim'
"Plug 'Valloric/YouCompleteMe'
Plug 'lokaltog/vim-easymotion'
Plug 'vim-scripts/AutoComplPop' " goto http://vim-scripts.org/vim/scripts.html
Plug 'vim-scripts/Efficient-python-folding'
Plug 'vim-scripts/LargeFile'
"Plug 'andviro/flake8-vim'
"Plug 'Townk/vim-autoclose'
Plug 'Raimondi/delimitMate'
Plug 'chazy/cscope_maps'
"Plug 'python-rope/ropevim'
Plug 'richsoni/vim-ecliptic'
Plug 'vim-test/vim-test'
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-projectionist'
"Plug 'tomasr/molokai'
"Plug 'ivalkeen/vim-ctrlp-tjump'
"Plug 'fisadev/vim-ctrlp-cmdpalette'
"Plug 'Keithbsmiley/investigate.vim'
" LSP {{{
Plug 'prabirshrestha/vim-lsp' " async LSP for vim8 and neovim
Plug 'prabirshrestha/asyncomplete.vim' " async autocompletion
Plug 'prabirshrestha/asyncomplete-lsp.vim' " provides LSP autocompletion source for asyncomplete.vim
Plug 'mattn/vim-lsp-settings' " simplify installing and registering language servers
"TODO try this?
"Plug 'rhysd/vim-lsp-ale' " simplify installing and registering language servers
"Plug 'thomasfaingnaert/vim-lsp-snippets'
"Plug 'thomasfaingnaert/vim-lsp-ultisnips'
" }}}
call plug#end()
if !has("gui_running") && !has("nvim")
"once TERM=xterm-256color i didnt need any of this anymore
"set termguicolors
"set t_Co=256
"set t_ut=
"set term=xterm-256color
endif
if !has("gui_running") && has("clipboard")
set clipboard=unnamedplus
endif
colorscheme lucius
if has("gui_running")
LuciusDark
"LuciusLight
else
"LuciusLight
LuciusDark
endif
syntax on
set wildignore+=.svn\*,*.pyc,*.pyo,*.so,*.o,*.dll,*.lib,*.pyd
set wildignore+=*.obj,*.h5,*.ttf,*.pdf,*.xls,*.pcl,*.gz,*.png
set wildignore+=*.gif,*.jpg,*.ico,*.bak,*~
set wildignore+=*.sln,*.csproj,*.resx,*.suo
set wildignore+=*.exe,*.pdb,*.map
set wildignore+=*.doc
set wildignore+=tmp,tags,cscope.out
" ============================================================================
" UI Options:
" ============================================================================
set cmdheight=1
set completeopt=longest,menu complete=.,w,b,u
set confirm
set guioptions=egc
set laststatus=2
set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$
set fillchars=
set mouse=a
set mousehide
if !has('nvim')
set ttymouse=xterm2
endif
set noequalalways
set noerrorbells visualbell t_vb=
if has('autocmd')
autocmd GUIEnter * set visualbell t_vb=
endif
"set noerrorbells
"set novisualbell
set ruler showcmd
set scrollopt=jump,ver,hor
set showtabline=1
set sidescroll=10
set splitbelow splitright
set statusline=%<%f\ %h%m%r%y[%{&ff}]%=%-14.(%l,%c%V%)\ %P
set wildmenu wildmode=list:longest,full
set winminheight=0 winminwidth=0
set ignorecase incsearch hlsearch smartcase
if has("gui_running")
set title
if InLocation("home_osx")
set lines=80 columns=200 fuoptions=maxvert,maxhorz
else
set lines=60 columns=160
endif
if has("gui_win32") || has ("gui_win64")
set guifont=Consolas:h10
elseif has("gui_macvim")
set guifont=Consolas:h13
endif
else
set guioptions+=aA
endif
" ============================================================================
" File Options:
" ============================================================================
filetype plugin indent on
set autoread
set encoding=utf-8
set fileformats=unix,dos
set nobackup nowritebackup noswapfile
" ============================================================================
" Editting Options:
" ============================================================================
set autoindent
set backspace=indent,eol,start
set formatoptions=tcrqn
set nowrap nojoinspaces
set showmatch
set tabstop=4 softtabstop=4 shiftwidth=4 expandtab smarttab shiftround
set virtualedit=block
set whichwrap+=<,>,h,l
if version >= 703 && !has("nvim")
set cryptmethod=blowfish
endif
" ============================================================================
" Key Mappings:
" ============================================================================
let mapleader = ";"
let maplocalleader = ";"
" Indenting in visual mode
vnoremap <tab> >gv
vnoremap <s-tab> <gv
vnoremap > >gv
vnoremap < <gv
vnoremap <BS> d
if InLocation("home_osx")
inoremap <A-BS> <C-w>
elseif InLocation("home_win") || InLocation("work_win")
inoremap <C-BS> <C-w>
endif
map <Leader>gq gqap
" Select up to the next non-text blob
vmap <C-j> /^[^a-zA-Z0-9]*$<CR>k
vmap <C-k> ?^[^a-zA-Z0-9]*$<CR>j
" Buffer contorls
noremap <silent> <leader>n :bnext<CR>
noremap <silent> <leader>p :bprev<CR>
" Diff commands
noremap <silent> <leader>dt :diffthis<CR>
noremap <silent> <leader>do :diffoff!<CR>
" Window control
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-h> <C-w>h
nmap <C-l> <C-w>l
" Resize windows
if has("gui_running")
nnoremap <S-Up> 10<C-W>+
nnoremap <S-Down> 10<C-W>-
nnoremap <S-Left> 10<C-W><
nnoremap <S-Right> 10<C-W>>
else
nnoremap <Up> 10<C-W>+
nnoremap <Down> 10<C-W>-
nnoremap <Left> 10<C-W><
nnoremap <Right> 10<C-W>>
endif
" move and resize
nnoremap <C-b> :vertical resize -15<cr>
nnoremap <C-e> :vertical resize +15<cr>
" maximize and minimize windows
nnoremap <C-W>M <C-W>\|<C-W>_
nnoremap <C-W>m <C-W>=
" Splitting
noremap <leader>sp :split<CR>
noremap <leader>vs :vsplit<CR>
" Shortcuts for clipboard copy/pasting
vnoremap zp "*p
vnoremap zy "*y
noremap zp "*p
noremap zy "*y
" Make x not yank to register
noremap x "_x
" CTRL-A is Select all, etc
if !InLocation("home_osx")
noremap <C-A> ggVG
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG
noremap <C-S> :w<CR>
endif
" Color scheme
nnoremap <F2> :LuciusLight<CR>
nnoremap <S-F2> :LuciusDark<CR>
nnoremap <C-F2> :LuciusDarkDim<CR>
" Windows copy, cut, and paste
if has("win32") || has("win64")
exe 'inoremap <script> <C-V>' paste#paste_cmd['i']
exe 'vnoremap <script> <C-V>' paste#paste_cmd['v']
" Fix shift + insert to use the paste scripts too
imap <S-Insert> <C-V>
vmap <S-Insert> <C-V>
" Use CTRL-Q to do what CTRL-V used to do
noremap <C-Q> <C-V>
" CTRL-X and SHIFT-Del are Cut
vnoremap <C-X> "+x
vnoremap <S-Del> "+x
" CTRL-C and CTRL-Insert are Copy
vnoremap <C-C> "+y
vnoremap <C-Insert> "+y
" CTRL-V and SHIFT-Insert are Paste
map <C-V> "+gP
map <S-Insert> "+gP
" Command mode paste
cmap <C-V> <C-R>+
cmap <S-Insert> <C-R>+
endif
" Don't bring up help on F1
map <F1> <ESC>
imap <F1> <ESC>
" Disable middle mouse button pasting
map <MiddleMouse> <Nop>
imap <MiddleMouse> <Nop>
map <2-MiddleMouse> <Nop>
imap <2-MiddleMouse> <Nop>
map <3-MiddleMouse> <Nop>
imap <3-MiddleMouse> <Nop>
map <4-MiddleMouse> <Nop>
imap <4-MiddleMouse> <Nop>
" Get rid of Ex mode
nnoremap <S-Q> <Q>
"Clear searches
nnoremap <C-f> :nohlsearch<Bar>:echo<CR>
" ============================================================================
" Commands:
" ============================================================================
command! -nargs=1 Title :set title titlestring=<args>
" Strip extra whitespace
command! Strip %s/\s\+$//
command! ReloadConfig :source ~/vimfiles/vimrc.vim
command! Config :e ~/vimfiles/vimrc.vim
command! Notes :cd ~/notes
" Change directory to current buffer
command! CD :lcd %:p:h
" More lenient to save command
command! W w
command! Q q
command! QA qa
command! Qa qa
command! Wq wq
command! WQ wq
" ============================================================================
" Plugin Options:
" ============================================================================
" ----------------------------------------------------------------------------
" Airline:
" ----------------------------------------------------------------------------
let g:airline_left_sep=''
let g:airline_right_sep=''
" ----------------------------------------------------------------------------
" ALE {{{
" ----------------------------------------------------------------------------
let g:ale_lint_on_text_changed='normal'
let g:ale_lint_on_insert_leave=1
let g:ale_set_highlights=1
let g:ale_set_signs=1
let g:ale_set_balloons=0
let in_jcs = isdirectory('/jcs')
if in_jcs
let g:ale_linters={
\ 'cpp': ['gcc'],
\ 'python': ['flake8']
\ }
let g:ale_fixers={
\ 'python': ['black']
\ }
let g:ale_cpp_gcc_options='-std=c++14 -Wall -Wextra -Wpedantic -Wconversion'
else
let g:ale_linters={
\ 'cpp': ['gcc'],
\ 'python': ['flake8', 'pylint', 'pydocstyle']
\ }
let g:ale_fixers={
\ 'python': ['black', 'isort']
\ }
let g:ale_cpp_gcc_options='-std=c++14 -Wall -Wextra -Wpedantic -Wconversion'
let g:ale_python_flake8_options='--ignore=E203,E501,W503'
endif
" asyncomplete {{{
let g:asyncomplete_auto_popup=0 " disable auto popup since we define a mapping to use tab for autocompletion
" Autoclose preview window when completion is done
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
" Use tab to trigger autocompletion
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ asyncomplete#force_refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
" }}}
" ----------------------------------------------------------------------------
" Ctags:
" ----------------------------------------------------------------------------
let g:ctags_bin = "ctags"
" ----------------------------------------------------------------------------
" Cpp Omnicomplete:
" ----------------------------------------------------------------------------
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_NamespaceSearch = 2
let OmniCpp_ShowPrototypeInAbbr = 1
" ----------------------------------------------------------------------------
" CScope:
" ----------------------------------------------------------------------------
"if has("cscope")
" set cscopequickfix=s-,c-,d-,i-,t-,e-
" if filereadable("cscope.out")
" set cscopetagorder=0
" set cscopetag
" set nocscopeverbose
" cs add cscope.out
" "set cscopeverbose
" endif
" " View the tag (g-] behavior)
" nmap <C-@>v :tselect <C-R>=expand("<cword>")<CR><CR>
" " Find this C symbol
" nmap <C-@>s :lcscope find s <C-R>=expand("<cword>")<CR><CR>
" " Find this definition
" nmap <C-@>g :lcscope find g <C-R>=expand("<cword>")<CR><CR>
" " Find functions called by this function
" nmap <C-@>d :lcscope find d <C-R>=expand("<cword>")<CR><CR>
" " Find functions calling this function
" nmap <C-@>c :lcscope find c <C-R>=expand("<cword>")<CR><CR>
" " Find this text string
" nmap <C-@>t :lcscope find t <C-R>=expand("<cword>")<CR><CR>
" " Find this egrep pattern
" nmap <C-@>e :lcscope find e <C-R>=expand("<cword>")<CR><CR>
" " Find this file
" nmap <C-@>f :lcscope find f <C-R>=expand("<cword>")<CR><CR>
" " Find files #including this file
" nmap <C-@>i :lcscope find i <C-R>=expand("<cword>")<CR><CR>
"endif
" ----------------------------------------------------------------------------
" CtrlP:
" ----------------------------------------------------------------------------
let g:ctrlp_max_files = 0
let g:ctrlp_max_depth = 10
let g:ctrlp_working_path_mode = 0
let g:ctrlp_show_hidden = 0
let g:ctrlp_max_height = 20
let g:ctrlp_clear_cache_on_exit = 0
let g:ctrlp_lazy_update = 0
let g:ctrlp_buftag_ctags_bin = g:ctags_bin
let g:ctrlp_switch_buffer = 'vh'
let g:ctrlp_extensions = ['buffertag']
let g:ctrlp_custom_ignore = {
\ 'dir': 'env$',
\ 'file': '',
\ }
"leverage ctrlp-py-matcher to go faster
let g:ctrlp_match_func = { 'match': 'pymatcher#PyMatch' }
noremap <silent> <leader>ff :CtrlP<CR>
noremap <silent> <leader>fb :CtrlPBuffer<CR>
noremap <silent> <leader>fr :CtrlPMRU<CR>
noremap <silent> <leader>ft :CtrlPBufTag<CR>
" ----------------------------------------------------------------------------
" Dbext:
" ----------------------------------------------------------------------------
let g:dbext_default_prompt_for_parameters = 0
let g:dbext_default_display_cmd_line = 1
let g:dbext_default_SQLITE_bin = "sqlite3"
let g:dbext_default_history_file = "$HOME/.dbext_sql_history.txt"
" ----------------------------------------------------------------------------
" NERD Commenter:
" ----------------------------------------------------------------------------
let NERDShutUp = 1
let NERDRemoveExtraSpaces=0
" ----------------------------------------------------------------------------
" NERD Tree:
" ----------------------------------------------------------------------------
let g:NERDTreeChDirMode = 0
let g:NERDChristmasTree = 1
let g:NERDTreeCaseSensitiveSort = 0
let g:NERDTreeIgnore = ['\.doc$', '\.pdf$', '\.xls$', '\.docx$',
\'\.zip$', '\.dll$', '\.so$', '\.pyc$', '\~$']
let g:NERDTreeShowHidden = 0
let g:NERDTreeWinPos = 'left'
let g:NERDTreeWinSize = 32
map <F3> :NERDTreeToggle<CR>
map <C-F3> :NERDTree<CR>
map <S-F3> :NERDTreeClose<CR>
" ----------------------------------------------------------------------------
" Python:
" ----------------------------------------------------------------------------
let python_highlight_all = 1
au BufEnter *.py :syntax sync fromstart " helps with ''' comments
let g:pyindent_open_paren = "&sw"
let g:pyindent_nested_paren = "&sw"
let g:pyindent_continue = "&sw"
" ----------------------------------------------------------------------------
" SQLUtilities:
" ----------------------------------------------------------------------------
let g:sql_type_default = "sqlanywhere"
let g:sqlutil_align_where = 0
let g:sqlutil_align_comma = 1
let g:sqlutil_align_first_word = 1
let g:sqlutil_keyword_case = '\L'
" ----------------------------------------------------------------------------
" SuperTab:
" ----------------------------------------------------------------------------
let SuperTabDefaultCompletionType = "context"
let SuperTabContextDefaultCompletionType = "<c-n>"
let SuperTabContextTextOmniPrecedence = ["&completefunc"]
au BufEnter *.md,*.txt,*.wiki :let b:SuperTabNoCompleteAfter = g:SuperTabNoCompleteAfter + ['\.', '\*', '-', ')']
" ----------------------------------------------------------------------------
" Flake8-vim
" ----------------------------------------------------------------------------
let g:PyFlakeCheckers = 'frosted,pep8'
let g:PyFlakeDisabledMessages = 'E203,E501,W503'
let g:PyFlakeMaxLineLength = 88
" ----------------------------------------------------------------------------
" Syntastic:
" ----------------------------------------------------------------------------
let g:syntastic_check_on_open = 0
let g:syntastic_echo_current_error = 1
let g:syntastic_enable_signs = 1
let g:syntastic_enable_balloons = 1
let g:syntastic_always_populate_loc_list=1
let g:syntastic_enable_highlighting = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_mode_map = {
\ "mode": "passive",
\ "active_filetypes": [],
\ "passive_filetypes": [] }
let g:syntastic_python_checkers = ["pyflakes"]
map <Leader>sc :SyntasticCheck<CR>
map <Leader>sr :SyntasticReset<CR>
" ----------------------------------------------------------------------------
" Tagbar:
" ----------------------------------------------------------------------------
let g:tagbar_compact = 1
let g:tagbar_iconchars = ['+', '-']
let g:tagbar_ctags_bin = g:ctags_bin
map <F4> :TagbarToggle<CR>
map <leader>t :echo tagbar#currenttag('%s','','fs')<CR>
"set statusline=%<%f\ %h%m%r%y[%{&ff}]\ \ %{tagbar#currenttag('%s','','f')}%=%-14.(%l,%c%V%)\ %P
" ----------------------------------------------------------------------------
" VCS:
" ----------------------------------------------------------------------------
let VCSCommandDeleteOnHide = 1
augroup VCSCommand
au User VCSBufferCreated set bufhidden=wipe
augroup END
map <Leader>vd :VCSVimDiff<CR>
" vim-lsp {{{
function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
nmap <buffer> gd <plug>(lsp-definition)
nmap <buffer> gs <plug>(lsp-document-symbol-search)
nmap <buffer> gS <plug>(lsp-workspace-symbol-search)
nmap <buffer> gr <plug>(lsp-references)
nmap <buffer> gi <plug>(lsp-implementation)
nmap <buffer> gt <plug>(lsp-type-definition)
nmap <buffer> <leader>rn <plug>(lsp-rename)
nmap <buffer> [g <Plug>(lsp-previous-diagnostic)
nmap <buffer> ]g <Plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover)
endfunction
augroup lsp_install
autocmd!
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup end
let g:lsp_diagnostics_echo_cursor=1 " echo error for the current line to status
let g:lsp_diagnostics_enabled=0 " enable reporting of linter errors/warnings, using ALE for now
let g:lsp_diagnostics_highlights_enabled=1 " disable highlighting of errors since they're flagged with signs
let g:lsp_diagnostics_signs_enabled=1 " flag errors/warnings in the signs column
let g:lsp_diagnostics_signs_error = {'text': '✗'}
let g:lsp_diagnostics_signs_warning = {'text': '!'}
let g:lsp_diagnostics_virtual_text_enabled=0 " don't show annoying virtual text next to errors
let g:lsp_document_highlight_enabled=0 " don't highlight the symbol under the cursor
let g:lsp_fold_enabled=0 " use SimpylFold for (python) folding
"cannot get this working
""===vim-lsp-ultisnips
"let g:UltiSnipsExpandTrigger="<tab>"
"let g:UltiSnipsJumpForwardTrigger="<tab>"
"let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
""===
" }}}
" vim-lsp-settings {{{
let g:lsp_settings = {
\ 'pyls-all': {
\ 'workspace_config': {
\ 'pyls': {
\ 'configurationSources': ['flake8'],
\ 'plugins': {
\ 'jedi': {'enabled': v:true},
\ 'flake8': {'enabled': v:false},
\ 'mccabe': {'enabled': v:false},
\ 'pycodestyle': {'enabled': v:false},
\ 'pydocstyle': {'enabled': v:false},
\ 'pyflakes': {'enabled': v:false},
\ 'pylint': {'enabled': v:false},
\ 'rope': {'enabled': v:false}
\ }
\ }
\ }
\ }}
" Opt out of :LspInstallServer suggestion messages (run :LspStatus to check)
let g:lsp_settings_enable_suggestions=0
" }}}
" }}}
" ============================================================================
" Autocommands:
" ============================================================================
" Close the preview window automatically
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" Set xaml to be like xml
au BufNewFile,BufRead *.xaml setfiletype xml
" Format for xml
au FileType xml setlocal equalprg=xmllint\ --format\ --recover\ -\ 2>/dev/null
" Markdown
au FileType markdown setlocal formatoptions-=l textwidth=79
" ICE
au FileType slice setlocal cindent
" ============================================================================
" Functions:
" ============================================================================
" ----------------------------------------------------------------------------
" EditColors:
" ----------------------------------------------------------------------------
function! EditColors()
execute 'e ~/vimfiles/colors/lucius.vim'
execute 'so $VIMRUNTIME/syntax/hitest.vim'
execute 'wincmd L'
execute 'help syntax'
execute 'wincmd ='
execute '10wincmd +'
execute '219'
normal! zt
execute 'wincmd h'
execute 'set title titlestring=Colors'
endfunction
command! Colors call EditColors()
" ----------------------------------------------------------------------------
" GetOutput:
" ----------------------------------------------------------------------------
function! GetOutput(cmd)
redir => message
silent execute a:cmd
redir END
enew
silent put=message
set nomodified
endfunction
command! -nargs=+ -complete=command GetOutput call GetOutput(<q-args>)
" ---------
" Netrw explorer
" -----------
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 20
if &diff
else
augroup ProjectDrawer
autocmd!
autocmd VimEnter * :Vexplore
augroup END
end
" ----------------------------------------------------------------------------
" UseWorkSettings:
" ----------------------------------------------------------------------------
function! UseWorkSettings()
"au BufNewFile,BufRead *.py set noexpandtab
au BufNewFile,BufRead *.py set expandtab colorcolumn=80
au BufNewFile,BufRead *.cpp set noexpandtab
au BufNewFile,BufRead *.C set noexpandtab
au BufNewFile,BufRead *.hpp set noexpandtab
au BufNewFile,BufRead *.H set noexpandtab
au BufNewFile,BufRead *.cs set noexpandtab
endfunction
command! WorkSettings :call UseWorkSettings()
if InLocation("work_win", "work_linux")
WorkSettings
endif
" WSL yank support
let s:clip = '/mnt/c/Windows/System32/clip.exe' " change this path according to your mount point
if executable(s:clip)
augroup WSLYank
autocmd!
autocmd TextYankPost * if v:event.operator ==# 'cy' | call system(s:clip, @0) | endif
augroup END
endif
" ============================================================================
" Local:
" ============================================================================
if filereadable(expand("~/.vimrc_local"))
source ~/.vimrc_local
endif
" =====
" replace the selected text with ctrl+r
" ====
" Escape special characters in a string for exact matching.
" This is useful to copying strings from the file to the search tool
" Based on this - http://peterodding.com/code/vim/profile/autoload/xolox/escape.vim
function! EscapeString (string)
let string=a:string
" Escape regex characters
let string = escape(string, '^$.*\/~[]')
" Escape the line endings
let string = substitute(string, '\n', '\\n', 'g')
return string
endfunction
" Get the current visual block for search and replaces
" This function passed the visual block through a string escape function
" Based on this - https://stackoverflow.com/questions/676600/vim-replace-selected-text/677918#677918
function! GetVisual() range
" Save the current register and clipboard
let reg_save = getreg('"')
let regtype_save = getregtype('"')
let cb_save = &clipboard
set clipboard&
" Put the current visual selection in the " register
normal! ""gvy
let selection = getreg('"')
" Put the saved registers and clipboards back
call setreg('"', reg_save, regtype_save)
let &clipboard = cb_save
"Escape any special characters in the selection
let escaped_selection = EscapeString(selection)
return escaped_selection
endfunction
" Start the find and replace command across the entire file
vmap <C-r> <Esc>:%s/<c-r>=GetVisual()<cr>//g<left><left>
" ====== vim-test
let test#python#runner = 'pytest'
let test#strategy = "dispatch"
let test#strategy = {
\ 'nearest': 'vimterminal',
\ 'file': 'dispatch',
\ 'suite': 'dispatch',
\}
" these "Ctrl mappings" work well when Caps Lock is mapped to Ctrl
nmap <silent> t<C-n> :TestNearest -v<CR>
nmap <silent> t<C-f> :TestFile<CR>
nmap <silent> t<C-s> :TestSuite<CR>
nmap <silent> t<C-l> :TestLast -v<CR>
nmap <silent> t<C-g> :TestVisit<CR>
" ====== vim-projectionist
let g:projectionist_heuristics = {
\ "*.py|tests/test_*.py" : {
\ "*.py": {"alternate": "tests/test_{}.py"},
\ "tests/test_*.py": {"alternate": "{}.py"}
\}
\}
nnoremap <Leader>gt :A<CR>
nnoremap <Leader>gts :AS<CR>
" =====