-
Notifications
You must be signed in to change notification settings - Fork 1
/
.syncedvimrc
885 lines (760 loc) · 25.7 KB
/
.syncedvimrc
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
" Start a new autocommand group
:augroup vimrc
" Erase all autocommands so far in this group
:autocmd!
"{{{ Vim default behavior
" Vim settings instead of vi settings. make sure this is near the top of vimrc
set nocompatible
" Something about security and scripts running automatically
set modelines=0
" Set history and undo levels to more
set undolevels=300
set history=300
" Allow backspace to erase more in insert mode
set backspace=indent,eol,start
" Set ignore case in search
set ic
" Don't ignore case in search when caps specified
set smartcase
" Incremental search (move tmp cursor as you type)
set incsearch
" Highlight search
set hls
" Settings for taboo tab renaming, save tabs and globals in sessions on save
set sessionoptions+=tabpages,globals
" Fix colors when restoring a session
set sessionoptions-=options
" make tab autocompletion work like bash, with highlighting
set wildmode=longest,list,full
set wildmenu
" ignore case in command completion
try
set wildignorecase
catch
endtry
" Save current view when leaving, load when entering buffer
autocmd BufWinLeave *.* if bufname("%")!=""|mkview|endif
autocmd BufWinEnter *.* silent loadview
" Hack to allow "crontab -e" on mac
au BufEnter /private/tmp/crontab.* setl backupcopy=yes
" Source this and vimrc on write/save
if has("win32") || has("win16")
autocmd! bufwritepost _vimrc source %
autocmd! bufwritepost .syncedvimrc source ~/_vimrc
else
autocmd! bufwritepost .vimrc source %
autocmd! bufwritepost .syncedvimrc source ~/.vimrc
endif
"}}}
"{{{ Formatting/wrapping/spacing
" Turn on auto-indenting
set autoindent
set smartindent
" Autowrap text and comments at textwidth if set
set formatoptions+=tc
" Don't break a line if it was greater than textwidth when insert mode entered
set formatoptions+=l
" Trailing white space indicates a paragraph continues in the next line.
" A line that ends in a non-white character ends a paragraph.
set formatoptions+=w
" Allow formatting of comments with "gq".
" Note that formatting will not change blank lines or lines containing
" only the comment leader. A new paragraph starts after such a line,
" or when the comment leader changes.
set formatoptions+=q
" v: Vi-compatible auto-wrapping in insert mode: Only break a line at a
" blank that you have entered during the current insert command. (Note:
" this is not 100% Vi compatible. Vi has some "unexpected features" or
" bugs in this area. It uses the screen column instead of the line
" column.)
" b: Like 'v', but only auto-wrap if you enter a blank at or before
" the wrap margin. If the line was longer than 'textwidth' when you
" started the insert, or you do not enter a blank in the insert before
" reaching 'textwidth', Vim does not perform auto-wrapping.
set formatoptions+=b
" Continue comments after hitting enter (r) and 'o' (o)
set formatoptions+=ro
" Set tab width
set tabstop=2
set shiftwidth=2
" Use tabs instead of spaces
set expandtab
" Mark end of change-to text with a '$'
set cpoptions+=$
"}}}
"{{{ Misc Mappings
" Custom leader, comma
let mapleader = ","
" Remap comma's old functionality to ctrl-backslash
nmap \ ,
vmap \ ,
" Map jk to escape
:inoremap jk <Esc>
" Shortcut to auto indent entire file, then go back to location
nmap <leader>i gg=G``
"imap <leader>i <ESC>gg=Ga'' " I don't want this in insert mode anymore
" Open current buffer in new tab
nmap <leader>o :tabedit %<CR>
" Open current buffer in new tab and closes in previous
nmap <leader>O :tabedit %<CR> \| :tabp <CR>\| :q <CR>\| :tabn <CR>
" Close current tab
nmap <leader>q :tabclose<CR>
" Alt-q, close tab
nmap Å“ :tabclose<CR>
"nmap q :tabclose<CR>
" Alt-j, navigate to last tab
map ∆ :tabl<CR>
"map j :tabl<CR>
" Alt-k, navigate to first tab
map Ëš :tabfir<CR>
"map k :tabfir<CR>
" Alt-h, navigate to previous tab
map Ë™ :tabp<CR>
"map h :tabp<CR>
" Alt-l, navigate to next tab
map ¬ :tabn<CR>
"map l :tabn<CR>
" Alt-c, create new tab
map ç :tabnew<CR>
"map c :tabnew<CR>
" Alt-r, rename tab
map ® :TabooRename
"map r :TabooRename
" Alias :W as :w, so write command works with caps or not
" Don't use cnoreabbrev because it breaks case sensitive search (e.g. for capital Q)
"cnoreabbrev W w
"cnoreabbrev Q q
"cnoreabbrev Qa qa
if has("user_commands")
command! -bang -nargs=? -complete=file E e<bang> <args>
command! -bang -nargs=? -complete=file W w<bang> <args>
command! -bang -nargs=? -complete=file Wq wq<bang> <args>
command! -bang -nargs=? -complete=file WQ wq<bang> <args>
command! -bang Wa wa<bang>
command! -bang WA wa<bang>
command! -bang Q q<bang>
command! -bang QA qa<bang>
command! -bang Qa qa<bang>
endif
" Allow saving as sudo with `:w!!` even if vim wasn't started with sudo
cmap w!! w !sudo tee > /dev/null %
" Alias leader-s as :w
nmap <leader>s :w<CR>
" Alias alt-w as :w
nmap ∑ :w<CR>
" Allow jumping between quickfix errors
nmap ]l :lnext<CR>
nmap [l :lprevious<CR>
" make j and k act normally for wrapped lines. ctrl-j/k for expected jump behavior
nnoremap j gj
nnoremap k gk
" make K work like k
nnoremap K k
vnoremap K k
"}}}
"{{{ Custom functions and mappings
" {{{ copy/paste mode
" Shortcut to prepare for paste
"nnoremap <leader>p :se paste!<CR> "doesn't provide feedback on current mode
function! PasteToggle()
if &paste
setlocal nopaste
echom "Paste mode disabled"
else
setlocal paste
echom "Paste mode enabled"
endif
endfunction
function! PasteXclip()
setlocal paste
r ! xclip -o -sel clipboard
setlocal nopaste
endfunction
function! PasteSystem()
setlocal paste
normal! "*p
setlocal nopaste
endfunction
function! PasteGui()
setlocal paste
normal! "+p
setlocal nopaste
endfunction
nnoremap <leader>p :call PasteToggle()<CR>
"add paste shortcuts below to .vimrc, depending on environment
"nnoremap <c-p> :call PasteXclip()<CR>
nnoremap <leader>P :call PasteSystem()<CR>
" Fold columns
let defaultfdc=2
"" Set 80 char wrapping for certain file types
"autocmd BufRead *.php,*.php call SetCodeWrapping()
"function! SetCodeWrapping()
" " Turn on wrapping
" set wrap
" " Set width to 80
" setlocal textwidth=80
" " More space for split windows
" let defaultfdc=1
" execute ":setlocal fdc=".defaultfdc
"endfunction
execute ":se fdc=".defaultfdc
" Shortcut to prepare for copy
function! CopyToggle()
if &foldcolumn
" hide extra columns
let b:defaultfdc = &fdc
setlocal nonu
if (&rnu)
let b:rnu=1
endif
ALEDisable
SyntasticReset
setlocal nornu
setlocal nolist
setlocal foldcolumn=0
echom "Copy mode enabled"
else
" show extra columns
if (exists('b:defaultfdc'))
else
let b:defaultfdc = defaultfdc
endif
if b:rnu
setlocal rnu
endif
ALEEnable
setlocal nu
setlocal list
"setlocal foldcolumn=defaultfdc
"execute ":setlocal fdc=".defaultfdc
execute ":se fdc=".b:defaultfdc
echom "Copy mode disabled"
endif
endfunction
nnoremap <leader>c :call CopyToggle()<CR>
"}}}
" {{{ Indenting
" Indent the = sign on a range of lines
"map <leader>ec :call IndentRange()<CR>
map <F1> :call IndentRange()<CR>
function! GetIndentColumn()
normal 0f=
return col(".")
"let b:EqualColumn = col(".")
endfunction
function! ResetIndent()
s/ \+=/ =/g
"let b:EqualColumn = col(".")
endfunction
function! IndentEqualsTo(column)
"echom col(".")
"echom b:EqualColumn
normal 0f=
while col(".") < a:column
exe "normal i l"
endwhile
endfunction
function! IndentRange()
let l:first_line = line("'<")
let l:last_line = line("'>")
let l:current_line = l:first_line
let l:biggest_indent_line = l:first_line
let l:biggest_indent = 0
"go through each line, searching for biggest indent
while l:current_line <= l:last_line
exe "normal " . l:current_line . "G"
call ResetIndent()
let column = GetIndentColumn()
if l:column > l:biggest_indent
let l:biggest_indent = l:column
let l:biggest_indent_line = l:current_line
endif
let l:current_line = l:current_line + 1
endwhile
"start over, indenting each line as we go
let l:current_line = l:first_line
while l:current_line <= l:last_line
exe "normal " . l:current_line . "G"
let l:column = IndentEqualsTo(l:biggest_indent)
if l:column > l:biggest_indent
let l:biggest_indent = l:column
let l:biggest_indent_line = l:current_line
endif
let l:current_line = l:current_line + 1
endwhile
endfunction
"}}}
" {{{ Hex mode
" ex command for toggling hex mode - define mapping if desired
command! -bar Hexmode call ToggleHex()
" helper function to toggle hex mode
function! ToggleHex()
" hex mode should be considered a read-only operation
" save values for modified and read-only for restoration later,
" and clear the read-only flag for now
let l:modified=&mod
let l:oldreadonly=&readonly
let &readonly=0
let l:oldmodifiable=&modifiable
let &modifiable=1
if !exists("b:editHex") || !b:editHex
" save old options
let b:oldft=&ft
let b:oldbin=&bin
let b:oldeol=&eol
" set new options
setlocal binary " make sure it overrides any textwidth, etc.
silent :e " this will reload the file without trickeries
"(DOS line endings will be shown entirely )
setlocal noeol
let &ft="xxd"
" set status
let b:editHex=1
" switch to hex editor
%!xxd -ps
else
" restore old options
let &ft=b:oldft
let &eol=b:oldeol
if !b:oldbin
setlocal nobinary
endif
" set status
let b:editHex=0
" return to normal editing
%!xxd -r -ps
endif
" restore values for modified and read only state
let &mod=l:modified
let &readonly=l:oldreadonly
let &modifiable=l:oldmodifiable
endfunction
"}}}
" View diff from last save
if !exists(":DiffOrig")
command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
\ | wincmd p | diffthis
endif
" Run phpunit on a group
function! s:PhpUnit(group)
echom "group=" + a:group
let g:phpunit_args_append = "--group " . a:group
exec ":Test"
endfunction
" Leader-t runs phpunit on specified group
"command! -nargs=1 Phpunit call s:PhpUnit(<q-args>)
"map <leader>t :Phpunit
"}}}
"{{{ Folding
" Set vim filetype to marker folded
:au Filetype vim exec "se fdm=marker"
:au Filetype vim exec "se foldmarker={{{,}}}"
" Autofold document with {,}
nnoremap <leader>f :call AutoFold()<CR>
nnoremap <leader>F :call AutoFold2()<CR>
function! AutoFold()
set foldmethod=marker
set foldmarker={,}
"set foldmethod=manual
endfunction
function! AutoFold2()
"set foldmethod=marker
"set foldmarker={,}
set foldmethod=manual
endfunction
" Reese's command for custom fold text: first line concat next line
function! MyFoldText()
let line = getline(v:foldstart)
let line2 = getline(v:foldstart + 1)
let sub = substitute(line . "|" . line2, '/\*\|\*/\|{{{\d\=', '', 'g') "}}} close fold on this line
let ind = indent(v:foldstart)
let lines = v:foldend-v:foldstart + 1
let i = 0
let spaces = ''
while i < (ind - ind/4)
let spaces .= ' '
let i = i+1
endwhile
"let chars = eval(s/././ng)
"winwidth('.')
let offset = 10 + float2nr(log10(lines)) + &foldcolumn + &numberwidth
let filler = winwidth(0) - strlen(spaces . sub) - offset
return spaces . sub . repeat('-', filler) . '('. lines . ' lines)'
endfunction
"from http://www.gregsexton.org/2011/03/improving-the-text-displayed-in-a-fold/
function! CustomFoldText()
"get first non-blank line
let fs = v:foldstart
while getline(fs) =~ '^\s*$' | let fs = nextnonblank(fs + 1)
endwhile
if fs > v:foldend
let line = getline(v:foldstart)
else
let line = substitute(getline(fs), '\t', repeat(' ', &tabstop), 'g')
endif
let w = winwidth(0) - &foldcolumn - (&number ? 8 : 0)
let foldSize = 1 + v:foldend - v:foldstart
let foldSizeStr = " " . foldSize . " lines "
let foldLevelStr = repeat("+--", v:foldlevel)
let lineCount = line("$")
let foldPercentage = printf("[%.1f", (foldSize*1.0)/lineCount*100) . "%] "
let expansionString = repeat(".", w - strwidth(foldSizeStr.line.foldLevelStr.foldPercentage))
return line . expansionString . foldSizeStr . foldPercentage . foldLevelStr
endfunction
"set foldtext=MyFoldText()
set foldtext=CustomFoldText()
"}}}
"{{{ Bundles
"{{{ List bundles
function! GetBundles()
Bundle 'gmarik/vundle'
"Add your bundles here
"uber awesome syntax and errors highlighter
"Bundle 'Syntastic' "old repo?
Bundle 'vim-syntastic/syntastic'
Bundle 'dense-analysis/ale'
Bundle 'altercation/vim-colors-solarized'
"Git plugin
Bundle 'https://github.com/tpope/vim-fugitive'
Bundle 'https://github.com/tpope/vim-unimpaired'
"...All your other bundles...
"vdebug
Bundle 'joonty/vdebug.git'
"NERDTree
Bundle 'scrooloose/nerdtree'
"tab names
"Bundle 'shinymayhem/Tab-Rename'
Bundle 'shinymayhem/taboo.vim'
"fuzzy file finder
Bundle 'ctrlpvim/ctrlp.vim'
"less syntax highlighting
Bundle 'groenewege/vim-less'
"snipmate
Bundle "MarcWeber/vim-addon-mw-utils"
Bundle "tomtom/tlib_vim"
Bundle "garbas/vim-snipmate"
Bundle "honza/vim-snippets"
Bundle "shinymayhem/cypher-vim-syntax"
Bundle 'https://github.com/sukima/xmledit'
" relative line numbers
Bundle "jeffkreeftmeijer/vim-numbertoggle"
" jade syntax highlighting
Bundle "digitaltoad/vim-jade"
" Indent whitespace highlighting
Bundle "nathanaelkane/vim-indent-guides"
" better json syntax handling
Bundle "elzr/vim-json"
" leader-w to move to next camelcase or underscore word
Bundle "bkad/camelcasemotion"
"Bundle "kien/rainbow_parentheses.vim"
Bundle "luochen1990/rainbow"
" Dynamic window resizing
Bundle "roman/golden-ratio"
"Plugin 'google/yapf', { 'rtp': 'plugins/vim' }
Plugin 'fatih/vim-go'
Bundle 'ycm-core/YouCompleteMe'
Plugin 'hashivim/vim-terraform'
endfunction
"}}}
" Install bundles {{{
" On first load, read/source bundles
if has("win32") || has("win16")
cd ~/
"gvim _vimrc
let vundle_readme=expand('~/vimfiles/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "follow instructions at https://github.com/gmarik/vundle/wiki/Vundle-for-Windows"
echo ""
else
"echo "vundle already installed"
endif
set rtp+=~/vimfiles/bundle/vundle/
call vundle#rc('~/vimfiles/bundle')
call GetBundles()
else "linux/mac
" Setting up Vundle - the vim plugin bundler
let iCanHazVundle=1
let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
let iCanHazVundle=0
endif
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
call GetBundles()
if iCanHazVundle == 0
echo "Installing Bundles, please ignore key map error messages"
echo ""
:BundleInstall
endif
" Setting up Vundle - the vim plugin bundler end
endif
"}}}
" Customize bundles {{{
let g:terraform_align=1
let g:terraform_fmt_on_save=1
" These are set in vim-terraform's ftdetect, not sure why it isn't working
autocmd BufRead,BufNewFile *.tf,*.tfvars,.terraformrc,terraform.rc set filetype=terraform
autocmd BufRead,BufNewFile *.tfstate,*.tfstate.backup set filetype=json
" disable auto golden ratio resizing
let g:golden_ratio_autocommand = 0
:map <leader>r :GoldenRatioResize<CR>
let g:rainbow_active = 1
"hue-contrasty order
let g:rainbow_conf = {
\ 'ctermfgs': ['1', '2', '4', '3', '5', '6', '7'],
\ 'guifgs': ['red', 'orange', 'yellow', 'green', 'blue', 'violet', 'white']
\}
"rainbow order
"let g:rainbow_conf = {
" \ 'ctermfgs': ['1', '2', '4', '3', '5', '6', '7']
" \}
" xmledit
let g:xmledit_enable_html = 1 "make it work on html files
" Override xmledit html callback, don't add extra attributes
function! HtmlAttribCallback( xml_tag )
return 0
endfunction
" Set up default mappings for camelcasemotion
call camelcasemotion#CreateMotionMappings('<leader>')
" vdebug
if !exists('g:vdebug_options')
let g:vdebug_options = {}
endif
let g:vdebug_options["break_on_open"]=0
" Taboo_rename vdebug tab
noremap <F8> :TabooRename debugger<CR>
" Auto renaming doesn't work because of python waiting or something
"let g:vdebug_keymap = { 'run':"" }
"noremap <F5> :python debugger.run()<CR> :TabooRename debugger<CR>
" Customize renamed tab format
let g:taboo_renamed_tab_format=" [%N]%f%m "
" Syntastic, show errors list when detected
"let g:syntastic_auto_loc_list=1
" Syntastic, show errors list, close when empty, don't open automatically
let g:syntastic_auto_loc_list=2
"let g:syntastic_sh_shellcheck_args="-e SC2034"
" Snipmate
let g:snips_author = "Reese Wilson"
let g:snipMate = get(g:, 'snipMate', {})
let g:snipMate.scope_aliases = {}
let g:snipMate.scope_aliases['php'] = 'php,html'
let g:snipMate.scope_aliases['javascript'] = 'javascript,javascript-jquery'
let g:snipMate.scope_aliases['css'] = 'css'
let g:snipMate.no_default_aliases = 1
" Shortcut to open file explorers
:map <leader>n :NERDTreeToggle<CR>
:map <leader>, :CtrlP<CR>
let g:ctrlp_map = ''
" Fix nerdtree weird characters
let g:NERDTreeDirArrows=1
let g:NERDTreeDirArrowExpandable="+"
let g:NERDTreeDirArrowCollapsible="~"
" ignore .pyc files
let NERDTreeIgnore = ['\~$', '\.pyc$']
" Shortcut to open nerdtree to current file location
:map <leader>N :NERDTreeFind<CR>
" Ctrlp show hidden files
"let g:ctrlp_show_hidden=1
" Ignore files and/or directories
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/](\.git|vendor|\.vim)$'
\ }
" ctrlp search defaults to current dir up to closest .git dir
let g:ctrlp_working_path_mode = 'ra'
" change json filetype from javascript for eslint
au BufNewFile,BufRead *.json set filetype=json
" disable json quote concealing
let g:vim_json_syntax_conceal = 0
" enable eslint
let g:syntastic_javascript_checkers = ['eslint']
" enable python pep8
"let g:syntastic_python_checkers = ['python', 'pyflakes']
let g:syntastic_python_checkers = ['python', 'pylint', 'pep8', 'flake8']
" Open omnifunc whenever '.' is pressed in go
"au filetype go inoremap <buffer> . .<C-x><C-o>
map <leader>t <Plug>(go-def-type-tab)
"let g:go_def_reuse_buffer = 1
" Set go linters (doesn't seem to work, and megacheck takes a long time
" anyway, would need to find how to increase deadline timeout)
let g:go_meta_linter_enabled = ['vet', 'golint', 'errcheck', 'megacheck']
let g:syntastic_go_checkers = ['golangci-lint']
" help go_def work with local packages/modules in subdirectories
"let g:go_def_mode="godef"
" Indent guides configuration
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_default_mapping = 1 "leader-ig
let g:indent_guides_auto_colors = 0
" light bg
"autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=0 ctermfg=10 guibg=#f1fdd8
"autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=8 ctermfg=10 guibg=#f7f6d2
" dark bg
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=0 ctermfg=10 guibg=#012d38
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=8 ctermfg=10 guibg=#073642
"
"autocmd VimEnter,Colorscheme * :hi link IndentGuidesOdd CursorLine "FIXME broken in macvim
"autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=bg ctermfg=10 "FIXME broken in macvim
"}}}
"}}}
"{{{ Appearance
" Statusline {{{
set statusline=%f "filename
set statusline+=%m "modified flag
set statusline+=%r "read only flag
set statusline+=\ #%n "buffer number
set statusline+=%= "right-align the rest
set statusline+=%l,%v "line/column number
" Syntastic settings, show errors in statusline
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%{fugitive#statusline()}
set statusline+=%*
"}}}
" Add line numbers
set nu
" show tabs as '| '
set list
set listchars=tab:\|\
" show trailing whitespace chars
set listchars+=trail:¯,nbsp:¯
" Show symbol if line wraps
"set listchars+=extends:#
" Set colorscheme *after* solarized bundle sourced
set bg=dark
colorscheme solarized
if has("gui_running")
" Mac Font
"set guifont=Monaco:h10
" Powerline Font
set guifont=MesloLGS\ NF\ Regular\ 8
" Other
set guifont=SourceCodePro\ 8
" Menu bar
set guioptions-=m
" Toolbar
set guioptions-=T
" Remove vertical and horizontal scrollbars
set guioptions-=L
set guioptions-=l
set guioptions-=R
set guioptions-=r
set guioptions-=b
" Switch to text-style tab display
set guioptions-=e
" Cursor colors
highlight Cursor guifg=black guibg=white
highlight iCursor guifg=white guibg=steelblue
" Cursorline colors
hi CursorLine gui=underline
":hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
"setguicursor=n-v-c:block-Cursor
"setguicursor+=i:ver100-iCursor
"setguicursor+=n-v-c:blinkon0
"setguicursor+=i:blinkwait10
else
" Cursor colors
"hi CursorLine gui=underline guibg=gray10
"ctermfg=white
"ctermbg=darkred ctermfg=white guibg=darkred guifg=white
hi CursorLine ctermbg=0 cterm=underline
if &term =~ "xterm-256color\\|xterm\\|rxvt"
" Use orange cursor in insert mode
let &t_SI = "\<Esc>]12;orange\x7"
" Red cursor
let &t_EI = "\<Esc>]12;red\007"
" Reset cursor when vim exits
autocmd VimLeave * silent !echo -ne "\033]112\007"
endif
"highlight whitespace at beginning of line
"hi PreWhitespace ctermbg=darkgreen guibg=darkgreen
" Match PreWhitespace /^\ \+/
endif
if version >= 703
" Highlight column 81 and beyond
"autocmd VimEnter,Colorscheme * :hi ColorColumn ctermbg=0
"dark bg
autocmd VimEnter,Colorscheme * :hi ColorColumn ctermbg=0 guibg=#073642 "solarized base02
"light bg
"autocmd VimEnter,Colorscheme * :hi ColorColumn ctermbg=0 guibg=#f7f6d2
"autocmd VimEnter,Colorscheme * :hi! link ColorColumn CursorLine
"hi ColorColumn ctermbg=0
hi! link ColorColumn CursorLine
"let &colorcolumn=join(range(81,999),",")
let &colorcolumn=81
endif
" switch between dark and light themes (or fix missing column colors)
nmap <leader>l :call Light()<CR>
nmap <leader>d :call Dark()<CR>
function! Dark()
autocmd! VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=0 ctermfg=10 guibg=#012d38
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=8 ctermfg=10 guibg=#073642
autocmd VimEnter,Colorscheme * :hi ColorColumn ctermbg=0 guibg=#073642 "solarized base02
se bg=dark
endfunction
function! Light()
autocmd! VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=0 ctermfg=10 guibg=#e5e5d7
"autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=8 ctermfg=10 guibg=#f7f6d2
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=8 ctermfg=10 guibg=#ffffdf
autocmd VimEnter,Colorscheme * :hi ColorColumn ctermbg=0 guibg=#f7f6d2
se bg=light
endfunction
function! FontSizePlus ()
let l:gf_size_whole = matchstr(&guifont, '\( \)\@<=\d\+$')
let l:gf_size_whole = l:gf_size_whole + 1
let l:new_font_size = ' '.l:gf_size_whole
let &guifont = substitute(&guifont, ' \d\+$', l:new_font_size, '')
endfunction
function! FontSizeMinus ()
let l:gf_size_whole = matchstr(&guifont, '\( \)\@<=\d\+$')
let l:gf_size_whole = l:gf_size_whole - 1
let l:new_font_size = ' '.l:gf_size_whole
let &guifont = substitute(&guifont, ' \d\+$', l:new_font_size, '')
endfunction
if has("gui_running")
nmap <C-_> :call FontSizeMinus()<CR>
nmap <C-=> :call FontSizePlus()<CR>
endif
" Show cursorline on window enter, hide on leave
" Do this after solarized theme loaded
autocmd WinEnter * setlocal cursorline
autocmd WinLeave * setlocal nocursorline
" Undo italic gui comments
highlight Comment cterm=none gui=none
"highlight FoldColumn guibg=Black guifg=White
"highlight FoldColumn ctermbg=black ctermfg=white
:highlight FoldColumn guibg=Black guifg=White
:highlight FoldColumn ctermbg=black ctermfg=white
"}}}
"{{{ Misc
" Custom file type behavior {{{
autocmd FileType yaml setlocal sw=2 ts=2
autocmd FileType javascript setlocal sw=2 ts=2
autocmd FileType vim setlocal sw=2 ts=2 expandtab
autocmd FileType go setlocal sw=4 ts=4 noexpandtab listchars=trail:¯,nbsp:¯,tab:\ \
autocmd FileType go let b:ale_linters = ['golangci-lint']
"}}}
"}}}
"{{{ Conclusion
" Save these lines until the end to help with plugin filetype detection
" Enable filetype based indenting
if (has("autocmd"))
filetype plugin indent on
else
endif
" These have to go after the filetype autocommands
" ALE checker options
let g:ale_go_go111module="on"
let g:ale_go_golangci_lint_package=1
let g:ale_go_golangci_lint_options=""
let g:ale_sh_shellcheck_exclusions = 'SC2034'
let g:ale_sh_shellcheck_options="-e SC2034"
"let g:sonyntastic_sh_shellcheck_args="-e SC2034"
" Enable syntax highlighting. this should go near the end of vimrc
syntax on
syntax enable
"}}}
" End autocommand group
:augroup END