forked from mhinz/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
810 lines (683 loc) · 24.8 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
"
" ███████████████████████████
" ███████▀▀▀░░░░░░░▀▀▀███████
" ████▀░░░░░░░░░░░░░░░░░▀████
" ███│░░░░░░░░░░░░░░░░░░░│███
" ██▌│░░░░░░░░░░░░░░░░░░░│▐██
" ██░└┐░░░░░░░░░░░░░░░░░┌┘░██
" ██░░└┐░░░░░░░░░░░░░░░┌┘░░██
" ██░░┌┘▄▄▄▄▄░░░░░▄▄▄▄▄└┐░░██
" ██▌░│██████▌░░░▐██████│░▐██
" ███░│▐███▀▀░░▄░░▀▀███▌│░███
" ██▀─┘░░░░░░░▐█▌░░░░░░░└─▀██
" ██▄░░░▄▄▄▓░░▀█▀░░▓▄▄▄░░░▄██
" ████▄─┘██▌░░░░░░░▐██└─▄████
" █████░░▐█─┬┬┬┬┬┬┬─█▌░░█████
" ████▌░░░▀┬┼┼┼┼┼┼┼┬▀░░░▐████
" █████▄░░░└┴┴┴┴┴┴┴┘░░░▄█████
" ███████▄░░░░░░░░░░░▄███████
" ██████████▄▄▄▄▄▄▄██████████
" ███████████████████████████
"
" You are about to experience a potent dosage of Vim. Watch your steps.
"
" ╔══════════════════════════════════════════╗
" ║ ⎋ HERE BE VIMPIRES ⎋ ║
" ╚══════════════════════════════════════════╝
let s:is_win = has('win32')
let $v = $HOME.(s:is_win ? '\vimfiles' : '/.vim')
if s:is_win
set shell=cmd.exe
set shellcmdflag=/c
set encoding=utf-8
endif
" Plug {{{1
let s:bundle_dir = $v.'/bundle'
let g:plug_shallow = 0
let g:plug_window = 'enew'
let g:plug_pwindow = 'vertical rightbelow new'
call plug#begin(s:bundle_dir)
Plug 'jonathanfilip/vim-lucius'
Plug 'arcticicestudio/nord-vim'
Plug 'mhartington/oceanic-next'
Plug 'joshdick/onedark.vim'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'chrisbra/unicode.vim', {'on': ['UnicodeName', 'UnicodeTable']}
Plug 'godlygeek/csapprox', {'for': 'fugitiveblame' }
Plug 'junegunn/fzf', has('win32') ? {} : {'on': 'FZF', 'dir': '~/local/fzf', 'do': './install --bin'}
Plug 'junegunn/vim-easy-align', {'on': '<plug>(LiveEasyAlign)'}
Plug 'junegunn/vim-plug'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-rhubarb'
Plug 'tpope/vim-rsi'
Plug 'tpope/vim-scriptease'
Plug 'tpope/vim-surround'
if has('nvim-0.5')
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-treesitter/nvim-treesitter-refactor'
Plug 'nvim-treesitter/nvim-treesitter-textobjects'
Plug 'nvim-treesitter/playground'
Plug 'norcalli/nvim-colorizer.lua'
Plug 'nvim-lua/plenary.nvim'
Plug 'nvim-telescope/telescope.nvim'
Plug 'mhinz/telescope-spotlight.nvim'
Plug 'bfredl/luarefvim'
Plug 'phaazon/hop.nvim'
endif
let g:plug_url_format = '[email protected]:%s.git'
Plug 'mhinz/vim-crates'
Plug 'mhinz/vim-grepper'
Plug 'mhinz/vim-halo'
Plug 'mhinz/vim-janah'
Plug 'mhinz/vim-lookup'
Plug 'mhinz/vim-mix-format'
Plug 'mhinz/vim-rfc'
Plug 'mhinz/vim-sayonara', {'on': 'Sayonara'}
Plug 'mhinz/vim-signify'
Plug 'mhinz/vim-startify'
Plug 'mhinz/vim-tree'
unlet! g:plug_url_format
call plug#end()
if has('nvim-0.5')
lua require 'config'
lua require 'tree'
endif
" Init {{{1
if has('nvim')
let $GIT_EDITOR = 'nvr -cc split --remote-wait'
let $ELIXIR_EDITOR = 'nvr -l +__LINE__ __FILE__'
if v:progpath =~# 'build/bin/nvim$'
" for build/runtime/syntax/vim/generated.vim
let &runtimepath .= ','.$VIM.'/build/runtime'
endif
else
filetype plugin indent on
syntax on
packadd! matchit
endif
let g:vimsyn_embed = 'l'
let g:vimsyn_folding = 'f'
let g:is_bash = 1
let g:lisp_rainbow = 1
let g:markdown_fenced_languages = ['vim']
let g:loaded_2html_plugin = 1
let g:loaded_getscriptPlugin = 1
let g:loaded_gzip = 1
let g:loaded_logipat = 1
" let g:loaded_matchit = 1
" let g:loaded_matchparen = 1
let g:loaded_rrhelper = 1
let g:loaded_spellfile_plugin = 1
let g:loaded_tarPlugin = 1
let g:loaded_vimballPlugin = 1
let g:loaded_zipPlugin = 1
augroup vimrc
autocmd!
augroup END
" Option {{{1
" indent settings
set autoindent
set cinoptions =l1,p0,)50,*50,t0
set expandtab
set smarttab
set softtabstop =2
set shiftwidth =2
set shiftround
" backup/swap/info/undo settings
set nobackup
set nowritebackup
set undofile
set swapfile
if has('nvim')
set backupdir -=.
set shada ='100
else
set backupdir =$v/files/backup
set directory =$v/files/swap//
set undodir =$v/files/undo
set viewdir =$v/files/view
set viminfo ='100,n$v/files/info/viminfo
endif
" better navigation
set cursorline
set foldmethod =marker
set foldopen -=hor
set foldopen +=jump
set foldtext =mhi#foldy()
set hlsearch
set incsearch
set mouse =a
set scrolloff =4
set sidescroll =5
set ignorecase
set smartcase
set tagcase =match
" misc settings
set autoread
set backspace =indent,eol,start
set clipboard =unnamed
set complete -=i
set completeopt +=noselect
set diffopt +=vertical,foldcolumn:0,indent-heuristic,algorithm:patience
set fileformats =unix,dos,mac
set hidden
set history =1000
set lazyredraw
set more
set mousemodel =popup
set noautowrite
set noautowriteall
set noequalalways
set noerrorbells
set nofsync
set nojoinspaces
set wrapscan
set nrformats =hex
set pastetoggle =<F5>
set norelativenumber
set report =0
set sessionoptions-=options
set sessionoptions+=localoptions
set showfulltag
set showtabline =1
set splitbelow
set splitright
set switchbuf =
set synmaxcol =200
set tags ^=./.git/tags;
set timeout
set timeoutlen =1000
set titlestring =VIM:\ %f
set ttimeout
set ttimeoutlen =10
set ttyfast
set virtualedit =onemore,block
set whichwrap =h,l
" wild stuff
set suffixes +=.a,.1,.class
set wildignore +=*.o,*.so,*.zip,*.png
set wildmenu
set wildoptions =tagfile
if has('nvim')
set wildoptions+=pum
else
set wildmode=list:longest,full
endif
" display settings
set display +=lastline
set laststatus =2
set list
set modeline
set modelines =1
set nostartofline
set numberwidth =1
set ruler
set shortmess =aoOTI
set showcmd
set showmatch
set showmode
" spelling
set spellfile =~/.vim/spell/en.utf-8.add,~/.vim/spell/de.utf-8.add
set spelllang =en,de
" breaking
set wrap
set nolinebreak
set breakindent
set breakindentopt=min:40
"set highlight +=@:SpecialKey
set cpoptions =aABcefFqsZ
set formatoptions =tcrqnj
if has('multi_byte') && &encoding ==# 'utf-8'
let &listchars = 'tab:▸ ,extends:❯,precedes:❮,nbsp:±,trail:⣿'
let &fillchars = 'vert: ,diff: ' " ▚
let &showbreak = '↪ '
highlight VertSplit ctermfg=242
" augroup vimrc
" autocmd InsertEnter * set listchars-=trail:⣿
" autocmd InsertLeave * set listchars+=trail:⣿
" augroup END
else
let &listchars = 'tab:> ,extends:>,precedes:<,nbsp:.'
let &fillchars = 'vert: ,stlnc:#'
let &showbreak = '-> '
augroup vimrc
autocmd InsertEnter * set listchars-=trail:.
autocmd InsertLeave * set listchars+=trail:.
augroup END
endif
if has('nvim')
set signcolumn=auto:2
endif
" Mapping {{{1
let mapleader = ';'
nnoremap \ ;
inoremap jf <esc>
nnoremap gh :call mhi#github_open_issue()<cr>
nnoremap gH :call mhi#github_open_slug()<cr>
inoremap <expr> <tab> mhi#tab_yeah()
inoremap <expr> <c-]> mhi#close_bracket()
nnoremap <silent> <tab> <c-w>w:call halo#run()<cr>
nnoremap <silent> <c-p> :call mhi#switch_buffer('bprevious')<cr>
nnoremap <silent> <c-n> :call mhi#switch_buffer('bnext')<cr>
nnoremap <silent> [b :call mhi#switch_buffer('bprevious')<cr>
nnoremap <silent> ]b :call mhi#switch_buffer('bnext')<cr>
nnoremap <silent> [q :cprevious<bar>call halo#run()<cr>
nnoremap <silent> ]q :cnext<bar>call halo#run()<cr>
nnoremap <silent> [l :lprevious<bar>call halo#run()<cr>
nnoremap <silent> ]l :lnext<bar>call halo#run()<cr>
nnoremap <silent> [t :tabprevious<bar>call halo#run()<cr>
nnoremap <silent> ]t :tabnext<bar>call halo#run()<cr>
nnoremap [<space> :<c-u>put! =repeat(nr2char(10), v:count1)<cr>'[
nnoremap ]<space> :<c-u>put =repeat(nr2char(10), v:count1)<cr>
nnoremap [e :<c-u>execute 'move -1-'. v:count1<cr>
nnoremap ]e :<c-u>execute 'move +'. v:count1<cr>
" switch comma-separated arguments
nnoremap [w :normal F,h]w2w<cr>
nnoremap ]w :let s=&isk \| setl isk+=\",' \| exe "norm diwmmebgPdw'mP" \| let &isk=s<cr>
nnoremap } }zz
nnoremap { {zz
nnoremap ]] ]]zz
nnoremap [[ [[zz
nnoremap [] []zz
nnoremap ][ ][zz
nnoremap g; g;zvzz
nnoremap g, g,zvzz
nnoremap <left> <c-w>>
nnoremap <right> <c-w><
nnoremap <up> <c-w>-
nnoremap <down> <c-w>+
nnoremap <silent><a-h> :<c-u>call mhi#tmux_navigate('h')<cr>
nnoremap <silent><a-j> :<c-u>call mhi#tmux_navigate('j')<cr>
nnoremap <silent><a-k> :<c-u>call mhi#tmux_navigate('k')<cr>
nnoremap <silent><a-l> :<c-u>call mhi#tmux_navigate('l')<cr>
xnoremap < <gv
xnoremap > >gv
onoremap gv :<c-u>normal! gv<cr>
nnoremap Q gqap
nnoremap <leader>ev :edit $MYVIMRC<cr>
nnoremap <leader>em :edit ~/.vim/autoload/mhi.vim<cr>
nnoremap <leader>si :echo mhi#syninfo()<cr>
nnoremap <leader>ss :echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')<cr>
nnoremap <leader>m :Messages<cr>
nnoremap <leader>M :<c-u><c-r><c-r>='let @'. v:register .' = '. string(getreg(v:register))<cr><c-f><left>
" nnoremap <leader>o :!echo `git url`/blob/`git rev-parse --abbrev-ref HEAD`/%\#L<C-R>=line('.')<cr> \| xargs open<cr><cr>
nnoremap <leader>o :silent !open <c-r>=fnameescape('<c-r><c-a>')<cr><cr>
nnoremap <leader>w :update<cr>
nnoremap <leader>x :xit<cr>
nnoremap <leader>l :noh<bar>diffupdate<bar>call clearmatches()<bar>syntax sync fromstart<cr><c-l>
nnoremap <leader>v :Runtime<cr>
nnoremap <leader>t :Tree<cr>
nnoremap <silent> <leader>d :Dirview<cr>
" nnoremap <silent> <leader>d :exe 'sil !open' fnameescape(printf('https://devdocs.io/#q=%s%%20%s', &ft, expand('<cword>')))<cr>
nnoremap <silent><leader>b :call mhi#git_blame_current_line()<cr>
nnoremap ' `
nnoremap ` '
nnoremap <bs> <c-t>
nnoremap <silent><cr> :call mhi#jump()<cr>
cnoremap <expr> <c-n> wildmenumode() ? "\<c-n>" : "\<down>"
cnoremap <expr> <c-p> wildmenumode() ? "\<c-p>" : "\<up>"
cnoremap <leader>r $VIMRUNTIME/
cnoremap <leader>ft ~/.vim/after/ftplugin/
nnoremap <silent> n :call mhi#search_highlight_next_match('Nn'[v:searchforward])<cr>
nnoremap <silent> N :call mhi#search_highlight_next_match('nN'[v:searchforward])<cr>
xnoremap * :<c-u>call mhi#search()<cr>//<cr>
xnoremap # :<c-u>call mhi#search()<cr>??<cr>
if has('nvim')
nnoremap <leader>T :vsplit +terminal<cr>
tnoremap <esc> <c-\><c-n>
tnoremap <silent><a-h> <c-\><c-n>:<c-u>call mhi#tmux_navigate('h')<cr>
tnoremap <silent><a-j> <c-\><c-n>:<c-u>call mhi#tmux_navigate('j')<cr>
tnoremap <silent><a-k> <c-\><c-n>:<c-u>call mhi#tmux_navigate('k')<cr>
tnoremap <silent><a-l> <c-\><c-n>:<c-u>call mhi#tmux_navigate('l')<cr>
endif
if !has('nvim')
if empty($TMUX)
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
else
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
let &t_SR = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=2\x7\<Esc>\\"
endif
endif
" Autocmd {{{1
augroup vimrc
" foldopen=hor sucks
autocmd BufWinEnter * normal! zvzz
if has('nvim')
autocmd TermOpen,BufEnter term://* startinsert
endif
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ execute 'normal! g`"' |
\ endif
autocmd WinEnter * set cursorline
autocmd WinLeave * set nocursorline
autocmd InsertEnter * set nocursorline
autocmd InsertLeave * set cursorline
autocmd FocusGained * call halo#run()
autocmd CompleteDone * pclose
augroup END
" Command {{{1
command! -nargs=1 -complete=command Scratch call mhi#scratch(<f-args>)
command! CleanSpell runtime! spell/cleanadd.vim
command! Cd call mhi#cd()
command! -range Evo call mhi#git_log_evolution(<line1>, <line2>, expand('%'))
command! Changed exe 'args' join(map(systemlist('git diff --name-only --relative "$@" 2>/dev/null'), 'fnameescape(v:val)'))
command! -nargs=1 -bang T call mhi#terminal(<bang>0, <f-mods>, <f-args>)
command! Signs PP sign_getplaced('.', {'lnum': line('.'), 'group': '*'})
if has('nvim')
command! LuaG lua print(vim.inspect(_G))
command! LspClients lua print(vim.inspect(vim.lsp.buf_get_clients()))
endif
" Color {{{1
function! s:colors_default() abort
" highlight Comment cterm=italic
highlight link User1 StatusLine " master branch
highlight link User2 StatusLine " other branch
highlight link User3 StatusLine " separators
highlight link User4 StatusLine " filename at beginning
highlight link User5 StatusLine " ~changes
" highlight SignifySignAdd ctermfg=151 ctermbg=NONE cterm=NONE
" highlight SignifySignDelete ctermfg=181 ctermbg=NONE cterm=NONE
" highlight SignifySignChange ctermfg=187 ctermbg=NONE cterm=NONE
" highlight Halo guifg=white guibg=#F92672 ctermfg=white ctermbg=197
endfunction
function! s:colors_fnord() abort
highlight link StartifyPath Identifier
highlight link StartifyFile Directory
endfunction
function! s:colors_janah() abort
highlight User1 ctermfg=192 ctermbg=237 cterm=NONE
highlight User2 ctermfg=167 ctermbg=237 cterm=NONE
highlight User3 ctermfg=245 ctermbg=237 cterm=NONE
highlight User4 ctermfg=215 ctermbg=237 cterm=NONE
highlight User5 ctermfg=111 ctermbg=237 cterm=NONE
endfunction
function! s:colors_lucius() abort
if &background ==# 'light'
highlight Normal ctermbg=NONE guibg=NONE
highlight CursorLine ctermbg=255
highlight User1 ctermfg=84 ctermbg=237 cterm=NONE
highlight User2 ctermfg=222 ctermbg=237 cterm=NONE
highlight User3 ctermfg=237 ctermbg=237 cterm=NONE
highlight User4 ctermfg=255 ctermbg=237 cterm=NONE
highlight User5 ctermfg=255 ctermbg=237 cterm=NONE
highlight StatusLine ctermbg=237 cterm=NONE
highlight SignColumn ctermfg=NONE ctermbg=NONE cterm=NONE
highlight Question ctermfg=24 ctermbg=255 cterm=NONE
highlight Search ctermfg=fg ctermbg=222 cterm=NONE
highlight Folded ctermbg=253 cterm=NONE
" highlight NormalFloat ctermfg=231 ctermbg=240 cterm=NONE
highlight NormalFloat ctermfg=0 ctermbg=223 cterm=NONE
highlight DirviewArchive ctermfg=31
highlight DirviewDirectory ctermfg=88
highlight DirviewImage ctermfg=29
highlight DirviewVideo ctermfg=115
endif
endfunction
augroup vimrc
autocmd ColorScheme * call s:colors_default()
autocmd ColorScheme janah call s:colors_janah()
autocmd ColorScheme lucius call s:colors_lucius()
autocmd ColorScheme fnord call s:colors_fnord()
augroup END
if has('gui_running')
set background=light
colorscheme lucius
set guioptions=a
set mousehide
if s:is_win
autocmd GUIEnter * simalt ~x
let &guifont = 'Consolas:h10:b'
elseif has('gui_macvim')
set macmeta
let &guifont = 'Source Code Pro:h13'
endif
command! Bigger let &guifont = substitute(&guifont, '\d\+', '\=submatch(0)+1', '')
command! Smaller let &guifont = substitute(&guifont, '\d\+', '\=submatch(0)-1', '')
else
set termguicolors
if !has('nvim')
let &t_8f = "\<Esc>[38:2:%lu:%lu:%lum"
let &t_8b = "\<Esc>[48:2:%lu:%lu:%lum"
endif
if $TERM =~ 'alacritty'
set background=dark
color janah
highlight Normal ctermbg=236
elseif $ITERM_PROFILE == 'Light'
set background=light
colorscheme lucius
else
set background=dark
colorscheme fnord
endif
endif
" Statusline {{{1
command! -bar ToggleStatusline let b:stl_location = !get(b:, 'stl_location')
command! -bar ToggleHighlight let b:stl_highlight = !get(b:, 'stl_highlight')
nnoremap <silent><f10> :ToggleStatusline<cr>
nnoremap <silent><f11> :ToggleHighlight<cr>
set statusline=%!SetStatusline()
function! SetStatusline()
let stl = ' %4*%<%f%*'
if exists('b:git_dir')
let stl .= '%3*:%*'
let branch = fugitive#head(8)
let stl .= ((branch =~# 'master\|main') ? '%1*' : '%2*'). branch .'%*'
let stl .= mhi#sy_stats_wrapper()
endif
let stl .= '%m%r%h%w '
" right side
let stl .=
\ '%= '
\ . '%#ErrorMsg#%{&paste ? " paste " : ""}%*'
\ . '%#WarningMsg#%{&ff != "unix" ? " ".&ff." ":""}%* '
\ . '%#warningmsg#%{&fenc != "utf-8" && &fenc != "" ? " ".&fenc." " :""}%* '
if get(b:, 'stl_highlight')
let id = synID(line('.'), col('.'), 1)
let stl .=
\ '%#WarningMsg#['
\ . '%{synIDattr('.id.',"name")} as '
\ . '%{synIDattr(synIDtrans('.id.'),"name")}'
\ . ']%* '
endif
if get(b:, 'stl_location')
let stl .=
\ '%3*[%*%v%3*,%*%l%3*/%*%L%3*]%* '
\ . '%p%3*%%%* '
endif
return stl
endfunction
" }}}1
" Plugin {{{1
" Plugin: fzf {{{2
set runtimepath+=~/local/fzf
let g:fzf_layout = {'down': '40%'}
nnoremap <leader><leader> :Buffers<cr>
nnoremap <leader>C :Colorschemes<cr>
nnoremap <leader>P :Plugins<cr>
nnoremap <leader>S :Scriptnames<cr>
nnoremap <leader>f :FZF<cr>
function! s:buflist()
return map(filter(range(1, bufnr('$')),
\ 'bufloaded(v:val)'), 'printf("%s: %s", v:val, bufname(v:val))')
endfunction
function! s:bufopen(lines)
if len(a:lines) < 2 | return | endif
let cmd = get({
\ 'ctrl-s': 'split',
\ 'ctrl-v': 'vsplit',
\ 'ctrl-t': 'tabedit'
\ }, a:lines[0], 'edit')
execute cmd '+b'.matchstr(a:lines[1], '^\d\+')
endfunction
function! s:plugopen(entry)
execute 'Dirvish' expand(s:bundle_dir) .'/'. a:entry
execute 'lcd' expand('%')
endfunction
command! Buffers let bl = reverse(s:buflist()) | call fzf#run({
\ 'source': bl,
\ 'sink*': function('<sid>bufopen'),
\ 'options': '+m --expect=ctrl-s,ctrl-v,ctrl-t',
\ 'down': len(bl) + 2,
\ }) | unlet bl
command! Plugins call fzf#run({
\ 'source': reverse(sort(map(globpath(s:bundle_dir, '*', 0, 1), 'fnamemodify(v:val, ":t")'))),
\ 'sink': function('<sid>plugopen'),
\ 'options': '+m',
\ 'left': 30
\ })
command! Colorschemes call fzf#run({
\ 'source': reverse(sort(map(globpath(&rtp, 'colors/*.vim', 0, 1), 'fnamemodify(v:val, ":t:r")'))),
\ 'sink': 'colorscheme',
\ 'options': '+m',
\ 'left': 30
\ })
" Plugin: netrw {{{2
" let g:loaded_netrwPlugin = 1
let g:netrw_banner = 0
let g:netrw_bufsettings = 'relativenumber'
let g:netrw_keepdir = 0
let g:netrw_liststyle = 1
let g:netrw_sort_options = 'i'
" Plugin: surround {{{2
let g:surround_indent = 1
let g:surround_{char2nr('k')} = "<kbd>\r</kbd>"
" Plugin: tagbar {{{2
nnoremap <f2> :TagbarToggle<cr>
let g:tagbar_width = 40
let g:tagbar_autoclose = 0
let g:tagbar_autofocus = 1
let g:tagbar_compact = 1
" Plugin: vim-easy-align {{{2
xmap <cr> <plug>(LiveEasyAlign)
" Plugin: vim-grepper {{{2
nnoremap <leader>g :Grepper<cr>
nmap gs <plug>(GrepperOperator)
xmap gs <plug>(GrepperOperator)
highlight GrepperSideFile ctermfg=161 cterm=reverse
highlight Conceal ctermfg=NONE ctermbg=250
let g:grepper = {}
let g:grepper.dir = 'repo,filecwd'
let g:grepper.tools = ['git', 'rg', 'rubocop']
let g:grepper.rubocop = {
\ 'grepprg': 'rubocop -femacs',
\ 'grepformat': '%f:%l:%c: %t: %m' }
command! Todo Grepper -noprompt -tool rg -query '(TODO|FIX|FIXME|XXX|NOTE|HACK|OPTIMIZE):'
" Plugin: vim-sayonara {{{2
nnoremap <silent><leader>q :Sayonara<cr>
nnoremap <silent><leader>Q :Sayonara!<cr>
let g:sayonara_confirm_quit = 0
" Plugin: vim-startify {{{2
nnoremap <leader>st :Startify<cr>
let g:startify_change_to_dir = 0
" let g:startify_custom_header = 'startify#pad(startify#fortune#boxed())'
let g:startify_enable_special = 0
let g:startify_fortune_use_unicode = 1
let g:startify_update_oldfiles = 1
let g:startify_use_env = 1
" Filetype {{{1
augroup vimrc
" Filetype: Assembly {{{2
let g:asmsyntax = 'nasm'
" vim-commentary uses 'commentstring', not 'comments'
autocmd FileType nasm let &commentstring = '; %s'
" Filetype: C {{{2
autocmd FileType c,cpp setl com=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/
autocmd BufLeave *.{c,cpp} mark C
autocmd BufLeave *.h mark H
" Filetype: cmake {{{2
autocmd FileType cmake setlocal commentstring=#\ %s
" Filetype: crontab {{{2
autocmd FileType crontab setlocal nobackup nowritebackup
" Filetype: Erlang {{{2
autocmd FileType erlang setl com-=:%
" Filetype: Go {{{2
let g:go_bin_path = $v.'/vendor/go'
let g:go_fmt_command = 'goimports'
let g:gofmt_on_save = 0
autocmd FileType go setlocal noet sts& sw& com-=:// isk-=. lcs+=tab:\ \
" Filetype: Help {{{2
autocmd FileType help
\ setl noet
\| execute 'silent wincmd' 'TL'[winnr('$') == 2]
" Filetype: HTML {{{2
autocmd FileType html setl et sts=2 sw=2
" Filetype: Lua {{{2
autocmd FileType lua setl com-=:# sts=2 sw=2
" Filetype: Perl {{{2
let perl_include_pod = 1
autocmd FileType perl
\ setlocal com-=:# kp=perldoc\ -f
\| compiler perl
autocmd BufRead,BufNewFile *.html.ep{,l} set ft=html.epl
" Filetype: Python {{{2
let python_highlight_all = 1
autocmd FileType python
\ setlocal kp=pydoc mp=./%
\| compiler pyunit
" Filetype: Ruby {{{2
let g:ruby_operators = 1
let g:ruby_space_errors = 1
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
let g:rubycomplete_rails = 1
function! s:ruby()
command! -buffer -bang Rubocop exe 'Grepper -tool rubocop -noprompt' ['-buffer',''][<bang>0]
command! -buffer -nargs=* -bang Rspec exe '<mods> T clear; bundle exec rspec <args>' expand('%:p').['', ':'.line('.')][<bang>0]
nnoremap <buffer> <leader>rs :vertical Rspec!<cr>
endfunction
autocmd BufNewFile *.rb call append(0, ['#!/usr/bin/env ruby', ''])
autocmd FileType ruby call s:ruby()
" -> after/ftplugin/ruby.vim
" Filetype: Rust {{{2
if has('nvim')
autocmd BufRead Cargo.toml call crates#toggle()
endif
" Filetype: Sh, Zsh {{{2
au FileType zsh,sh setl com-=:# sts=4 sw=4
\| com! -buffer Lint Grepper -noprompt -buffer -grepprg shellcheck -fgcc
" Filetype: Text, Mail, Markdown {{{2
let g:instant_markdown_autostart = 0
let g:instant_markdown_slow = 1
autocmd FileType mail setl tw=72 wrap lbr
autocmd FileType markdown setl tw=80 mp=gomali\ %
autocmd FileType text setl tw=80 fo+=t
" Filetype: VCS {{{2
autocmd FileType git,gitcommit setl tw=80 fo+=t
" fugitive
autocmd BufReadPost fugitive:// setlocal bufhidden=delete
autocmd FileType fugitiveblame nmap q gq
autocmd User fugitive
\ if get(b:, 'fugitive_type', '') =~# '\v^%(tree|blob)$'
\| nnoremap <buffer> .. :edit %:h<cr>
\| endif
" signify
let g:signify_sign_show_text = 1
let g:signify_sign_add = '▊'
let g:signify_sign_change = '▊'
let g:signify_sign_delete = '▊'
omap ic <plug>(signify-motion-inner-pending)
xmap ic <plug>(signify-motion-inner-visual)
omap ac <plug>(signify-motion-outer-pending)
xmap ac <plug>(signify-motion-outer-visual)
nnoremap <silent><leader>p :SignifyHunkDiff<cr>
nnoremap <silent><leader>u :SignifyHunkUndo<cr>
autocmd User SignifyAutocmds autocmd! signify CursorHold,CursorHoldI
" Filetype: Vim, Vader {{{2
autocmd FileType vim nnoremap <buffer><silent> <bs> :call lookup#pop()<bar>call halo#run()<cr>
autocmd FileType vim setl sts=2 sw=2 isk-=#
" }}}2
augroup END
" }}}1
if filereadable($v.'/magic.vim')
source $v/magic.vim
endif
" vim: sw=2 sts=2 tw=0 fdm=marker