forked from noctuid/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
2266 lines (1866 loc) · 66.5 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
" Todo:
" don't count capitilization errors as spelling errors?
" tab for snippets and indentation and auto-completion?
" visual repeat setup
" octodown instead of livedown
" http://smalltalk.gnu.org/blog/bonzinip/emacs-ifying-vims-autoindent
" instead of autochdir?
" autocmd BufReadPost * if &ft != 'help' | silent! cd %:p:h | endif
" Plugins:
" https://github.com/gelguy/Cmd2.vim
" skybison and vim-swoop
" https://github.com/mhinz/vim-startify
" https://github.com/t9md/vim-transform
" Wishes:
" listchars working with linebreak
" W13 fix
" async linter update; async git singify update
" decent repl integration with new terminal in neovim
" real-time visualization of block editing (not that important)
" Notes:
" see https://gist.github.com/romainl/9ecd7b09a693816997ba
" to check what is setting certain mappings and settings-
" :verbose map
" :verbose set
" Insert prefixes: . and , (as usually followed by a space; can cause problems)
" chord would be better..
" having a ~/.vimrc turns off compatable; :h 'cp'; with -u can use -N
" fixes complaining about undefined tcomment variable
set runtimepath+=~/.vim/bundle/tcomment_vim
" #==============================
" # Experimental {{{
" #==============================
" Arpeggio {{{
" otherwise vim complains
autocmd VimEnter * call s:arpeggio_maps()
" works great with low timeout except during lag (due to neocomplete mostly)
function! s:arpeggio_maps()
Arpeggio inoremap st <c-w>
Arpeggio inoremap ie <end>
Arpeggio inoremap ne <esc>
Arpeggio inoremap se <cr>
" Arpeggio inoremap wf <c-r>+
endfunction
let g:arpeggio_timeoutlen=11
" }}}
" better text file long line nav (use with lazy redraw); up and down between wraps
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
" not viable due to vim abbrevs expanding even with letters before them
" and sometimes even when have typed stuff before the abbrev
" letter symbols; short letter abbrevs {{{
" " don't use a, x, y, z, i (for several reasons), or j
" inoreabbr e =
" inoreabbr pe +=
" inoreabbr r &
" inoreabbr rr &&
" inoreabbr c :
" inoreabbr q ?
" " plus, time*, modulo
" inoreabbr p +
" inoreabbr t *
" inoreabbr m %
" " e.g. dollar operator
" inoreabbr d $
" " e.g.type t/ to get ~/
" inoreabbr t ~
" " comparison
" inoreabbr ee ==
" inoreabbr g >
" inoreabbr ge >=
" inoreabbr l <
" inoreabbr le <=
" problems so far:
" if backspace and then type one of these sequences will expand; may be better to use only in program files and not in config files either (because of mappings)
" e.g.
" inoreabbr eg e.g.
" }}}
" make a submode for this...
" nnoremap w zj
" nnoremap b zk
augroup sCustom
au!
" move by paragraph (empty line)
au FileType * nnoremap <buffer> s }|nnoremap <buffer> S {
" move by sentence
au FileType doto,text,mkd nmap <buffer> s <Plug>(textobj-sentence-move-n)|nmap <buffer> S <Plug>(texobj-sentence-move-p):call repeat#set("\<Plug>(textobj-sentence-move-p)", v:count)<cr>
augroup END
nmap r <nop>
nnoremap cd r
if has("gui_running")
" WM Experimentation {{{
nnoremap <silent> <space><space> :silent !bspc window -f left && xsendkey p && bspc window -f last<cr>
" "r" is Redraw {{{
" worskpace/Destkop switch {{{
nnoremap <silent> ra :silent !wm_action inpw ra<cr>
nnoremap <silent> rr :silent !wm_action inpw rr<cr>
nnoremap <silent> rs :silent !wm_action inpw rs<cr>
nnoremap <silent> rt :silent !wm_action inpw rt<cr>
nnoremap <silent> rd :silent !wm_action inpw rd<cr>
nnoremap <silent> rh :silent !wm_action inpw rh<cr>
" nnoremap <silent> rn :silent !wm_action dsel 7<cr>
" nnoremap <silent> re :silent !wm_action dsel 8<cr>
nnoremap <silent> rn :silent !wm_action inpw rn<cr>
nnoremap <silent> re :silent !wm_action inpw re<cr>
nnoremap <silent> ri :silent !wm_action inpw ri<cr>
nnoremap <silent> ro :silent !wm_action inpw ro<cr>
" }}}
" move to destkop {{{
nnoremap <silent> Ra :silent !wm_action inpw Ra<cr>
nnoremap <silent> Rr :silent !wm_action inpw Rr<cr>
nnoremap <silent> Rs :silent !wm_action inpw Rs<cr>
nnoremap <silent> Rt :silent !wm_action inpw Rt<cr>
nnoremap <silent> Rd :silent !wm_action inpw Rd<cr>
nnoremap <silent> Rh :silent !wm_action inpw Rh<cr>
nnoremap <silent> Rn :silent !wm_action inpw Rn<cr>
nnoremap <silent> Re :silent !wm_action inpw Re<cr>
nnoremap <silent> Ri :silent !wm_action inpw Ri<cr>
nnoremap <silent> Ro :silent !wm_action inpw 0Ro<cr>
" }}}
" moving windows within desktop {{{
" move to biggest
nnoremap <silent> rcm :silent !wm_action inpw rcm<cr>
" directions
nnoremap <silent> rch :silent !wm_action inpw rch<cr>
nnoremap <silent> rcn :silent !wm_action inpw rcn<cr>
nnoremap <silent> rce :silent !wm_action inpw rce<cr>
nnoremap <silent> rci :silent !wm_action inpw rci<cr>
" circulate
nnoremap <silent> r. :silent !wm_action inpw r.<cr>
nnoremap <silent> r, :silent !wm_action inpw r,<cr>
" }}}
" resize {{{
nnoremap <silent> rmh :silent !wm_action inpw rmh<cr>
nnoremap <silent> rmn :silent !wm_action inpw rmn<cr>
nnoremap <silent> rme :silent !wm_action inpw rme<cr>
nnoremap <silent> rmi :silent !wm_action inpw rmi<cr>
" }}}
" take from old s<keys> bindings {{{
" last window
nnoremap <silent> ru :silent !wm_action inpw ru<cr>
" monocle toggle
nnoremap <silent> rk :silent !wm_action inpw rk<cr>
nnoremap <silent> rf :silent !wm_action inpw rf<cr>
nnoremap <silent> ry :silent !wm_action inpw ry<cr>
" }}}
" last destkop
nnoremap <silent> rl :silent !wm_action inpw rl<cr>
" close window
nnoremap <silent> rx :silent !wm_action inpw rx<cr>
" }}}
" }}}
else
" Tmux Experimentation {{{
" "r" is Redraw {{{
" window switching {{{
nnoremap <silent> ra :silent !wm_action inpt ra<cr>:redraw!<cr>
nnoremap <silent> rr :silent !wm_action inpt rr<cr>:redraw!<cr>
nnoremap <silent> rs :silent !wm_action inpt rs<cr>:redraw!<cr>
nnoremap <silent> rt :silent !wm_action inpt rt<cr>:redraw!<cr>
nnoremap <silent> rd :silent !wm_action inpt rd<cr>:redraw!<cr>
nnoremap <silent> rh :silent !wm_action inpt rh<cr>:redraw!<cr>
nnoremap <silent> rn :silent !wm_action inpt rn<cr>:redraw!<cr>
nnoremap <silent> re :silent !wm_action inpt re<cr>:redraw!<cr>
nnoremap <silent> ri :silent !wm_action inpt ri<cr>:redraw!<cr>
nnoremap <silent> ro :silent !wm_action inpt ro<cr>:redraw!<cr>
" }}}
" resize panes {{{
nnoremap <silent> rmh :silent !wm_action inpt rmh<cr>
nnoremap <silent> rmn :silent !wm_action inpt rmn<cr>
nnoremap <silent> rme :silent !wm_action inpt rme<cr>
nnoremap <silent> rmi :silent !wm_action inpt rmi<cr>
" }}}
" circulate
" previous
nnoremap <silent> r, :silent !wm_action inpt r,<cr>
" next
nnoremap <silent> r. :silent !wm_action inpt r.<cr>
" new window
nnoremap <silent> rc :silent !wm_action inpt rc<cr>:redraw!<cr>
" kill pane
nnoremap <silent> rx :silent !wm_action inpt rx<cr>
" last window
nnoremap <silent> rl :silent !wm_action inpt rl<cr>:redraw!<cr>
" split windows
nnoremap <silent> r/ :silent !wm_action inpt r/<cr>:redraw!<cr>
nnoremap <silent> r- :silent !wm_action inpt r-<cr>:redraw!<cr>
" break pane
nnoremap <silent> r! :silent !wm_action inpt rbang<cr>
" take from old s<keys> bindings {{{
" last pane
nnoremap <silent> ru :silent !wm_action inpt ru<cr>:redraw!<cr>
" zoomed pane toggle
nnoremap <silent> rk :silent !wm_action inpt rk<cr>
" fullscreen
nnoremap <silent> rf :silent !wm_action inpt rf<cr>
" sticky
nnoremap <silent> ry :silent !wm_action inpt ry<cr>:redraw!<cr>
" main-vertical layout
nnoremap <silent> rv :silent !wm_action inpt rv<cr>:redraw!<cr>
" }}}
" }}}
" }}}
endif
" }}}
" #==============================
" # General/ Vim Settings {{{
" #==============================
" General General {{{
" utf8 as default encoding
set encoding=utf8
" 2000 lines of command line history.
set history=2000
" keep buffer contents in memory (e.g. undo history doesn't go away if change buffers and not saving undo history to disk)
set hidden
" no rodent
set mouse=c
" automatically cd to dir current file is in
set autochdir
" default; :%s/// replaces one; /g replace all; /gg replace one
set nogdefault
" can select past eol in visual block if one line is longer
set virtualedit=block
" default for vim; read "vim: settings:" in files
set modeline
" allow backspacing over autoindent, linebreaks, and start of insert (2)
set backspace=indent,eol,start
" default; when do things like gg, will move cursor to sol
set startofline
" turn off timeout; default is 1000
" fix airline mode changes without screwing up remaps of default letter keys (without this, using escape to exit insert mode won't change airline to display normal mode immediately in the terminal)
" ttimeout only applies to keycodes (so changes to default vim keys that can't be unmapped won't be a problem, e.g. using r in multikey/prefix bindings)
set notimeout ttimeout ttimeoutlen=10
" generally use marker folds
set foldmethod=marker
set foldcolumn=2
" open folds when jumping to marks
set foldopen+=mark
set splitright nosplitbelow
" Text Formatting {{{
" default; disable automatic insertion of newline characters
set textwidth=0 wrapmargin=0
" :h fo-table
" get rid of tc; no auto hardwrap (insert newline) of comments or text based on textwidth
" having textwidth set overrides having tc in formatoptions
" a - automatic formatting of paragraphs (e.g. if <esc> at eol with trailing whitespace, will join the lines)
" j- remove comment char when joining lines
" l- don't break lines in insert mode
" r - insert comment after enter while in insert
" q - allow formatting of comments with gq
" w - trailing whitespace indicates a paragraph continues on the next line
" o - adds comment char on o when line (above) is commented
set formatoptions=ljrq
" don't add two spaces when joining a line that ends with.,?, or !
set nojoinspaces
" }}}
" return to/restore last edit position when opening files
" http://vim.wikia.com/wiki/Restore_cursor_to_file_position_in_previous_editing_session
augroup resCur
au!
au BufReadPost * call setpos(".", getpos("'\""))|normal! zv
augroup END
" }}}
" Backup, Swap, Undo Settings {{{
" // to avoid collisions (files with same name will be named based on path)
" set directory=~/.vim/swap//
" swapfiles are annoying
set noswapfile
" persistent undo history (even if close buffer)
" Save undo's after file closes
set undofile
" where to save undo histories
set undodir=~/.vim/undo//
" How many undos
set undolevels=2000
" save whole buffer for undo on reload if number of lines is smaller than
set undoreload=10001
" backup before overwriting file and keep backup file
set writebackup backup
" backup dir does not have // :(
set backupdir=~/.vim/tmp
set backupcopy=auto
" my important text files are under git; not worried about losing old versions
set backupskip+=*EDITMSG,*.txt
augroup keepSomeBackups
au!
" changes backup extension before writing file so old backup isn't deleted if has been a minute
au BufWritePre * call NewInitBex()
" delete files older than two days
" http://askubuntu.com/questions/413529/delete-files-older-than-one-year-on-linux
" if put .vim/tmp/*, wouldn't match dot files
au BufWritePost * silent !find ~/.vim/tmp* -mtime +2 -delete &
augroup END
" http://vim.wikia.com/wiki/Keep_incremental_backups_of_edited_files
function! NewInitBex()
let &bex = '-' . strftime("(%m_%d)-{%H_%M}~")
endfunction
" https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-207
" make folders automatically if they don't already exist
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), "p")
endif
" if !isdirectory(expand(&directory))
" call mkdir(expand(&directory), "p")
" endif
" }}}
" Writing/Saving Settings {{{
" save buffer if changed when using various commands (switching buffers, quit, exit, etc.)
set autowriteall
" don't autoreload a file when changed outside of vim; prompt
set noautoread
" auto save all changed buffers
augroup autoSave
au!
au InsertLeave,FocusLost,BufEnter * silent! wa
augroup END
" }}}
" Command Mode {{{
" when tab completing from command line will show
set wildmenu
" https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-153
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.pyc " Python byte code
" changes tab behaviour in command line (i.e. list makes every possible choice popup)
set wildmode:full
" }}}
" Searching {{{
" highlight search time
set hlsearch
" fine I'll incsearch
set incsearch
" go back to beginning of buffer once reach end
set wrapscan
" when searching lower case, will match any case
" won't ignore case if search with upper case
set ignorecase smartcase
" }}}
" Auto-Sourcing .vimrc {{{
" https://github.com/bling/vim-airline/issues/539
function! RefreshUI()
if exists(':AirlineRefresh')
AirlineRefresh
else
" Clear & redraw the screen, then redraw all statuslines.
redraw!
redrawstatus!
endif
endfunction
" from vim wiki
augroup autoReloadVimRC
au!
" automatically reload vimrc when it's saved
au BufWritePost ~/dotfiles/vim/.vimrc so ~/.vimrc | call RefreshUI()
augroup END
" }}}
" }}}
" #==============================
" # Specific Filetype/Indentation Settings {{{
" #==============================
" Indentation
" will use settings in path_to_vim_install/indent/<filetype>.vim
" don't set smartindent or cindent with; can set autoindent though
filetype plugin indent on
" use previous line's indentation with <cr>, o, O
set autoindent
" Notes {{{
" :retab for conversion from tabs to spaces; :retab! for spaces to tabs
" see help and http://vim.wikia.com/wiki/Indenting_source_code
" expandtab - replace tab with spaces (noexpandtab is default)
" tabstop - how many columns a tab counts for visually
" softtabstop - how many columns vim uses when you hit Tab in insert mode (default: 0/off); if not set, the tabstop value is used
" shiftwidth - how many columns text is indented with <<, >>, and == and with automatic indentation
" smarttab -use shiftwidth instead of softtabtop forwhen determining what to do with <tab> and <bs> at the start of line and insert; it repurposes softtabstop (or tabstop, if softtabstop is 0) to be used for determining number of spaces to insert/delete elsewhere (not at sol)
" also, setting softtabstop to negative values with smarttab seems to mess up the behaviour instead of using the shiftwidth value; none of this is confusing
" http://tedlogan.com/techblog3.html
" "If softtabstop is less than tabstop and expandtab is not set, vim will use a combination of tabs and spaces to make up the desired spacing. If softtabstop equals tabstop and expandtab is not set, vim will always use tabs. When expandtab is set, vim will always use the appropriate number of spaces."
" Example: if tabstop is 8, softtabstop is 4 and noexpandtab and nosmarttab are set,
" the first tab will insert 4 spaces, second will make a tab that is visually 8 columns
" if shiftwidth is also 4, >> from start of line will first create 4 spaces then a tab of visual length 8
" now, if smarttab is set, shiftwidth will be used for <tab> and <bs> at the start of the line, and softtabstop will be used elsewhere
" }}}
set shiftwidth=4 tabstop=4 softtabstop=4
set noexpandtab
set smarttab
" Filetype Specific
" default commentstring (will be used by tcomment)
set commentstring=#\ %s
" pentadactyl
augroup pentadactyl
au!
au BufNewFile,BufRead *.pentadactylrc,*penta setlocal filetype=pentadactyl
augroup END
" for vim-dotoo
augroup orgdotoo
au!
au BufEnter,BufNewFile,BufRead *.org setlocal filetype=dotoo
augroup END
" See:
" ./.vim/after/ftplugin
" ./.vim/after/syntax
" }}}
" #==============================
" # Encryption Related {{{
" #==============================
" Edit gpg Files {{{
" http://vim.wikia.com/wiki/Edit_gpg_encrypted_files
set backupskip+=*.gpg
augroup gpg_encrypted
au!
" Disable swap files, and set binary file format before reading the file
" To avoid that parts of the file is saved to .viminfo when yanking or
" deleting, empty the 'viminfo' option.
au BufReadPre,FileReadPre *.gpg
\ setlocal noswapfile noundofile noshelltemp history=0 viminfo= bin
" Decrypt the contents after reading the file, reset binary file format
" and run any BufReadPost autocmds matching the file name without the .gpg
" extension
au BufReadPost,FileReadPost *.gpg
\ execute "'[,']!gpg --decrypt --default-recipient-self" |
\ setlocal nobin |
\ execute "doautocmd BufReadPost " . expand("%:r")
" Set binary file format and encrypt the contents before writing the file
au BufWritePre,FileWritePre *.gpg
\ setlocal bin |
\ '[,']!gpg --encrypt --default-recipient-self
" After writing the file, do an :undo to revert the encryption in the
" buffer, and reset binary file format
au BufWritePost,FileWritePost *.gpg
\ silent u |
\ setlocal nobin
augroup END
" }}}
" Vault Files (password storage) {{{
" have switched primarily to using pass (http://www.passwordstore.org/)
" see vpass alias in ~/.zshrc; using .encrypted_vimrc, not this (no loading of plugins); I guess this is useful if I somehow accidentally open a file in another vim session
" no backup or writebackup for vault files
set backupskip+=*.vault
augroup vaultEncrypted
au!
" disable swap files, saving to disk of undo history, writing to disk of commands, and saving thigns to .viminfo
au BufReadPre,FileReadPre,BufEnter *.vault
\ setlocal noswapfile cm=blowfish noundofile noshelltemp viminfo= history=0
" yanking pass
au BufEnter *.vault nnoremap <buffer> yy yiB
augroup END
" }}}
" }}}
" #==============================
" # Appearance {{{
" #==============================
syntax on
augroup rainbowParens
au!
au FileType c,cpp call rainbow#load()
augroup END
" Gvim v. Vim Settings
if has("gui_running")
" Slow down cursor blinking speed
set guicursor=a:blinkon1200-blinkoff800
" ultra anxiety...
" set guicursor=a:blinkon100-blinkoff50
colorscheme gruvbox
" colorscheme molokai
" colorscheme badwolf
" set guifont=Inconsolata-dz\ for\ Powerline\ 11
set guifont=Fira\ Mono\ 9
" remove menubar (m), toolbar (t), gui tabs (e), and scrollbars
" c use console dialogues instead of popups for simple choices
" a automatically puts visually selected text to primary (*)
set guioptions=ca
" kind of fixes white bar appearing at bottom; seems to work.. a bit
" also see ./.gtkrc-2.0.mine
set guiheadroom=0
else
colorscheme seoul256
endif
" (G)vim Settings {{{
" default; no screen flashes/beeps
set noerrorbells
"relative numbers except current line (rnu); using numbers vim plugin as well
set number relativenumber
" set titlestring based on file
set title
" default; show mode; show keys in bottom right
set showcmd showmode
" highlight matching brackets, parens, etc.
set showmatch
" Make < and > as well as match pairs. https://github.com/EHartC/dot-vimrc/blob/master/vim%20config/styling.vim
set matchpairs+=<:>
" won't redraw while executing macros, registers, and commands that have not been typed (not default)
" for example, stops flickering when have up and down mapped to c-o gk and gj in insert
set lazyredraw
" don't highlight past certain length; slows down vim on long lines
set synmaxcol=750
" at least 5 lines shown below and above cursor
set scrolloff=5
" filler lines to keep text position; start diff with vertical splits; don't ignore changes in case and whitespace
set diffopt=filler,vertical
" http://vim.wikia.com/wiki/Word_wrap_without_line_breaks
" softwrap lines visually when reach the edge
set wrap
" display tabs and certain whitespace
set list
" ☬⚛⚜⚡☥☣
set listchars=tab:\!\ ,nbsp:☣,eol:¬,extends:❯,precedes:❮
" don't indent wrapped lines
set nobreakindent
" set showbreak=↪\
" show trailing whitespace in normal mode
" https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-141
augroup trailing
au!
" listchars doesn't work with linebreak (which fucking sucks)
" http://stackoverflow.com/questions/6496778/vim-run-autocmd-on-all-filetypes-except
let blacklist = ['text', 'tex']
au InsertEnter * if index(blacklist, &ft) < 0 | set listchars-=trail:⌴
au InsertLeave * if index(blacklist, &ft) < 0 | set listchars+=trail:⌴
augroup END
" }}}
" Airline theme {{{
" https://github.com/bling/vim-airline/issues/539
" statusline always present
set laststatus=2
" http://stackoverflow.com/questions/114431/fast-word-count-function-in-vim
" also see http://naperwrimo.org/wiki/index.php?title=Vim_for_Writers
function! WordCount()
let s:old_status = v:statusmsg
let position = getpos(".")
exe ":silent normal g\<c-g>"
let stat = v:statusmsg
let s:word_count = 0
if stat != '--No lines in buffer--'
let s:word_count = str2nr(split(v:statusmsg)[11])
let v:statusmsg = s:old_status
end
call setpos('.', position)
return s:word_count
endfunction
au VimEnter * call s:airline_sections_custom()
function! s:airline_sections_custom()
" add current session name to statusline
"http://stackoverflow.com/questions/11374047/adding-the-current-session-filename-in-the-statusline add current session name to statusline
let g:airline_section_x = airline#section#create(['filetype', ' %{fnamemodify(v:this_session, ":t")}'])
" let g:airline_section_z = airline#section#create(["%{noscrollbar#statusline(20,' ','▓',['▐'],['▌'])}", '%02p%% : %l: %c', ' %{WordCount()}w'])
let g:airline_section_z = airline#section#create(['%02p%% : %l: %c', ' %{WordCount()}w'])
endfunction
" my custom combination theme:
let g:airline_theme='darkfox'
" powerline symbols
let g:airline_left_sep = ''
" let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
" let g:airline_right_alt_sep = ''
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_powerline_fonts = 1
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
" turn off mixed indent, trailing space
let g:airline_section_warning = ''
" nrrwrgn integration
let g:airline#extensions#nrrwrgn#enabled = 1
" vcs integration
let g:airline#extensions#branch#enabled = 1
" show summary of changed hunks (gitgutter and vim-signify)
let g:airline#extensions#hunks#enabled = 1
" syntastic integration
let g:airline#extensions#syntastic#enabled = 1
" tabline w/ taboo integration
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#taboo#enabled = 1
" show tab number instead of number of splits
let g:airline#extensions#tabline#tab_nr_type = 1
" }}}
" }}}
" #==============================
" # General Mappings/ Bindings {{{
" #==============================
" _Colemak/Navigation Mappings/Improvements {{{
" make colemak t more useful
let g:mapleader = "t"
" modified from here:
" https://github.com/bunnyfly/dotfiles/blob/master/vimrc
" http://forum.colemak.com/viewtopic.php?id=1808
" My changes:
" .keep i and don't have a dedicated right
" .l for 'last' instead of line
" up/down, including softwraps
noremap n gj|noremap e gk|nnoremap gn j|nnoremap ge k
" get back default gn
nnoremap gk gn
xnoremap gk gn
" keep in visual
xnoremap n j|xnoremap e k
" High/Low/Mid.
" I never use gm or select mode; would rather have go to middle of window not line
noremap gh H|noremap gm M|noremap gl L
" l for last
nnoremap l <c-o>zvzz
nnoremap L <c-i>zvzz
" Keep the cursor in place while joining lines
nnoremap j mzJ`z
" https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-398
" Split line (sister to [J]oin lines)
nnoremap <cr> i<cr><esc>^mwgk:silent! s/\v +$//<cr>:noh<cr>`w
" quickfix nav
augroup quickfix
au!
au FileType qf call s:qf_settings()
augroup END
function! s:qf_settings()
nnoremap <buffer> n j
nnoremap <buffer> e k
endfunction
" Fold Navigation/Creation {{{
" put comment char at sol (before text) with zf and add space between comment char and marker
" fix this
" xnoremap zf zf$3hr<space>:TComment mode=K<cr>zo]za<space><esc>[zzc
" swapping folds with tommcdo's exchange and kana's fold text object
nmap zE vazXzkvazX
nmap zN vazXzjvazX
" jump
nnoremap ze zk:silent! call repeat#set("zk", v:count)<cr>
nnoremap zn zj:silent! call repeat#set("zj", v:count)<cr>
nnoremap <leader>fe zk:silent! call repeat#set("zk", v:count)<cr>
nnoremap <leader>fn zj:silent! call repeat#set("zj", v:count)<cr>
nnoremap <leader>fu ]z:silent! call repeat#set("]z", v:count)<cr>
nnoremap <leader>fd [z:silent! call repeat#set("[z", v:count)<cr>
" open/close
nnoremap <tab> za
nnoremap <leader>fh zmzz:silent! call repeat#set("zmzz", v:count)<cr>
nnoremap <leader>fi zrzz:silent! call repeat#set("zrzz", v:count)<cr>
nnoremap <leader>fo zRzz:silent! call repeat#set("zRzz", v:count)<cr>
nnoremap <leader>fk zMzz:silent! call repeat#set("ZMzz", v:count)<cr>
" https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-651
" put current line at center and close surrounding folds
nnoremap zl mzzMzvzz`z
" }}}
" Search {{{
" noremap k nzozz|noremap K Nzozz
nmap k <Plug>(Oblique-n)
nmap K <Plug>(Oblique-N)
" get rid of visual mode mappings for n
xmap Qq <Plug>(Oblique-n)
xmap QQ <Plug>(Oblique-N)
" map k to do visual star instead
xmap k <Plug>(Oblique-*)
xmap K <Plug>(Oblique-#)
augroup oblique
au!
" center and open enough folds after search, star, and repeat
au User Oblique normal! zvzz
au User ObliqueStar normal! zvzz
au User ObliqueRepeat normal! zvzz
augroup END
" }}}
" }}}
" Modified Defaults {{{
" commandline
" I never really need , and ;
nnoremap ; :
xnoremap ; :
nnoremap <leader>; q:i
xnoremap <leader>; q:i
augroup cmdwin
au!
" use escape in "normal" to exit cmdwin:
au CmdwinEnter * nnoremap <buffer> <esc> <c-w>c
" enter in "normal" to execute command under cursor and re-enter q:
au CmdwinEnter * nnoremap <buffer> <cr> <cr>q:
augroup END
" using sneak, so unecessary
" this, uncommented, is also annoying with nmaps/plugs (e.g. can't nmap <somekey> <Plug>(something):somecommand<cr>)
" nnoremap : ;
" Y like D
nnoremap Y y$
" http://hashrocket.com/blog/posts/8-great-vim-mappings
" yank paragraph
nnoremap yp yap<S-}>p
" Sane redo.
noremap U <C-r>
" I use a more than A
nnoremap a A
nnoremap A a
" visual block
nnoremap <leader>v <c-v>
xnoremap v V
" because I hate Q; apply macro
nnoremap Q @q
xnoremap Q :norm @q<cr>
" centering an opening folds
nnoremap G Gzvzz
" https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-579
" move to last change (gi moves to last insert point)
nnoremap gI `.a
" go to file with optional line number, open folds, and center
nnoremap gf gFzvzz
" use m for "mode" or filetype specific bindings
" nnoremap M m
" }}}
" Other General Mappings {{{
" jump up and down
nnoremap <leader>k <c-d>zz:silent! call repeat#set("<c-d>zz", v:count)<cr>
nnoremap <leader>o <c-u>zz:silent! call repeat#set("<c-u>zz", v:count)<cr>
xnoremap <leader>k <c-d>zz
xnoremap <leader>o <c-u>zz
" control backspace behaviour
inoremap ¸ <c-w>
cnoremap ¸ <c-w>
nnoremap ¸ daw
inoremap .uu <c-u>
" paste in insert and command mode
inoremap .yp <c-r>+
cnoremap .yp <c-r>+
" source vimrc
nnoremap <leader>. :so ~/.vimrc<cr>
" source current buffer
nnoremap g. :so %<cr>
" source line or selection; https://bitbucket.org/sjl/dotfiles/src/tip/vim/vimrc#cl-405
nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
xnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
"'x-ray' view; cuc and cul
nnoremap <leader>x :set cursorcolumn!\|set cursorline!<cr>
" open with rifle
function! OpenCurrentLine()
" https://github.com/gotbletu/shownotes/blob/master/mlocate_vdiscover_vim_locate.txt
" grab current line
let line = getline (".")
" remove leading whitespace
let line = substitute(line, '^\s', '', "g")
" add qoutes around the current line to avoid spaces/symbols issues
let line = substitute(line, '^\(.*\)$', '"\1"', "g")
" changed to open with rifle (don't use with dirs/text files; use gf that)
exec "!rifle" line '>&/dev/null &'
endfunction
" bind function to a hotkey
nnoremap <leader>go :call OpenCurrentLine()<CR><CR>
" }}}
" _Clipboard/Yank/Paste Related {{{
" use +/clipboard as default register
set clipboard=unnamedplus
" http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/
" move to end after yank or paste; similar to gp but won't go to next line
xnoremap <silent> y y`]
xnoremap <silent> p p`]
nnoremap <silent> p p`]
" since have above, change gp to paste on new line
nnoremap gp :pu<cr>
nnoremap gy V`]
" https://github.com/Shougo/unite.vim/issues/415
let g:unite_source_history_yank_enable = 1
" saves things in clipboard register even if not yanked in vim
let g:unite_source_history_yank_save_clipboard = 1
" don't save yanks to disk
let g:unite_source_history_yank_file=""
" let g:unite_source_history_yank_limit = 300
nnoremap <space>y :Unite history/yank<cr>
" }}}
" }}}
" #==============================
" # Commands/ Shell {{{
" #==============================
" get rid of trailing whitespace; don't remember where got this from
command! Tr normal! mz:%s/\s\+$//<cr>:let @/=''<cr>`z
" copy current file path to clipboard
command! Yp let @+=expand("%:p")
" Shell Specific
nnoremap <a-1> :let @+=expand("%:p")<cr>:!xterm -e "<c-r>+" &<cr>
" mappings for in navigation.vim
command! ViewTxtPdf :!prose2pdf -v % &<cr>
" command! CurrentChapterStats :!
" " }}}
" #==============================
" # Plugin Unmaps {{{
" #==============================
autocmd VimEnter * silent! nunmap <leader>tt
" replace camelcase's ib map
autocmd VimEnter * omap ib <Plug>(textobj-anyblock-i)|xmap ib <Plug>(textobj-anyblock-i)
" }}}
" #==============================
" # Buffer, Window, and Tab Management Mappings and Settings {{{
" #==============================
nnoremap <space>q 1gt
nnoremap <space>w 11gt
" re-setup session/tabs and close other buffers
nnoremap ,ks 1gt:tabonly<cr>:only<cr>:e ~/.vimrc<cr>:vsplit ~/.zshrc<cr>:tabe ~/ag-sys/else/log.org<cr>:tabe ~/ag-sys/else/arch_and_program_info.org<cr>:vsplit ~/ag-sys/else/everything_index.org<cr>:TabooRename main<cr>:tabe ~/ag-sys/else/browse.org<cr>:TabooRename browse<cr>:tabe ~/.navigation.vim<cr>:TabooRename config<cr>:tabe ~/dotfiles/post_install/post_install.sh<cr>:TabooRename bin<cr>:tabe ~/ag-sys/else/remapping.org<cr>:TabooRename remap<cr>:tabe ~/ag-sys/else/consume/book_notes.org<cr>:vsplit ~/ag-sys/else/music/listen/music.org<cr>:TabooRename cons<cr>:tabe ~/ag-sys/else/scrawl/prose/pots/draft_a.org<cr>:vsplit ~/ag-sys/else/scrawl/prose/pots/plot.org<cr>:TabooRename wr<cr>:tabnew<cr>:TabooRename wr<cr>:tabnew<cr>:Wipeout<cr>2gt
" repls; vimshell has some annoyances though (lack of visual updating when window not active, weird cursor blinking, errors, etc.)
nnoremap ,kl :TabooRename prog<cr>:VimShellInteractive --split='vsplit' sbcl<cr>
nnoremap ,kp :TabooRename prog<cr>:VimShellInteractive --split='vsplit' python<cr>
nnoremap ,kh :TabooRename prog<cr>:VimShellInteractive --split='vsplit' ghci<cr>
source ~/.navigation.vim
augroup navigationSourcing
au!
au BufEnter * so ~/.navigation.vim
augroup END
" General Quickmarks {{{
nnoremap ,a :e ~/ag-sys/else/arch_and_program_info.org<cr>
nnoremap ,b :e ~/ag-sys/else/browse.org<cr>
nnoremap ,B :e ~/.config/bspwm/bspwmrc<cr>
nnoremap ,c :e ~/.config/ranger/rc.conf<cr>
nnoremap ,d :e ~/ag-sys/else/scrawl/ideas.org<cr>
nnoremap ,E :e ~/.emacs.d/awaken.org<cr>
nnoremap ,g :e ~/.pentadactyl/groups.penta<cr>
nnoremap ,i :e ~/ag-sys/else/interaction.org<cr>
nnoremap ,I :e ~/dotfiles/post_install/post_install.txt<cr>
nnoremap ,j :e ~/ag-sys/else/journal.org<cr>
nnoremap ,l :e ~/ag-sys/else/log.org<cr>
nnoremap ,m :e ~/.muttrc<cr>
nnoremap ,M :e ~/ag-sys/else/music/listen/music.org<cr>
nnoremap ,n :e ~/.navigation.vim<cr>
nnoremap ,p :e ~/.pentadactylrc<cr>
nnoremap ,P :e ~/ag-sys/else/policy.org<cr>
nnoremap ,r :e ~/ag-sys/else/remapping.org<cr>
nnoremap ,R :e ~/.README.md<cr>
nnoremap ,t :e ~/.tmux.conf<cr>
nnoremap ,v :e ~/.vimrc<cr>
nnoremap ,w :e ~/ag-sys/else/workflow.org<cr>
nnoremap ,x :e ~/.xinitrc<cr>
nnoremap ,y :Unite -start-insert buffer file_mru<cr>.yml<esc>
nnoremap ,z :e ~/.zshrc<cr>
nnoremap ,2 :e ~/ag-sys/else/20xx.org<cr>
" }}}
" Tabs {{{
nnoremap <leader>t :tabnew<cr>
" go to last tab
nnoremap <space>l :TWcmd tcm p<cr>
" move tabs
nnoremap <leader>N :tabm -1<cr>
nnoremap <leader>E :tabm +1<cr>
" Taboo {{{
" default tab naming behaviour
let g:taboo_modified_tab_flag='+'
let g:taboo_tab_format='%m%f'
let g:taboo_renamed_tab_format='[%l]%m'