forked from kracejic/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
998 lines (799 loc) · 30.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
" this script is being ln -s to ~/.config/nvim/init.vim ~/.vimrc ~/.nvimrc
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" Keep Plugin commands between vundle#begin/end.
Plugin 'tpope/vim-fugitive'
" :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
Plugin 'junegunn/gv.vim'
Plugin 'tpope/vim-surround'
Plugin 'lighttiger2505/gtags.vim'
" Plugin 'tomtom/tcomment_vim'
Plugin 'bling/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'airblade/vim-gitgutter'
Plugin 'easymotion/vim-easymotion'
" Plugin 'terryma/vim-multiple-cursors'
Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'jpo/vim-railscasts-theme'
Plugin 'scrooloose/nerdTree'
" Plugin 'vim-scripts/indentpython.vim'
" Plugin 'vim-scripts/argtextobj.vim'
" new text objects
Plugin 'kana/vim-textobj-user'
" f F text objects
Plugin 'kana/vim-textobj-function'
" User defined operators/actions
Plugin 'kana/vim-operator-user'
Plugin 'michaeljsmith/vim-indent-object'
Plugin 'vimwiki/vimwiki'
" gs
Plugin 'christoomey/vim-sort-motion'
Plugin 'tomasr/molokai'
Plugin 'octol/vim-cpp-enhanced-highlight'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown' "better markdown support
" better cooperation with tmux
Plugin 'christoomey/vim-tmux-navigator'
" gutter for marks
Plugin 'kshenoy/vim-signature'
" Vim plug for switching between companion source files (e.g. .h and .cpp)
Plugin 'derekwyatt/vim-fswitch'
Plugin 'rhysd/vim-clang-format'
Plugin 'sbdchd/neoformat'
" session management
Plugin 'tpope/vim-obsession'
Plugin 'dhruvasagar/vim-prosession'
Plugin '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
Plugin 'tpope/vim-abolish'
" Snippets
Plugin 'SirVer/ultisnips'
Plugin 'honza/vim-snippets'
Plugin 'kracejic/snippetinabox.vim'
Plugin 'scrooloose/syntastic'
Plugin 'majutsushi/tagbar'
Plugin 'joereynolds/gtags-scope'
" search with :Ack [options] {pattern] [{directories}]
Plugin 'mileszs/ack.vim'
" :Dox command generates stub for doxygen doc in C++, etc
Plugin 'vim-scripts/DoxygenToolkit.vim'
" :Search :SearchBuffers :SearchReset :SearchBuffersReset
Plugin 'vim-scripts/MultipleSearch'
" fast searching
Plugin 'junegunn/fzf'
Plugin 'junegunn/fzf.vim'
" ga / gaip= align in paragraph around char =
Plugin 'junegunn/vim-easy-align'
" :ColorToggle
Plugin 'lilydjwg/colorizer'
Plugin 'vim-scripts/AnsiEsc.vim'
" Syntaxes for a lot of languages
Plugin 'sheerun/vim-polyglot'
" :DevDocs ---
Plugin 'rhysd/devdocs.vim'
Plugin 'vim-scripts/visual-increment'
" :Delete, :Unlink, :Move, :Rename, :Chmod, :Mkdir, :Find, :Locate, :SudoWrite, :SudoEdit
Plugin 'tpope/vim-eunuch'
" Plugin 'artur-shaik/vim-javacomplete2'
let g:colorizer_startup = 0
if hostname() =~ "build01"
Plugin 'vim-scripts/ccase.vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'vim-scripts/ShowFunc.vim'
endif
if hostname() =~ "ankh"
Plugin 'Valloric/YouCompleteMe'
Plugin 'tbabej/taskwiki'
endif
if hostname() =~ "efebe"
Plugin 'Valloric/YouCompleteMe'
" Plugin 'tbabej/taskwiki'
endif
if hostname() =~ "krull"
Plugin 'Valloric/YouCompleteMe'
Plugin 'tbabej/taskwiki'
endif
if hostname() =~ "tezuman"
Plugin 'Valloric/YouCompleteMe'
endif
if hostname() =~ "chirm"
" Plugin 'MrAshLinux/vim-perforce'
Plugin 'Valloric/YouCompleteMe'
Plugin 'tbabej/taskwiki'
endif
Plugin 'kracejic/themeinabox.vim'
" Bin
" Plugin 'itchyny/calendar.vim'
" Plugin 'Yggdroot/indentLine'
" All of your Plugins must be added before the following line
call vundle#end() " required
" 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
"
" 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
let mapleader=","
"General
"set number "Show line numbers
"set relativenumber
nmap <leader>nu :set nu! <CR>:set 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 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>
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=2 "Number of auto-indent spaces
set smartindent "Enable smart-indent
set smarttab "Enable smart-tabs
set softtabstop=2 "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
"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'}))
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>
" 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>
" 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
"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>+
" 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
if hostname() == "MD1KQAXC"
let g:vimwiki_list = [{'path': '/d/cloud/space/source/', 'syntax': 'markdown', 'ext': '.mdw', 'auto_tags': 1}, {'path': '/d/cloud/space/siemens/', 'syntax': 'markdown', 'ext': '.mdw', 'auto_tags': 1}]
elseif hostname() =~ "chirm"
let g:vimwiki_list = [{'path': '~/cloud/space/source/', 'syntax': 'markdown', 'ext': '.mdw', 'auto_tags': 1}, {'path': '~/cloud/space/siemens/', 'syntax': 'markdown', 'ext': '.mdw', 'auto_tags': 1}]
elseif hostname() =~ "ankh"
let g:vimwiki_list = [{'path': '~/cloud/space/source/', 'syntax': 'markdown', 'ext': '.mdw', 'auto_tags': 1}, {'path': '~/cloud/space/siemens/', 'syntax': 'markdown', 'ext': '.mdw', 'auto_tags': 1}]
else
let g:vimwiki_list = [{'path': '~/cloud/space/source/', 'syntax': 'markdown', 'ext': '.mdw', 'auto_tags': 1}]
endif
au BufNewFile,BufRead *.mdw set nowrap
" 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
let g:calendar_google_calendar = 1
" quickfix next, prev
:nmap [q :cprev<CR>
:nmap ]q :cnext<CR>
:nmap [Q :cfirst<CR>
:nmap ]Q :clast<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 base16_monokai<cr>
nnoremap <leader>3 :colorscheme themeinabox<cr>:AirlineTheme base16_eighties<cr>
nnoremap <leader>4 :colorscheme themeinabox-light<cr>:AirlineTheme sol<cr>
nnoremap <leader>5 :colorscheme themeinabox-transparent<cr>:AirlineTheme base16_eighties<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>
"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": 2,
\ "MaxEmptyLinesToKeep": 2,
\ "NamespaceIndentation": "Inner",
\ "ObjCBlockIndentWidth": 2,
\ "TabWidth": 2}
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>
augroup END
" Neoformat
let g:neoformat_enabled_python = ['autopep8']
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'
\ ]
\ }
" autocmd FileType java setlocal omnifunc=javacomplete#Complete
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
augroup END
let g:syntastic_cpp_compiler_options = "-std=c++14"
" add constant
nmap <leader>acr /[,)]<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
if v:version > 703 || v:version == 703 && has("patch541")
set formatoptions+=j " Delete comment character when joining commented lines
endif
" 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
colorscheme themeinabox
let g:airline_theme='base16_eighties'
"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
" YCM
" 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 = '%'
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>
" 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': 60,
\ 'y': 88,
\ 'z': 60,
\ 'warning': 80,
\ '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 = 2
set laststatus=2
if hostname() =~ "ankh"
let g:airline_powerline_fonts = 1
elseif hostname() =~ "chirm"
let g:airline_powerline_fonts = 1
else
let g:airline_powerline_fonts = 1
endif
let g:airline#extensions#tabline#enabled = 1
"let g:airline#extensions#tabline#left_sep = ' '
"let g:airline#extensions#tabline#left_alt_sep = '|'
" tabline
command! TablineON :set showtabline=1
command! TablineOFF :set showtabline=0
" multicursor
let g:multi_cursor_next_key='<C-n>'
let g:multi_cursor_prev_key='<C-p>'
let g:multi_cursor_skip_key='<C-x>'
let g:multi_cursor_quit_key='<Esc>'
" easymotion
let g:EasyMotion_do_mapping = 0 " Disable default mappings
" nmap <Leader>w <Plug>(easymotion-w)
" Bi-directional find motion
" Jump to anywhere you want with minimal keystrokes, with just one key binding.
" `s{char}{label}`
"nmap s <Plug>(easymotion-s)
" or
" `s{char}{char}{label}`
" Need one more keystroke, but on average, it may be more comfortable.
nmap ss <Plug>(easymotion-s2)
" Turn on case insensitive feature
let g:EasyMotion_smartcase = 1
vnoremap <leader>j :m '>+1<CR>gv=gv
vnoremap <leader>k :m '<-2<CR>gv=gv
" visual shifting (builtin-repeat)
vnoremap < <gv
vnoremap > >gv
" -----------------------------------------------------------------------------
" fast indentations changes
nmap <leader>t1 :set expandtab tabstop=1 shiftwidth=1 softtabstop=1<CR>
nmap <leader>T1 :set noexpandtab tabstop=1 shiftwidth=1 softtabstop=1<CR>
nmap <leader>t2 :set expandtab tabstop=2 shiftwidth=2 softtabstop=2<CR>
nmap <leader>T2 :set noexpandtab tabstop=2 shiftwidth=2 softtabstop=2<CR>
nmap <leader>t4 :set expandtab tabstop=4 shiftwidth=4 softtabstop=4<CR>
nmap <leader>T4 :set noexpandtab tabstop=4 shiftwidth=4 softtabstop=4<CR>
nmap <leader>t6 :set expandtab tabstop=6 shiftwidth=6 softtabstop=6<CR>
nmap <leader>T6 :set noexpandtab tabstop=6 shiftwidth=6 softtabstop=6<CR>
nmap <leader>t8 :set expandtab tabstop=8 shiftwidth=8 softtabstop=8<CR>
nmap <leader>T8 :set noexpandtab tabstop=8 shiftwidth=8 softtabstop=8<CR>
" Python specific
" au BufNewFile,BufRead *.py
" \ set tabstop=4
" \ set softtabstop=4
" \ set shiftwidth=4
" \ set textwidth=79
" \ set expandtab
" \ set autoindent
" \ set fileformat=unix
command! Pandocahtml :w | ! pandocconvert.sh "%" html5
command! Pandocpdf :w | ! pandocconvert.sh "%" pdf
command! Pandocdocx :w | ! pandocconvert.sh "%" docx
command! Openahtml :w | ! pandocconvert.sh "%" html5 open
command! Openpdf :w | ! pandocconvert.sh "%" pdf open
command! Opendocx :w | ! pandocconvert.sh "%" docx open
" -----------------------------------------------------------------------------
" cn
let g:mc = "y/\\V\<C-r>=escape(@\", '/')\<CR>\<CR>"
nnoremap cn *``cgn
nnoremap cN *``cgN
vnoremap <expr> cn g:mc . "``cgn"
vnoremap <expr> cN g:mc . "``cgN"
function! SetupCR()
nnoremap <Enter> :nnoremap <lt>Enter> n@z<CR>q:<C-u>let @z=strpart(@z,0,strlen(@z)-1)<CR>n@z
endfunction
nnoremap cq :call SetupCR()<CR>*``qz
nnoremap cQ :call SetupCR()<CR>#``qz
vnoremap <expr> cq ":\<C-u>call SetupCR()\<CR>" . "gv" . g:mc . "``qz"
vnoremap <expr> cQ ":\<C-u>call SetupCR()\<CR>" . "gv" . substitute(g:mc, '/', '?', 'g') . "``qz"
" substitute for current selection
xnoremap gs y:%s/<C-r>"//g<Left><Left>
" -----------------------------------------------------------------------------
" Highlight all instances of word under cursor, when idle.
" Useful when studying strange source code.
" Type z/ to toggle highlighting on/off.
nnoremap <leader>z :if AutoHighlightToggle()<Bar>set hls<Bar>endif<CR>
function! AutoHighlightToggle()
let @/ = ''
if exists('#auto_highlight')
au! auto_highlight
augroup! auto_highlight
setl updatetime=4000
echo 'Highlight current word: off'
return 0
else
augroup auto_highlight
au!
au CursorHold * let @/ = '\V\<'.escape(expand('<cword>'), '\').'\>'
augroup end
setl updatetime=500
echo 'Highlight current word: ON'
return 1
endif
endfunction
" -----------------------------------------------------------------------------
" search for visually selected text
vnoremap // y/<C-R>"<CR>
" -----------------------------------------------------------------------------
" Search for selected text, forwards or backwards.
vnoremap <silent> * :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy/<C-R><C-R>=substitute(
\escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
vnoremap <silent> # :<C-U>
\let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR>
\gvy?<C-R><C-R>=substitute(
\escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR>
\gV:call setreg('"', old_reg, old_regtype)<CR>
" -----------------------------------------------------------------------------
" select ag as :Ack search when available
if executable('ag')
let g:ackprg = 'ag --nogroup --nocolor --column'
endif
nnoremap <leader>ag "zyiw:Ag <C-r>z<CR>
" -----------------------------------------------------------------------------
"Work stuff clear case
command! Ctpdiff :!cleartool diff -pre -col 190 % | less
command! Ctpdiff2 :!cleartool diff -pre -ser % | less
" -----------------------------------------------------------------------------
" Fix autocompletions
function! g:UltiSnips_Complete()
call UltiSnips#ExpandSnippet()
if g:ulti_expand_res == 0
if pumvisible()
return "\<C-n>"
else
call UltiSnips#JumpForwards()
if g:ulti_jump_forwards_res == 0
return "\<TAB>"
endif
endif
endif
return ""
endfunction
function! g:UltiSnips_Reverse()
call UltiSnips#JumpBackwards()
if g:ulti_jump_backwards_res == 0
return "\<C-P>"
endif
return ""
endfunction
if !exists("g:UltiSnipsJumpForwardTrigger")
let g:UltiSnipsJumpForwardTrigger = "<tab>"
endif
if !exists("g:UltiSnipsJumpBackwardTrigger")
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
endif
au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsJumpBackwardTrigger . " <C-R>=g:UltiSnips_Reverse()<cr>"
inoremap <silent><C-X><C-U> <C-R>=g:UltiSnips_Complete()<CR>
" -----------------------------------------------------------------------------
" execute macro on visal range
xnoremap @ :<C-u>call ExecuteMacroOverVisualRange()<CR>
function! ExecuteMacroOverVisualRange()
echo "@".getcmdline()
execute ":'<,'>normal @".nr2char(getchar())
endfunction
" -----------------------------------------------------------------------------
" Make the dot command work as expected in visual mode (via
" https://www.reddit.com/r/vim/comments/3y2mgt/do_you_have_any_minor_customizationsmappings_that/cya0x04)
vnoremap . :norm.<CR>
" -----------------------------------------------------------------------------
" Save temporary/backup files not in the local directory, but in your ~/.vim
" directory, to keep them out of git repos.
" But first mkdir backup, swap, and undo first to make this work
call system('mkdir ~/.vim')
call system('mkdir ~/.vim/backup')
call system('mkdir ~/.vim/swap')
set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
" Keep undo history across sessions by storing it in a file
if has('persistent_undo')
call system('mkdir ~/.vim/undo')
set undodir=~/.vim/undo//
set undofile
set undolevels=1000
set undoreload=10000
endif
" -----------------------------------------------------------------------------
" CMake support
function! BuildCMakeProjectShort(target, dir)
echom a:target
if isdirectory(a:dir)
silent !clear
execute "! cd " . a:dir . " && clear && cmake --build . --target " . a:target . " -- -j" . (system('grep -c ^processor /proc/cpuinfo')+1) . " && echo '-- Build was OK'"
else
echo "build folder was not found, cannot build"
endif
endfunction
function! BuildCMakeProject(target, dir)
echom a:target
if isdirectory(a:dir)
let result = system( "cd " . a:dir . " && clear && cmake --build . --target " . a:target . " -- -j" . (system('grep -c ^processor /proc/cpuinfo')+1) . " 2>&1 && echo '-- Build was OK'")
split __Build_output__
normal! ggdG
setlocal filetype=krcppbuild
setlocal buftype=nofile
setlocal bufhidden=hide
setlocal nobuflisted
" Insert the bytecode.
call append(0, split(result, '\v\n'))
setlocal nonumber
setlocal norelativenumber
" setlocal nomodifiable
:map <buffer> q :bd<cr>
else
echo "build folder was not found, cannot build"
endif
endfunction
nmap <leader>bt :!tmux send-keys -t "build" Up Enter<CR><CR>
if isdirectory("build")
nmap <leader>bb :call BuildCMakeProject("check", "build")<CR>
nmap <leader>bu :call BuildCMakeProject("unit", "build")<CR>
nmap <leader>bB :call BuildCMakeProject("all", "build")<CR>
nmap <leader>br :call BuildCMakeProjectShort("run", "build")<CR>
nmap <leader>bc :call BuildCMakeProjectShort("clean", "build")<CR>
nmap <leader>bf :call BuildCMakeProjectShort("format", "build")<CR>
endif
if isdirectory("build2")
nmap <leader>b2b :call BuildCMakeProject("check", "build2")<CR>
nmap <leader>b2u :call BuildCMakeProject("unit", "build2")<CR>
nmap <leader>b2B :call BuildCMakeProject("all", "build2")<CR>
nmap <leader>b2r :call BuildCMakeProjectShort("run", "build2")<CR>
nmap <leader>b2c :call BuildCMakeProjectShort("clean", "build2")<CR>
nmap <leader>b2f :call BuildCMakeProjectShort("format", "build2")<CR>
endif
if isdirectory("build3")
nmap <leader>b3b :call BuildCMakeProject("check", "build3")<CR>
nmap <leader>b3u :call BuildCMakeProject("unit", "build3")<CR>
nmap <leader>b3B :call BuildCMakeProject("all", "build3")<CR>
nmap <leader>b3r :call BuildCMakeProjectShort("run", "build3")<CR>
nmap <leader>b3c :call BuildCMakeProjectShort("clean", "build3")<CR>
nmap <leader>b3f :call BuildCMakeProjectShort("format", "build3")<CR>
endif
" -----------------------------------------------------------------------------