-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
2169 lines (1816 loc) · 67.9 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
" This Vim file is organized into
" ### VIM Settings
" ### General
" ### Tabs
" ### Scrollbars/Status
" ### Windows
" ### Cursor Highlights
" ### Searching
" ### Colors
" ### Line Wrapping
" ### File Stuff
" ### Redraw
" ### Aliases and custom key functions
" ### Custom text inserts
" ### Plugins
" Use modern vim
set nocompatible
" Fix unicode things
set encoding=utf-8
scriptencoding utf-8
" Setup vim-plug
" Docs here: https://github.com/junegunn/vim-plug
call plug#begin('~/.vim/plugged')
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'tomtom/tlib_vim'
" Plug 'junegunn/vim-peekaboo'
"
Plug 'junegunn/gv.vim'
Plug 'Chiel92/vim-autoformat'
Plug 'Lokaltog/vim-easymotion'
" https://github.com/airblade/vim-gitgutter
" A Vim plugin which shows a git diff in the gutter (sign column) and
" stages/undoes hunks.
Plug 'airblade/vim-gitgutter'
nmap gh <Plug>(GitGutterNextHunk)
nmap gH <Plug>(GitGutterPrevHunk)
" let g:gitgutter_realtime = 0
let g:gitgutter_max_signs = 2000
set updatetime=100
Plug 'ap/vim-css-color'
" Alignment
" https://github.com/tommcdo/vim-lion
Plug 'tommcdo/vim-lion'
let g:lion_squeeze_spaces = 1
" tpope vinegar, but with nerdtree
Plug 'askedrelic/vim-vinegar'
" Trying filebeagle? faster and simpler than vinegar/nerdtree
" But less file mgmt features :(
" Plug 'jeetsukumaran/vim-filebeagle'
" Airline status bar and themes
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" A better JSON for Vim
Plug 'elzr/vim-json'
" Better yaml syntax highlighting
Plug 'martin-svk/vim-yaml'
" Normal Mode
" - gagiw to search the word
" - gagi' to search the words inside single quotes.
" Visual Mode
" - gag to search the selected text
" Plug 'Chun-Yang/vim-action-ag'
Plug 'ervandew/supertab' ", {'commit': 'feb2a5f8'}
" Plug 'rking/ag.vim'
" I like this; it doesn't work with completor.vim
"Plug 'garbas/vim-snipmate' ", {'commit': '2d3e8ddc'}
"Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'
Plug 'godlygeek/tabular'
Plug 'gregsexton/MatchTag'
" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/rainbow_parentheses.vim'
" Plug 'junegunn/vim-easy-align'
Plug 'msanders/cocoa.vim'
Plug 'plasticboy/vim-markdown'
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_frontmatter = 1
Plug 'rhysd/clever-f.vim'
Plug 'scrooloose/nerdcommenter'
"" NERDCommenter
"" Add spaces after comment delimiters by default
let g:NERDSpaceDelims = 1
"" Use compact syntax for prettified multi-line comments
let g:NERDCompactSexyComs = 1
"" Enable trimming of trailing whitespace when uncommenting
let g:NERDTrimTrailingWhitespace = 1
" Align line-wise comment delimiters flush left instead of following code indentation
let g:NERDDefaultAlign = 'left'
" Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDCommentEmptyLines = 1
let g:NERDCreateDefaultMappings = 0
nmap gc <plug>NERDCommenterToggle
vmap gc <plug>NERDCommenterToggle
" Run ctags in the bg on save
Plug 'ludovicchabant/vim-gutentags'
" 2017/02/01 now using ale for linting
" Plug 'scrooloose/syntastic'
" Plug 'w0rp/ale'
Plug 'scrooloose/nerdtree'
Plug 'jistr/vim-nerdtree-tabs'
Plug 'AndrewRadev/tagfinder.vim'
"
""""""""""""" File search plugins
" Install FZF from homebrew
" Plug '/usr/local/opt/fzf'
" Plug 'junegunn/fzf.vim'
" Ack search
" 2018 - replace by vim-grepper
" Plug 'wincent/ferret'
" Ags search
" 2018 - replaced by vim-grepper
" Plug 'gabesoft/vim-ags'
" Interface for using all search tools
" Binds gv, breaks my tab, stab indent binding
" https://github.com/mhinz/vim-grepper
Plug 'mhinz/vim-grepper'
let g:grepper = {}
let g:grepper.tools = ['rg', 'ag']
" Disable the 'choose your tool' prompt
let g:grepper.prompt = 0
runtime autoload/grepper.vim
" Jump to first result
let g:grepper.jump = 1
" Limit to 500 results
let g:grepper.stop = 1000
" let g:grepper.rg.grepprg .= '--block-buffered'
let g:grepper = extend(get(g:, 'grepper', {}), {
\ 'rg': {'grepprg': 'rg -H --no-heading --vimgrep $*'},
\ })
noremap <C-g> :Grepper -tool rg -query<Space>""<Left>
nmap gv <plug>(GrepperOperator)
xmap gv <plug>(GrepperOperator)
" Override default K man page grep
vmap K <plug>(GrepperOperator)
" File/buffer/MRU search
Plug 'ctrlpvim/ctrlp.vim'
" Faster ctrlp searches
Plug 'FelikZ/ctrlp-py-matcher'
" Search the current file by tags
Plug 'majutsushi/tagbar'
let g:tagbar_type_make = {
\ 'kinds':[
\ 'm:macros',
\ 't:targets'
\ ]
\}
" Indenting
" https://github.com/jeetsukumaran/vim-indentwise
Plug 'jeetsukumaran/vim-indentwise'
" Keep hitting v to expand region
Plug 'terryma/vim-expand-region'
""""""""""""""" Almost all the tpope
" I prefer nerdcommenter
" Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-git'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-speeddating'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired', {'commit': 'bacf154'}
Plug 'tpope/vim-dispatch'
Plug 'tpope/vim-rhubarb'
" https://github.com/yssl/QFEnter
" make Enter work in the QF window
Plug 'yssl/QFEnter'
" Eunuch - vim sugar for the UNIX shell commands
" :Remove: Delete a buffer and the file on disk simultaneously.
" :Unlink: Like :Remove, but keeps the now empty buffer.
" :Move: Rename a buffer and the file on disk simultaneously.
" :Rename: Like :Move, but relative to the current file's containing directory.
" :Chmod: Change the permissions of the current file.
" :Mkdir: Create a directory, defaulting to the parent of the current file.
" :Find: Run find and load the results into the quickfix list.
" :Locate: Run locate and load the results into the quickfix list.
" :Wall: Write every open window. Handy for kicking off tools like guard.
" :SudoWrite: Write a privileged file with sudo.
" :SudoEdit: Edit a privileged file with sudo.
" File type detection for sudo -e is based on original file name.
" New files created with a shebang line are automatically made executable.
" New init scripts are automatically prepopulated with /etc/init.d/skeleton.
Plug 'tpope/vim-eunuch'
" Library for yelp test files
Plug 'askedrelic/pair_files.vim'
Plug 'moll/vim-bbye'
" Lanugages
Plug 'sheerun/vim-polyglot'
" Python ---------
Plug 'vim-scripts/python_match.vim'
" Javascript --------
Plug 'pangloss/vim-javascript'
Plug 'vim-scripts/matchit.zip'
Plug 'vim-scripts/visualrepeat'
" indent lines
Plug 'nathanaelkane/vim-indent-guides'
" Plug 'Yggdroot/indentLine'
" let g:indentLine_faster = 1
" let g:indentLine_setConceal = 0
" Testing -------------
" use this?? diff navigator
Plug 'https://gitlab.com/mcepl/vim-diff_navigator.git'
" Too much setup...
" Plug 'hecal3/vim-leader-guide'
" https://github.com/vim-ctrlspace/vim-ctrlspace
" ctrlp style search plugin
" Plug 'vim-ctrlspace/vim-ctrlspace'
Plug 'benmills/vimux'
" https://github.com/janko-m/vim-test
" Should fix all my testing issues?
Plug 'janko-m/vim-test', { 'on': ['TestFile', 'TestNearest', 'TestLast'] }
" First letter of runner's name must be uppercase
let test#runners = {'yelp': ['Testify']}
function! EchoStrategy(cmd)
echo 'It works! Command for running tests: ' . a:cmd
endfunction
let g:test#custom_strategies = {'echo': function('EchoStrategy')}
let g:test#strategy = 'echo'
nmap <silent> <leader>t :TestNearest<CR>
nmap <silent> <leader>T :TestFile<CR>
nmap <silent> <leader>a :TestSuite<CR>
" nmap <silent> <leader>l :TestLast<CR>
" nmap <silent> <leader>g :TestVisit<CR>
"
" Other ideas
" noremap <silent> <leader>tt :TestNearest<CR>
" noremap <silent> <leader>tf :TestFile<CR>
" noremap <silent> <leader>ts :TestSuite<CR>
" noremap <silent> <leader>tl :TestLast<CR>
" if has("nvim")
" let test#strategy = "neovim"
" else
" let test#strategy = "vimterminal"
" endif
" https://github.com/bogado/file-line
" Let vim open file:lineno style
Plug 'bogado/file-line'
" maggggit
" https://github.com/jreybert/vimagit
" Plug 'jreybert/vimagit'
" Plug 'davidhalter/jedi-vim'
Plug 'sjl/gundo.vim', { 'on': 'GundoToggle' }
" Plug 'heavenshell/vim-pydocstring'
" provides additional text objects
" https://github.com/wellle/targets.vim
" ( ) b (work on parentheses)
" { } B (work on curly braces)
" [ ] (work on square brackets)
" < > (work on angle brackets)
" t (work on tags)
" cin) next )
" dtl) previous )
Plug 'wellle/targets.vim'
" colorscheme
" Plug 'morhetz/gruvbox'
Plug 'maralla/completor.vim'
Plug 'thiagoalessio/rainbow_levels.vim'
" map <leader>l :RainbowLevelsToggle<cr>
let g:rainbow_levels = [
\{'ctermbg': 'none'},
\{'ctermbg': 'none'},
\{'ctermbg': 'none'},
\{'ctermbg': 'none'},
\
\{'ctermbg': 3, 'guibg': '#ffc66d'},
\{'ctermbg': 9, 'guibg': '#cc7833'},
\{'ctermbg': 1, 'guibg': '#da4939'},
\{'ctermbg': 160, 'guibg': '#870000'}]
" https://github.com/christoomey/vim-tmux-runner
" Send commands to tmux
" VtrSendCommandToRunner
Plug 'christoomey/vim-tmux-runner'
" https://github.com/fatih/vim-go
" Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
call plug#end()
" Create vimrc group
augroup vimrc
autocmd!
augroup END
function! General_Settings()
" Restore the screen when we're exiting and set correct terminal
" behave xterm
if &term == "xterm"
let &term = "xtermc"
set rs
set t_ti= 7 [r [?47h
set t_te= [?47l 8
endif
" Fix term under cli vim
"if exists('$TMUX') && !has("gui_running")
" set term=screen-256color
"endif
" save last 50 search history items, last 50 edit marks,
" don't remember last search highlight
set viminfo=/50,'30,h
set backup " enable backup files
"set writebackup " enable backup files
set swapfile " enable swap files (useful when loading huge files)
let s:vimdir=$HOME . "/.vim"
let &backupdir=s:vimdir . "/backup" " backups location
let &directory=s:vimdir . "/tmp" " swap location
if exists("*mkdir")
if !isdirectory(s:vimdir)
call mkdir(s:vimdir, "p")
endif
if !isdirectory(&backupdir)
call mkdir(&backupdir, "p")
endif
if !isdirectory(&directory)
call mkdir(&directory, "p")
endif
endif
" skip backup for tmp files
set backupskip=/tmp/*,/private/tmp/*,*.tmp
" 2017/11/16 17:25:47
" Disable to let nvim work?
"let &viminfo=&viminfo . ",n" . s:vimdir . "/.viminfo" " viminfo location
" if you want to yank and paste with the system clipboard
" set clipboard=unnamed
" keep 1000 lines of command line history
set history=1000
" keep 1000 undo levels
set undolevels=1000
" Resize splits when the window is resized
autocmd VimResized * exe "normal! \<c-w>="
" allow you to have multiple files open and change between them without saving
set hidden
"make backspace work
set backspace=indent,eol,start
" highlight matching [{()}]
set showmatch
" have % bounce between angled brackets, as well as other kinds:
" set matchpairs+=<:>
" set comments=s1:/*,mb:*,ex:*/,f://,b:#,:%,:XCOMM,n:>,fb:-
" report: show a report when N lines were changed. 0 means 'all'
set report=0
" runtimepath: list of dirs to search for runtime files
" set runtimepath=~/.vim,$VIMRUNTIME
" Like File Explorer, preview window height is 8
"set previewheight=8
" always show status line
set ls=2
" Turn off bell, this could be more annoying, but I'm not sure how
set vb t_vb=
" shorten all vim messages
set shortmess=flnrxoOItTA
" We have a modern terminal
set ttyfast
set fileformats=unix,dos,mac
" Don't try to highlight lines longer than 800 characters.
set synmaxcol=800
" Add vertical spaces to keep right and left aligned
set diffopt=filler
" Ignore whitespace changes (focus on code changes)
set diffopt+=iwhite
" Allow cursor keys in insert mode.
if !has('nvim')
set esckeys
endif
" Only insert single space after a '.', '?' and '!' with a join command.
set nojoinspaces
" Don't reset cursor to start of line when moving around.
set nostartofline
" Use /bin/sh for executing shell commands
set shell=/bin/sh
" Use OSX Textmate style tabs and eol
" tab:▸
" eol:¬
" execute 'set listchars+=tab:' . nr2char(9656) . nr2char(183)
" execute 'set listchars+=eol:' . nr2char(172)
" set listchars=eol:¬,tab:→→,extends:>,precedes:<
" set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
set listchars=tab:▸\ ,eol:¬,extends:❯,precedes:❮,nbsp:+
set showbreak=↪
"check if file is written to elsewhere and ask to reload immediately, not when saving
"autocmd CursorHold * checktime
" automatically reload a file when it has changed externally
set autoread
" automatically write the file a bunch of commands
set autowrite
" turn on wild command line completion (for :e)
set wildmenu
" Bash tab style completion is awesome
set wildmode=longest,list
" Tab completion key: default value is <C-E> but who doesn't complete with tab?
set wildchar=<tab>
" Ignore these filenames during enhanced command line completion.
set wildignore+=*.DS_Store " OSX bullshit
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+=*.pyc " Python byte code
set wildignore+=.tox " Python tox directory
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.sw? " Vim swap files
" set wildignore+=*/.git/*,*/.hg/*,*/.svn/* " Source control
" set wildignore+=*/eggs/*,*/develop-eggs/* " Python buildout
" Disable included files in tab complete, for now
set complete-=i
" redraw only when we need to.
set lazyredraw
" Time out on key codes but not mappings.
" Basically this makes terminal Vim work sanely.
set timeout
set ttimeoutlen=50
" set ttimeout
" set ttimeoutlen=100
set sessionoptions-=options
" make matchparen timeout quickly; don't take forever on long lines
let g:matchparen_insert_timeout=5
" let mapleader = ','
" Use space for leader
let g:mapleader = ' '
" shrug, local leader still doesn't make much sense to me
" let g:maplocalleader = '\'
" Search for ctags file up to /
set tags=tags;./;/
endfunction
call General_Settings()
function! Tabs()
function! Tabstyle_tabs()
" Using 4 column tabs
set softtabstop=4
set shiftwidth=4
set tabstop=4
set noexpandtab
endfunction
function! Tabstyle_spaces()
" Use 4 spaces
set expandtab
set autoindent
set copyindent
set shiftwidth=4
set tabstop=4
set softtabstop=4
endfunction
" function! Tabstyle_3spaces()
" " Use 3 spaces
" set expandtab
" set autoindent
" set copyindent
" set shiftwidth=3
" set tabstop=3
" set softtabstop=3
" endfunction
function! Tabstyle_2spaces()
" Use 2 spaces
setlocal expandtab
setlocal autoindent
setlocal copyindent
setlocal shiftwidth=2
setlocal tabstop=2
setlocal softtabstop=2
endfunction
call Tabstyle_spaces()
command! -nargs=* Stab call Stab()
function! Stab()
let l:tabstop = 1 * input('set shiftwidth=')
if l:tabstop > 0
" do we want expandtab as well?
" let l:expandtab = confirm('set expandtab?', "&Yes\n&No\n&Cancel")
" if l:expandtab == 3
" " abort?
" return
" endif
let &l:sts = l:tabstop
let &l:ts = l:tabstop
let &l:sw = l:tabstop
setlocal expandtab
endif
setlocal expandtab
" show the selected options
try
echohl ModeMsg
echon 'set tabstop='
echohl Question
echon &l:ts
echohl ModeMsg
echon ' shiftwidth='
echohl Question
echon &l:sw
echohl ModeMsg
echon ' sts='
echohl Question
echon &l:sts . ' ' . (&l:et ? ' ' : 'no')
echohl ModeMsg
echon 'expandtab'
finally
echohl None
endtry
endfunction
" when at 3 spaces, and I hit > ... go to 4, not 5
set shiftround
endfunction
call Tabs()
" ### Scrollbars/Status ###################################################
function! Scrollbars()
" show the cursor position all the time
set ruler
" always show line numbers
set number
" show in terminal title bar
set title
" display the current mode
set showmode
" display partially-typed commands
set showcmd
" ### Windows #############################################################
set splitbelow splitright
" don't always keep windows at equal size (for minibufexplorer)
" set noequalalways
" ### Cursor Highlights ###################################################
" highlight current line is good enough
set cursorline
"set cursorcolumn
set scrolloff=3
set sidescroll=1
set sidescrolloff=10
"Highlight cursorline ONLY in the active window:
autocmd WinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
" Highlight long lines
highlight clear ColorColumn
highlight ColorColumn cterm=underline gui=underline
"set colorcolumn=+1
" Highlight Long lines
nnoremap <silent> <leader>hl
\ :if exists('w:long_line_match') <Bar>
\ silent! call matchdelete(w:long_line_match) <Bar>
\ unlet w:long_line_match <Bar>
\ elseif &textwidth > 0 <Bar>
\ let w:long_line_match = matchadd('ColorColumn', '\%>'.&tw.'v.\+', -1) <Bar>
\ else <Bar>
\ let w:long_line_match = matchadd('ColorColumn', '\%>80v.\+', -1) <Bar>
\ endif<CR>
endfunction
call Scrollbars()
function! Searching()
" highlight search
set hlsearch
" case inferred by default
set infercase
" make searches case-insensitive
set ignorecase
"unless they contain upper-case letters:
set smartcase
" show the `best match so far' as search strings are typed:
set incsearch
" assume the /g flag on :s substitutions to replace all matches in a line:
set gdefault
" hide mouse on search
set mousehide
" Enable extended regexes.
set magic
" Searches wrap around end of file
set wrapscan
endfunction
call Searching()
function! Colors()
set background=dark
set t_Co=256
" One unified gui/terminal colorscheme
" colo Tomorrow-Night-Eighties
colorscheme badwolf
" colorscheme gruvbox
" let g:gruvbox_contrast_dark="soft"
if has("gui_running")
" set guifont=Monaco:h12
" set guifont=HackNerdFontCompleteMono-Regular:h12
set guifont=JetBrains_Mono_Regular_Nerd_Font_Complete_Mono:h13
" set guifont=Inconsolata:h14
" Orange :()
highlight SpellBad term=underline gui=undercurl guisp=Orange
" set lines=73 columns=271
set guioptions+=c " use console dialogs
set guioptions-=e " don't use gui tabs
set guioptions-=T " don't show toolbar
set guioptions-=m " don't show menu bar
set guioptions-=l " don't show left-hand scrollbar
set guioptions-=L " don't show left-hand scrollbar
set guioptions-=r " don't show right-hand scrollbar
set guioptions-=R " don't show right-hand scrollbar
" Use a line-drawing char for pretty vertical splits.
set fillchars+=vert:│
endif
" better diff pastel green/yellow/red diff colors
hi DiffAdd ctermfg=0 ctermbg=2 guibg=#cfffac guifg=#000000
hi DiffDelete ctermfg=0 ctermbg=1 guibg=#ffb6b0 guifg=#000000
hi DiffChange ctermfg=0 ctermbg=3 guibg=#ffffcc guifg=#000000
hi SignColumn guibg=#1C1B1A ctermbg=0
" Show the stack of syntax hilighting classes affecting whatever is under the
" cursor.
function! SynStack() "{{{
echo join(map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")'), " > ")
endfunc "}}}
" Highlight Tag? syntax?
nnoremap <leader>ht :call SynStack()<CR>
endfunction
call Colors()
function! Line_Wrapping()
" don't make it look like there are line breaks where there aren't:
set nowrap
" Wrap at word
set linebreak
" have the h and l cursor keys wrap between lines (like <Space> and <BkSpc> do
" by default), and ~ covert case over line breaks; also have the cursor keys
" wrap in insert mode:
set whichwrap=h,l,~,[,]
" only format comments at 80 chars by default, while typing
set textwidth=80
set formatoptions=
set formatoptions+=c " Format comments
set formatoptions+=r " Continue comments by default
" set formatoptions+=o " Make comment when using o or O from comment line
set formatoptions+=q " Format comments with gq
set formatoptions+=n " Recognize numbered lists
set formatoptions+=2 " Use indent from 2nd line of a paragraph
set formatoptions+=l " Don't break lines that are already long
set formatoptions+=1 " Break before 1-letter words
set formatoptions+=j " Delete comment character when joining commented lines
endfunction
call Line_Wrapping()
function! File_Types()
" Omni Completion
" mine set completeopt=menu,menuone,longest
set completeopt+=menuone
set completeopt-=menu
if &completeopt !~# 'noinsert\|noselect'
set completeopt+=noselect
endif
" complete using built in syntax? http://vim.wikia.com/wiki/Completion_using_a_syntax_file
" autocmd FileType * exec('setlocal dict+='.$VIMRUNTIME.'/syntax/'.expand('<amatch>').'.vim')
" CSS and LessCSS
augroup ft_css
autocmd!
autocmd bufnewfile,bufread *.less setlocal filetype=less
"autocmd Filetype less,css setlocal foldmethod=marker
"autocmd Filetype less,css setlocal foldmarker={,}
autocmd Filetype less,css setlocal omnifunc=csscomplete#CompleteCSS
autocmd Filetype less,css setlocal iskeyword+=-
" Use <leader>S to sort properties. Turns this:
"
" p {
" width: 200px;
" height: 100px;
" background: red;
"
" ...
" }
"
" into this:
" p {
" background: red;
" height: 100px;
" width: 200px;
"
" ...
" }
autocmd BufNewFile,BufRead *.less,*.css nnoremap <buffer> <localLeader>S ?{<CR>jV/\v^\s*\}?$<CR>k:sort<CR>:noh<CR>
" Make {<cr> insert a pair of brackets in such a way that the cursor is correctly
" positioned inside of them AND the following code doesn't get unfolded.
autocmd BufNewFile,BufRead *.less,*.css inoremap <buffer> {<cr> {}<left><cr><space><space><space><space>.<cr><esc>kA<bs>
augroup END
" Django
augroup ft_django
autocmd!
autocmd BufNewFile,BufRead urls.py setlocal nowrap
autocmd BufNewFile,BufRead urls.py normal! zR
autocmd BufNewFile,BufRead dashboard.py normal! zR
autocmd BufNewFile,BufRead local_settings.py normal! zR
autocmd BufNewFile,BufRead admin.py setlocal filetype=python.django
autocmd BufNewFile,BufRead urls.py setlocal filetype=python.django
autocmd BufNewFile,BufRead models.py setlocal filetype=python.django
autocmd BufNewFile,BufRead views.py setlocal filetype=python.django
autocmd BufNewFile,BufRead settings.py setlocal filetype=python.django
autocmd BufNewFile,BufRead forms.py setlocal filetype=python.django
autocmd BufNewFile,BufRead common_settings.py setlocal filetype=python.django
augroup END
" HTML and HTMLDjango
augroup ft_html
autocmd!
" autocmd BufNewFile,BufRead *.html setlocal filetype=htmldjango
" call Tabstyle_2spaces()
" NOTE: 2019-03-18, this seems broken?
"hitting % on <ul> jumps to <li> instead of </ul>
" autocmd FileType html let b:match_words='<:>,<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
autocmd FileType html setlocal omnifunc=htmlcomplete#CompleteTags
" Use Shift-Return to turn this:
" <tag>|</tag>
"
" into this:
" <tag>
" |
" </tag>
autocmd FileType html,jinja,htmldjango nnoremap <buffer> <s-cr> vit<esc>a<cr><esc>vito<esc>i<cr><esc>
" Django tags
autocmd FileType jinja,htmldjango inoremap <buffer> <c-t> {%<space><space>%}<left><left><left>
" Django variables
autocmd FileType jinja,htmldjango inoremap <buffer> <c-f> {{<space><space>}}<left><left><left>
augroup END
" Cheetah overrides
augroup ft_cheetah
autocmd!
autocmd BufNewFile,BufRead *.tmpl setlocal filetype=cheetah
augroup END
" Javascript
augroup ft_javascript
autocmd!
" easy comment insert
autocmd FileType javascript inoremap <buffer> <c-c> console.log();<left><left>
" autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
" autocmd FileType javascript setlocal foldmethod=marker
" autocmd FileType javascript setlocal foldmarker={,}
augroup END
augroup ft_markdown
autocmd!
autocmd BufNewFile,BufRead *.m*down setlocal filetype=markdown
" Use <localLeader>1/2/3 to add headings.
autocmd Filetype markdown nnoremap <buffer> <localLeader>1 yypVr=
autocmd Filetype markdown nnoremap <buffer> <localLeader>2 yypVr-
autocmd Filetype markdown nnoremap <buffer> <localLeader>3 I### <ESC>
" a function to execute formd and return the cursor back
" to it's original position within the buffer.
" http://drbunsen.github.io/formd/
function! Formd(option)
:let l:save_view = winsaveview()
:let l:flag = a:option
:if flag == "-r"
:%! formd -r
:elseif flag == "-i"
:%! formd -i
:else
:%! formd -f
:endif
:call winrestview(save_view)
endfunction
" formd mappings
nnoremap <localleader>fr :call Formd("-r")<CR>
nnoremap <localleader>fi :call Formd("-i")<CR>
" Format ...
nnoremap <localleader>f :call Formd("-f")<CR>
augroup END
augroup ft_nginx
autocmd!
autocmd BufRead,BufNewFile /etc/nginx/conf/* set ft=nginx
autocmd BufRead,BufNewFile /etc/nginx/sites-available/* set ft=nginx
autocmd BufRead,BufNewFile /usr/local/etc/nginx/sites-available/* set ft=nginx
autocmd BufRead,BufNewFile vhost.nginx set ft=nginx
augroup END
" Puppet
augroup ft_puppet
autocmd!
autocmd BufNewFile,BufRead *.pp setlocal filetype=puppet
augroup END
" Python
augroup ft_python
autocmd!
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
"autocmd FileType python compiler nose
" autocmd FileType man nnoremap <buffer> <cr> :q<cr>
" format comments correctly
autocmd FileType python setlocal textwidth=80
" autocmd FileType python setlocal formatoptions=croqn
" @NOTE disable smartindent, it forces inserting tabs. Use cindent instead
autocmd FileType python setlocal cindent cinwords=if,elif,else,for,while,with,try,except,finally,def,class
autocmd FileType python setlocal cinkeys-=0#
autocmd FileType python setlocal indentkeys-=0#
" Python mode settings
let g:pymode = 0
let g:pymode_syntax_all= 1
let g:pymode_indent = 1
let g:pymode_motion = 1
let g:pymode_rope_goto_definition_bind = ""
let g:pymode_run_bind = ""
let g:pymode_doc_bind = ""
let g:pymode_options_colorcolumn = 0
let g:pymode_folding = 0
" autocmd FileType python inoremap <buffer> <c-f> import IPython; IPython.embed()
" @NOTE This blows up omnifunc complete
" `gf` jumps to the filename under the cursor. Point at an import statement
" and jump to it!
" python << EOF
" import os
" import sys
" import vim
" for p in sys.path:
" if os.path.isdir(p):
" vim.command(r"set path+=%s" % (p.replace(" ", r"\ ")))
" EOF
augroup END
" Restructured text
augroup ft_rest
autocmd!
autocmd Filetype rst nnoremap <buffer> <localLeader>1 yypVr=
autocmd Filetype rst nnoremap <buffer> <localLeader>2 yypVr-
autocmd Filetype rst nnoremap <buffer> <localLeader>3 yypVr~
autocmd Filetype rst nnoremap <buffer> <localLeader>4 yypVr`
augroup END
" Ruby
augroup ft_ruby
autocmd!
autocmd Filetype ruby setlocal shiftwidth=2
autocmd Filetype ruby setlocal softtabstop=2
augroup END
augroup ft_vagrant
autocmd!
autocmd BufRead,BufNewFile Vagrantfile set ft=ruby
augroup END
" Vim
augroup ft_vim
autocmd!
autocmd FileType help setlocal textwidth=78 nonumber
autocmd BufWinEnter *.txt if &ft == 'help' | wincmd L | endif
" treat lines starting with a quote mark as comments (for `Vim' files, such as
" this very one!)
autocmd FileType vim setlocal comments+=b:\"
augroup END
"jump to last cursor position when opening a file
"except when writing a svn/git commit log entry
autocmd BufReadPost * call SetCursorPosition()
function! SetCursorPosition()
if &filetype !~ 'commit\c' && &filetype !~ 'svn\c'
if line("'\"") > 0 && line("'\"") <= line("$")
exe "normal g`\""
endif
end
endfunction
endfunction
call File_Types()
function! Normal_Mappings()
" Map uppercase write and quit, I'm lazy lazy lazy with shift
cab W w
cab Q q
cab WQ wq
cab WQ! wq!
" save even more keystrokes!