-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy path.vimrc
1335 lines (1093 loc) · 40.6 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
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
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
" vim: set ft=vim:
" this script is being ln -s to ~/.config/nvim/init.vim ~/.vimrc ~/.nvimrc
" set nocompatible " be iMproved, required
" filetype off " required
set mouse=
autocmd BufEnter * set mouse=
if exists('py2') && has('python')
elseif has('python3')
endif
if has('nvim')
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !wget -P ~/.config/nvim/autoload/ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
else
if empty(glob('~/.vim/autoload/plug.vim'))
silent !wget -P ~/.vim/autoload/ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
endif
call plug#begin('~/.vim/bundle')
" let Vundle manage Vundle, required
Plug 'VundleVim/Vundle.vim'
" Keep Plugin commands between vundle#begin/end.
Plug 'tpope/vim-fugitive'
" Automatically adjust indentation
Plug 'tpope/vim-sleuth'
" :GV - commit browser
" :GV! only commits for current file
" o or <cr> on a commit to display the content of it
" o or <cr> on commits to display the diff in the range
" O opens a new tab instead
" gb for :Gbrowse
" ]] and [[ to move between commits
" . to start command-line with :Git [CURSOR] SHA à la fugitive
" q to close
Plug 'junegunn/gv.vim'
Plug 'tpope/vim-surround'
Plug 'tomtom/tcomment_vim'
Plug 'bling/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'airblade/vim-gitgutter'
Plug 'easymotion/vim-easymotion'
Plug 'terryma/vim-multiple-cursors'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'jpo/vim-railscasts-theme'
Plug 'scrooloose/nerdTree'
Plug 'vim-scripts/indentpython.vim'
" aa ia - around argument, in argument
Plug 'vim-scripts/argtextobj.vim'
" Alt+c - modify color
" Alt+r - insert new color RGB
" Alt+2 - insert new color RGBA
" :ColorPicker - color picker
" origin: KabbAmine/vCoolor.vim
Plug 'kracejic/vcoolor.vim'
" new text objects
Plug 'kana/vim-textobj-user'
" f F text objects
Plug 'kana/vim-textobj-function'
" User defined operators/actions
Plug 'kana/vim-operator-user'
Plug 'michaeljsmith/vim-indent-object'
Plug 'vimwiki/vimwiki'
" gs
Plug 'christoomey/vim-sort-motion'
Plug 'tomasr/molokai'
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'pearofducks/ansible-vim'
" :Tabularize
Plug 'godlygeek/tabular'
Plug 'plasticboy/vim-markdown' "better markdown support
" better cooperation with tmux
Plug 'christoomey/vim-tmux-navigator'
" gutter for marks
Plug 'kshenoy/vim-signature'
" Vim Plug for switching between companion source files (e.g. .h and .cpp)
Plug 'derekwyatt/vim-fswitch'
Plug 'rhysd/vim-clang-format'
Plug 'sbdchd/neoformat'
" session management
Plug 'tpope/vim-obsession'
Plug 'dhruvasagar/vim-prosession'
Plug 'gikmx/ctrlp-obsession'
" vim abolish does three things,
" :Abolish {despa,sepe}rat{e,es,ed,ing,ely,ion,ions,or} {despe,sepa}rat{}
" :Subvert/blog{,s}/post{,s}/g
" coercion - crs, crc change to snake case,
" change to camel case, cru upper case
Plug 'tpope/vim-abolish'
" Snippets
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'kracejic/snippetinabox.vim'
Plug 'scrooloose/syntastic'
Plug 'majutsushi/tagbar'
Plug 'joereynolds/gtags-scope'
" nice search in files, nice for massreplace
Plug 'dyng/ctrlsf.vim'
" :FS [pattern]
" search with :Ack [options] {pattern] [{directories}]
Plug 'mileszs/ack.vim'
" :Dox command generates stub for doxygen doc in C++, etc
Plug 'vim-scripts/DoxygenToolkit.vim'
" :Search :SearchBuffers :SearchReset :SearchBuffersReset
" <Leader>*
Plug 'vim-scripts/MultipleSearch'
" fast searching
" Plug 'junegunn/fzf'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
" ga / gaip= align in paragraph around char =
Plug 'junegunn/vim-easy-align'
" :ColorToggle
Plug 'lilydjwg/colorizer'
" Syntaxes for a lot of languages
Plug 'sheerun/vim-polyglot'
" Increment - \a
Plug 'vim-scripts/visual-increment'
" :Delete, :Unlink, :Move, :Rename, :Chmod, :Mkdir, :Find, :Locate, :SudoWrite, :SudoEdit
Plug 'tpope/vim-eunuch'
"Run interactive:
":DB sqlite:myfile.sqlite3
"
"Run commands
":DB sqlite:myfile.sqlite3 select count(*) from widgets
":DB redis:/// CLIENT LIST
"
"Save DBs locations
":DB g:prod = postgres://user:[email protected]/production_database
":DB g:prod drop table users
"
"Give a range to run part or all of the current buffer as a query.
":%DB mysql://root@localhost/bazquux
Plug 'tpope/vim-db'
Plug 'Yggdroot/indentLine'
Plug 'skywind3000/asyncrun.vim'
" Source: https://github.com/madox2/vim-ai
" echo "YOUR_OPENAI_API_KEY" > ~/.config/openai.token
" :AI complete text
" :AIEdit edit text
" :AIChat continue or open new chat
" :AIRedo repeat last AI command
" :AINewChat open new chat
" :help vim-ai
" https://platform.openai.com/account/billing/overview
Plug 'madox2/vim-ai'
let initial_prompt =<< trim END
>>> system
You are going to play a role of a completion engine.
Write simple code that will work.
You will provide compact code/text completion, generation, transformation or explanation
Topic: general programming and text editing.
Do not provide any coments, just the code.
When ask to edit the code, provide just the code, do not provide an explanation.
END
let chat_engine_config = {
\ "engine": "chat",
\ "options": {
\ "model": "gpt-3.5-turbo",
\ "max_tokens": 1000,
\ "temperature": 0.1,
\ "request_timeout": 20,
\ "selection_boundary": "",
\ "initial_prompt": initial_prompt,
\ },
\ "ui": {
\ "paste_mode": 1,
\ },
\}
let g:vim_ai_complete = chat_engine_config
" let g:vim_ai_edit = chat_engine_config
" custom command that provides a code review for selected code block
function! CodeReviewFn(range) range
let l:prompt = "programming syntax is " . &filetype . ", suggest how to improve following code: \n"
let l:config = {
\ "options": {
\ "initial_prompt": ">>> system\n You will try to find ways how to simplify it and make it more readable and efficient. If you notice errors, you will describe the errors. ",
\ },
\}
'<,'>call vim_ai#AIChatRun(a:range, l:config, l:prompt)
endfunction
command! -range AIReview <line1>,<line2>call CodeReviewFn(<range>)
" custom command for regular AI
function! RegularAI(range) range
let l:prompt = ""
let l:config = {
\ "options": {
\ "engine": "chat",
\ "initial_prompt": "",
\ "model": "gpt-3.5-turbo",
\ "max_tokens": 1000,
\ "temperature": 0.1,
\ "request_timeout": 20,
\ "selection_boundary": "",
\ },
\ "ui": {
\ "paste_mode": 1,
\ },
\}
'<,'>call vim_ai#AIRun(a:range, l:config, l:prompt)
endfunction
command! -range AIi <line1>,<line2>call RegularAI(<range>)
" command! AIi call RegularAI(getline('.'))
" New autocomplete
" Async support
Plug 'prabirshrestha/async.vim'
" Async autocompletion for Vim 8 and Neovim with |timers|.
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-file.vim'
" Provide Language Server Protocol autocompletion source for asyncomplete.vim and vim-lsp.
Plug 'prabirshrestha/asyncomplete-lsp.vim'
" Async Language Server Protocol plugin for vim8 and neovim.
Plug 'prabirshrestha/vim-lsp'
" Add suport for languages
Plug 'mattn/vim-lsp-settings'
" Support snippets
" Plug 'thomasfaingnaert/vim-lsp-snippets'
" Plug 'thomasfaingnaert/vim-lsp-ultisnips'
" make clipboard working with sway
" "&y ... - pastebuffer
Plug 'kana/vim-fakeclip'
let g:fakeclip_provide_clipboard_key_mappings = 1
" Plug 'artur-shaik/vim-javacomplete2'
function! SourceIfExists(file)
if filereadable(expand(a:file))
exe 'source' a:file
endif
endfunction
let g:build_window_height = 15
call SourceIfExists("~/.vimrc.local")
call SourceIfExists("./.vimrc.local")
let g:colorizer_startup = 0
Plug 'kracejic/themeinabox.vim'
" Plug 'CoatiSoftware/vim-sourcetrail'
" Bin
" Plug 'itchyny/calendar.vim'
" Plug 'Yggdroot/indentLine'
" All of your Plugins must be added before the following line
call plug#end()
packadd termdebug
":Termdebug ../build/source/unittest/unittests -cd test<CR>
"help termdebug-starting
" Use of the filetype plugins, auto completion and indentation support
" filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
filetype plugin on
set nocompatible
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" -----------------------------------------------------------------------------
" Key shortcuts in VIM
" !! bash output on screen, current line is stdin
"General
" set number "Show line numbers
" set relativenumber
set nonu
set nornu
nmap <leader>num :set nu! <CR>:set rnu!<CR>
nmap <leader>gnum :set g:nu! <CR>:set g:rnu!<CR>
set wrap "enable wraping
set linebreak "Break lines at word (requires Wrap lines)
set nolist " list disables linebreak
set scrolloff=5 " 2 lines above/below cursor when scrolling
set noswapfile " turn off swapfiles
" :imap jj <Esc>
:imap <C-L> <Esc>
set textwidth=0
set wrapmargin=0 "Disable line wrap
set ruler "Show row and column ruler information
set showbreak=+++ "Wrap-broken line prefix
"set textwidth=100 "Line wrap (number of cols)
set showmatch "Highlight matching brace
set showcmd " show command in bottom bar
set title " show file in titlebar
set showmode " show mode in status bar (insert/replace/...)
set visualbell "Use visual bell (no beeping)
set cursorline " highlight current line
set matchpairs+=<:> " specially for html
" set maxmempattern=20000
set redrawtime=500
set hlsearch "Highlight all search results
set smartcase "Enable smart-case search
set ignorecase "Always case-insensitive
set incsearch "Searches for strings incrementally
nmap \q :nohlsearch<CR>
nnoremap <leader><space> :noh<cr>
" get rid of red curly braces
let c_no_curly_error=1
set virtualedit=onemore "allow to go one character behind the end of the line
set autoindent "Auto-indent new lines
set expandtab "Use spaces instead of tabs
set shiftwidth=4 "Number of auto-indent spaces
set smartindent "Enable smart-indent
set smarttab "Enable smart-tabs
set softtabstop=4 "Number of spaces per Tab
set wildmenu " visual autocomplete for command menu
set wildignore+=*.o,*.obj,*.bak,*.exe,*.py[co],*.swp,*~,*.pyc,.svn,*/cm/log/**,tags,*.jpg,*.png,*.jpeg,*.png,*.mesh,build*/**,build/**,*.sublime-workspace,*.svg,build2/**,build3/**
set lazyredraw " redraw only when we need to.
set confirm " get a dialog when :q, :w, or :wq fails
set nobackup " no backup~ files.
set viminfo='20,\"500 " remember copy registers after quitting in the .viminfo file -- 20 jump links, regs up to 500 lines'
set hidden " remember undo after quitting
set history=150 " keep 50 lines of command history
set mouse=v " use mouse in visual mode (not normal,insert,command,help mode
set t_ut=
set previewheight=7
set fillchars+=vert:│ " nicer vert split separator
set fillchars+=stlnc:- " nicer separator for horizontal split
if has('gui_running')
set guifont=Iosevka\ Term\ 12
endif
"display whitespace
set listchars=tab:>-,trail:~,extends:>,precedes:<
"set listchars=eol: ,tab:>-,trail:~,extends:>,precedes:<
set tags=./tags;/ "This will look in the current directory for 'tags', and work up the tree towards root until one is found.
set cscopetag
"Fuzzy search
if isdirectory("/mingw32")
" CtrlP settings
let g:ctrlp_match_window = 'top,order:ttb,max:15,results:15'
let g:ctrlp_follow_symlinks = 1
"let g:ctrlp_switch_buffer = 0
"let g:ctrlp_working_path_mode = 0
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
let g:ctrlp_custom_ignore = '\v[\/](node_modules)$'
let g:ctrlp_working_path_mode = 'a'
nnoremap <leader>. :CtrlPBufTag<cr>
nnoremap <leader>, :CtrlPTag<cr>
nnoremap <leader>q :CtrlPQuickfix<cr>
nnoremap <Leader>ss :CtrlPObsession<CR>
nnoremap <leader>a :CtrlPBuffer<CR>
nnoremap <leader><tab> :CtrlPBuffer<CR>
else
let g:ctrlp_map = '<leader><c-p>'
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~50%' }
" [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'
" command! GGFiles call fzf#run(fzf#wrap({'source': 'if [ -d .git ] ; then git ls-files -co --exclude-standard ; elif [ -d .hg ] ; then hg locate ; else find . ; fi', 'sink': 'e'}))
command! GGFiles call fzf#run(fzf#wrap({'source': 'if git rev-parse --git-dir > /dev/null ; then git ls-files -co --exclude-standard ; elif [ -d .hg ] ; then hg locate ; else find . ; fi', 'sink': 'e'}))
" command! GGFiles call fzf#run(fzf#wrap({'source': 'git ls-files -co --exclude-standard', 'sink': 'e'}))
" command! GGFiles call fzf#run(fzf#wrap({'source': 'git ls-files -co --exclude-standard', 'sink': 'e'}))
nnoremap <C-p> :GGFiles<cr>
" nnoremap <C-p> :CtrlP<cr>
nnoremap <leader>. :BTags<cr>
nnoremap <leader>, :Tags<cr>
nnoremap <leader>q :CtrlPQuickfix<cr>
nnoremap <Leader>ss :CtrlPObsession<CR>
nnoremap <leader>a :Buffers<CR>
nnoremap <leader><tab> :Buffers<CR>
" fzf
nnoremap <Leader><Leader> :Commands<CR>
nnoremap <leader>L :Lines<cr>
nnoremap <leader>l :BLines<cr>
nnoremap <leader>ft :Filetype<cr>
" TODO \* usage of word with :Lines and :Ag
" Insert mode completion
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)
endif
command! Ctagsgenerate :!ctags -R .
command! Gtagsgenerate :!gtags
" let GtagsCscope_Auto_Load = 1
" find references
nnoremap <leader>ygr "zyiw:cs find c <C-r>z<CR>
" Git-fugitive stuff
nmap <leader>g :Gstatus<cr>gg<C-n>
nmap <leader>go :Gstatus<cr>gg<C-n>
" open header fswitch
nmap <silent> <F4> :FSHere<cr>
nmap <silent> <Leader>of :FSHere<cr>
nmap <silent> <Leader>ol :FSRight<cr>
nmap <silent> <Leader>oL :FSSplitRight<cr>
nmap <silent> <Leader>oh :FSLeft<cr>
nmap <silent> <Leader>oH :FSSplitLeft<cr>
nmap <silent> <Leader>ok :FSAbove<cr>
nmap <silent> <Leader>oK :FSSplitAbove<cr>
nmap <silent> <Leader>oj :FSBelow<cr>
nmap <silent> <Leader>oJ :FSSplitBelow<cr>
" Tagbar
nmap <silent> <F3> :TagbarToggle<CR>
nmap <silent> <F5> :TagbarOpenAutoClose<CR>
let g:tagbar_case_insensitive = 1
" let g:tagbar_compact = 1
let g:tagbar_indent = 1
let g:tagbar_map_showproto = "r"
let g:tagbar_map_togglefold = "<space>"
let g:tagbar_sort = 0
" for pasting in terminal
set pastetoggle=<F2>
nnoremap <leader>a <C-A>
" vnoremap <leader>a <Plug>VisualIncrement
" vnoremap <silent> <Plug><leader>a :<C-U>call <SID>doincrement(v:count1)<CR>
" vnoremap <silent> <leader>a :<C-U>call <SID>doincrement(v:count1)<CR>
vnoremap <silent> <leader>a g<C-a>
" increment numbers
noremap + <c-a>
noremap - <c-x>
" Splits
set splitbelow " more natural split opening
set splitright " more natural split opening
"split movement
nnoremap <C-h> <C-w>h
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
nnoremap <C-j> <C-w>j
tnoremap <C-h> <C-w>h
tnoremap <C-k> <C-w>k
tnoremap <C-l> <C-w>l
tnoremap <C-j> <C-w>j
"saner splits
nnoremap <C-w>\| <C-w>v
nnoremap <C-w>_ <C-w>s
"resizing splits
nnoremap <C-w><C-w>h 8<C-w><
nnoremap <C-w><C-w>l 8<C-w>>
nnoremap <C-w><C-w>k 8<C-w>-
nnoremap <C-w><C-w>j 8<C-w>+
nnoremap <C-w><C-w><C-w>h <C-w><
nnoremap <C-w><C-w><C-w>l <C-w>>
nnoremap <C-w><C-w><C-w>k <C-w>-
nnoremap <C-w><C-w><C-w>j <C-w>+
" Zoom / Restore window.
function! s:ZoomToggle() abort
if exists('t:zoomed') && t:zoomed
execute t:zoom_winrestcmd
let t:zoomed = 0
else
let t:zoom_winrestcmd = winrestcmd()
resize
vertical resize
let t:zoomed = 1
endif
endfunction
command! ZoomToggle call s:ZoomToggle()
nnoremap <silent> <C-w>z :ZoomToggle<CR>
" buffers
nmap \] :bnext<CR>
nmap \[ :bprev<CR>
nmap <leader>w :bd<CR>
command! Bda :bufdo bd
nnoremap <bs> <c-^>
command! Bd bp|bd<space>#
nnoremap <leader>W :Bd<CR>
" syntax enable " enable syntax processing
syntax on " enable syntax processing
" settings for kshenoy/vim-signature, it will color the marks with gitgutter
" color
let g:SignatureMarkTextHLDynamic = 1
let g:SignatureMarkerTextHLDynamic = 1
"reload vimrc
:nmap \rv :source $MYVIMRC<CR>
"strip whitespace
nnoremap <leader>sw :%s/\s\+$//<cr>:let @/=''<CR>
command! Stripwhitespace :%s/\s\+$//
command! Whitespacestrip :%s/\s\+$//
" Start interactive EasyAlign in visual mode (e.g. vipga)
xmap ga <Plug>(EasyAlign)
" Start interactive EasyAlign for a motion/text object (e.g. gaip)
nmap ga <Plug>(EasyAlign)
" vimwiki
command! WTable :VimwikiTable
command! WToc :VimwikiTOC
command! WTags :VimwikiRebuildTags
" z= choose spell ]s [s move
" zg add to spellfile zw add as bad, zug/zuw remove from spellfile
set spellfile=~/.vim/spell.misc.utf-8.add
command! Spellen :setlocal spell spelllang=en_us
command! Spellcs :setlocal spell spelllang=cs
command! Spellnone :setlocal nospell
command! ColorPicker :VCoolor
let g:calendar_google_calendar = 1
" quickfix open
:nmap gqf :copen 20<CR>
command Quickfix :copen 20<CR>
command QF :copen 20<CR>
command Qf :copen 20<CR>
command QFF :cclose 20<CR>
command Qff :cclose 20<CR>
" quickfix next, prev
:nmap [q :cprev<CR>
:nmap ]q :cnext<CR>
:nmap [Q :cfirst<CR>
:nmap ]Q :clast<CR>
" location list next, prev
:nmap [e :lprev<CR>
:nmap ]e :lnext<CR>
:nmap [E :lfirst<CR>
:nmap ]E :llast<CR>
" Theme stuff
"let base16colorspace=256 " Access colors present in 256 colorspace
set background=dark
nnoremap <leader>1 :colorscheme railscasts<cr>:AirlineTheme dark<cr>
nnoremap <leader>2 :colorscheme molokai<cr>:AirlineTheme minimalist<cr>
nnoremap <leader>3 :colorscheme themeinabox<cr>:AirlineTheme bubblegum<cr>
nnoremap <leader>4 :colorscheme themeinabox-light<cr>:AirlineTheme sol<cr>
nnoremap <leader>5 :colorscheme themeinabox-transparent<cr>:AirlineTheme bubblegum<cr>
nnoremap <leader>6 :colorscheme themeinabox-blue<cr>:AirlineTheme base16_grayscale<cr>
" get current syntax class
nmap <leader>sy :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<'
\ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<"
\ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
function! SynMerge()
syntax region MergeLocal start="<<<<<<< " end=">>>>>>> .*$" contains=MergeBase,MergeRemote,MergeLocalHEAD
syntax region MergeLocal start="<<<<<<< " end=">>>>>>> .*$" contains=MergeBase,MergeRemote,MergeLocalHEAD contained
syntax match MergeLocalHEAD "<<<<<<< .*$" contained
syntax region MergeBase start="||||||| " end=">>>>>>> .*$" contains=MergeRemote,MergeBaseHEAD
syntax match MergeBaseHEAD "||||||| .*$" contained
syntax region MergeRemote start="=======" end=">>>>>>> .*$" contains=MergeRemoteHEAD
syntax match MergeRemoteHEAD ">>>>>>> .*$" contained
endfunction
command! SynMerge :call SynMerge()
"goto next file
:nmap <C-`> :e#<CR>
"toc for markdown
nmap <leader>toc :g/^#/#<CR> :noh <CR>
nmap <leader>defs :g/def /#<CR> :noh <CR>
"Showfunc.vim
nmap <leader>func <Plug>ShowFunc
nmap <leader>fun <Plug>ShowFunc<CR><C-w>H
" nmap <leader>cf <Plug>(operator-clang-format)
" vmap <leader>cf <Plug>(operator-clang-format)
" duplicate lanes TODO
nmap <leader>dd :s/\(^.*$\)/\1\r\1/<CR>:noh<CR>
xmap <leader>dd :'<,'>s/\(.*\)/\1\r\1/<CR>:noh<CR>
" New line in normal mode
" nnoremap <CR> :<c-u>put =repeat(nr2char(10), v:count1)<cr>
" json indent
command! -range -nargs=0 -bar IndentJson <line1>,<line2>!python -m json.tool
command! -range -nargs=0 -bar JsonIndent <line1>,<line2>!python -m json.tool
"xml indent
command! IndentXml :silent %!xmllint --encode UTF-8 --format -
command! XmlIndent :silent %!xmllint --encode UTF-8 --format -
" CLANG FORMAT
" default settings
let g:clang_format#code_style = "llvm"
let g:clang_format#style_options = {
\ "AllowShortFunctionsOnASingleLine": "Empty",
\ "AlwaysBreakTemplateDeclarations": "true",
\ "BreakBeforeBraces": "Allman",
\ "BreakConstructorInitializersBeforeComma": "true",
\ "IndentCaseLabels": "true",
\ "IndentWidth": 4,
\ "MaxEmptyLinesToKeep": 2,
\ "NamespaceIndentation": "Inner",
\ "ObjCBlockIndentWidth": 4,
\ "TabWidth": 4}
augroup ClangFormatSettings
autocmd!
" if you install vim-operator-user
autocmd FileType c,cpp,objc,java,javascript map <buffer><Leader>c <Plug>(operator-clang-format)
autocmd FileType c,cpp syntax clear cppSTLconstant
autocmd FileType vimwiki nmap <leader>tts :TaskWikiMod +sprint<CR>
autocmd FileType vimwiki nmap <leader>ttS :TaskWikiMod -sprint<CR>
" autocmd FileType markdown set cole=0
" au BufNewFile,BufRead *.mdw set nowrap
" au BufNewFile,BufRead,BufAdd *.md set cole=0
augroup END
let g:indentLine_char = '┊'
" let g:indentLine_setConceal = 0
" let g:indentLine_enabled = 0
" let g:indentLine_concealcursor = 'inc'
" let g:indentLine_conceallevel = 0
" let g:indentLine_fileTypeExclude = ['markdown']
let g:indentLine_fileType = ["yaml","yml","json","cpp","py","js","c"]
" :IndentLinesToggle
" Neoformat
let g:neoformat_enabled_python = ['autopep8']
let g:neoformat_java_clang = {
\ 'exe': 'clang-format',
\ 'stdin': 1,
\ }
let g:neoformat_enabled_java = ['clang']
nnoremap <Leader>cf :Neoformat<CR>
vnoremap <Leader>cf :Neoformat<CR>
" format line +-1
autocmd FileType c,cpp,objc,java,javascript nnoremap <Leader>cc :.-1,.+1Neoformat<CR>
" markdown ctags
let g:tagbar_type_markdown = {
\ 'ctagstype' : 'vimwiki',
\ 'kinds' : [
\ 'h:Heading_L1',
\ 'i:Heading_L2',
\ 'k:Heading_L3'
\ ]
\ }
let g:tagbar_type_markdown = {
\ 'ctagstype' : 'markdown',
\ 'kinds' : [
\ 'h:Heading_L1',
\ 'i:Heading_L2',
\ 'k:Heading_L3'
\ ]
\ }
augroup filetypedetect
au BufRead,BufNewFile *.log set filetype=log
au BufReadPost,BufNewFile *.compositor set ft=compositor
au BufReadPost,BufNewFile *.material set ft=material
au BufReadPost,BufNewFile *.glsl,*.cg set ft=glsl
au BufReadPost,BufNewFile content.txt set ft=fitnesse
au BufReadPost,BufNewFile database.txt,*.conf set ft=conf
au BufReadPost,BufNewFile config.in set ft=kconfig
au BufReadPost,BufNewFile *.xml set tabstop=4
au BufReadPost,BufNewFile *.crt set ft=crt
au BufReadPost,BufNewFile *.ASN set ft=asn
au BufReadPost,BufNewFile *.gsh set ft=Jenkinsfile
au BufReadPost,BufNewFile *.bbappend set ft=bash
au BufReadPost,BufNewFile *.bbclass set ft=bash
au BufReadPost,BufNewFile *.bb set ft=bash
au BufReadPost,BufNewFile *.inc set ft=bash
augroup END
let g:syntastic_cpp_compiler_options = "-std=c++14"
let g:syntastic_java_checkers = []
" add constant
nmap <leader>cre /[,)]<CR>:nohlsearch<CR>Bhi&<ESC>?[,(]<CR>:nohlsearch<CR>wiconst <ESC>
noremap <leader>cr :pyf ~/bin/clang-rename.py<cr>
:nmap \e :NERDTreeToggle<CR>
":nmap \t w setlocal wrap!<CR>:setlocal wrap?
":command Wrap setlocal wrap!<CR>:setlocal wrap?
":command :wrapt setlocal wrap!<CR>:setlocal wrap?<CR> " change wrapping
command! E :e %:p:h
command! LS :!ls -alh --color=always %:p:h
"folding
set foldenable " enable folding
set foldlevelstart=10 " open most folds by default
set foldnestmax=10 " 10 nested fold max
nnoremap <space> za
nnoremap z<space> zA
set foldmethod=indent " fold based on indent level
" Paste without yanking selected
xnoremap <leader>p "_dP
" Stamp = delete current word (without yanking) and paste
nnoremap S "_diwPb
nnoremap x "_x
nnoremap X "_X
xnoremap S "_diwPb
xnoremap x "_x
xnoremap X "_X
" movement
" move vertically by visual line
nnoremap j gj
nnoremap k gk
nnoremap <down> gj
nnoremap <up> gk
" move to beginning/end of line
nmap <Home> ^
nmap <End> $
nnoremap gV `[v`] " This mapping allows you to reselect the text you just pasted:
nnoremap gm :call cursor(0, len(getline('.'))/2)<CR> " goto midle of line
" diff merge
nnoremap <leader>d1 :diffget 1<CR>
nnoremap <leader>d2 :diffget 2<CR>
nnoremap <leader>d3 :diffget 3<CR>
command! Diffstart :windo diffthis
command! Diffstop :diffoff!
"Advanced
set undolevels=1000 "Number of undo levels
set backspace=indent,eol,start "Backspace behaviour
" check file change every 4 seconds ('CursorHold') and reload the buffer upon
" detecting change
set autoread
au CursorHold * checktime
set tabpagemax=50 " max number of pages
"plugins
set runtimepath^=~/.nvim/bundle/ctrlp.vim
"save with root
command! Wroot :execute ':silent w !sudo tee % > /dev/null' | :edit!
" fix typo
command! W :w
" YCMd
" http://stackoverflow.com/questions/3105307/how-do-you-automatically-remove-the-preview-window-after-autocompletion-in-vim
" :h ins-completion.
" :YcmDiags - errors
" let g:ycm_confirm_extra_conf = 0
" let g:ycm_global_ycm_extra_conf = '~/bin/rc/.ycm_extra_conf.py'
" let g:ycm_error_symbol = '%'
" let g:ycm_warning_symbol = '%'
" let g:ycm_always_populate_location_list = 1
" let g:ycm_max_diagnostics_to_display = 300
" nnoremap <leader>yj :YcmCompleter GoToDefinitionElseDeclaration<CR>
" nnoremap <leader>yg :YcmCompleter GoTo<CR>
" nnoremap <leader>yi :YcmCompleter GoToImplementationElseDeclaration<CR>
" nnoremap <leader>yt :YcmCompleter GetTypeImprecise<CR>
" nnoremap <leader>yd :YcmCompleter GetDoc<CR>
" nnoremap <leader>yf :YcmCompleter FixIt<CR>
" nnoremap <leader>yr :YcmCompleter GoToReferences<CR>
" nnoremap <leader>ys :YcmDiags<CR>
" nnoremap <leader>yD ::YcmForceCompileAndDiagnostics<CR>
" nnoremap <leader>yR :YcmRestartServer<CR>
" nnoremap <F12> :YcmCompleter GoToDefinitionElseDeclaration<CR>
" nnoremap <F10> :YcmCompleter GetTypeImprecise<CR>
" nnoremap <F9> :YcmCompleter GetDocImprecise<CR>
" "nnoremap <F5> :YcmForceCompileAndDiagnostics<CR>
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
" set completeopt+=menuone
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<cr>"
imap <c-space> <Plug>(asyncomplete_force_refresh)
" Disable diagnostics
" let g:lsp_diagnostics_enabled = 0
let g:lsp_signs_error = {'text': '✗'}
let g:lsp_signs_warning = {'text': '%'}
" Disable highligh errors
let g:lsp_highlights_enabled = 0
let g:lsp_diagnostics_highlights_enabled = 0
let g:lsp_diagnostics_echo_cursor = 1
" let g:lsp_diagnostics_float_cursor = 1
let g:lsp_diagnostics_virtual_text_enabled = 0
let g:lsp_diagnostics_signs_error = {'text': '✗'}
let g:lsp_diagnostics_signs_warning = {'text': ','}
let g:lsp_diagnostics_signs_information = {'text': '.'}
let g:lsp_diagnostics_signs_hint = {'text': '.'}
let g:lsp_textprop_enabled = 0
let g:lsp_signs_priority = 11
" see ~/bin/rc/pycodestyle linked to ~/.config/pycodestyle
let g:lsp_settings = {
\ 'python': {'cmd': ['pyls','-v']}
\}
let g:lsp_log_verbose = 1
let g:lsp_log_file = expand('~/.vim-lsp.log')
" for asyncomplete.vim log
let g:asyncomplete_log_file = expand('~/.vim.asyncomplete.log')
function! s:on_lsp_buffer_enabled() abort
setlocal omnifunc=lsp#complete
setlocal signcolumn=yes
" refer to doc to add more commands
endfunction
" Vim-async, youcompleteme, intelisense
nmap <F12> <plug>(lsp-declaration)
nmap gd <plug>(lsp-declaration)
nmap gD <plug>(lsp-definition)
nmap gp <plug>(lsp-peek-declaration)
nmap gP <plug>(lsp-peek-definition)
nmap ge <plug>(lsp-next-diagnostic)
nmap gh <plug>(lsp-hover)
nmap gr <plug>(lsp-references)
nmap gE <plug>(lsp-document-diagnostics)
nmap ga <plug>(lsp-code-action)
nmap <leader>ya <plug>(lsp-code-action)
nmap <leader>yj <plug>(lsp-declaration)
nmap <leader>yg <plug>(lsp-declaration)
nmap <leader>yd <plug>(lsp-peek-declaration)
nmap <leader>ys <plug>(lsp-status)
augroup lsp_install
au!
" 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
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({
\ 'name': 'file',
\ 'whitelist': ['*'],
\ 'priority': 10,
\ 'completor': function('asyncomplete#sources#file#completor')
\ }))
set showtabline:0
" airline
let g:airline_mode_map = {
\ '__' : '-',
\ 'n' : 'N',
\ 'i' : 'I',
\ 'R' : 'R',
\ 'c' : 'C',
\ 'v' : 'V',
\ 'V' : 'V',
\ '' : 'V',
\ 's' : 'S',
\ 'S' : 'S',
\ '' : 'S',
\ }
let g:airline#extensions#default#section_truncate_width = {
\ 'b': 79,
\ 'x': 100,
\ 'y': 90,
\ 'z': 60,
\ 'warning': 100,
\ 'error': 80,
\ }
let w:airline_skip_empty_sections = 1
" let g:airline_section_b=' %{fugitive#head()}'
let g:airline#extensions#hunks#enabled = 0
let g:airline#extensions#wordcount#enabled = 0
let g:airline_section_z='%l/%L☰%c'
let g:airline#extensions#branch#format = 1
let g:airline#extensions#branch#displayed_head_limit = 8
let g:airline#extensions#branch#displayed_head_limit = 8
let g:airline#extensions#hunks#enabled = 0
let g:airline#extensions#lsp#enabled = 0
let g:airline#extensions#syntastic#enabled = 0
let g:airline_skip_empty_sections = 1
let g:airline#parts#ffenc#skip_expected_string='utf-8[unix]'
let g:airline#extensions#searchcount#enabled = 0
" colorscheme themeinabox
let g:airline_theme='bubblegum'
set laststatus=2
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 0