-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvimrc
2894 lines (2624 loc) · 92.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
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
" {{{ Prelude
augroup vimrc
autocmd! vimrc *
set nocompatible
filetype off
if !exists("g:nix_enabled")
let g:nix_enabled = 0
endif
if has("win16") || has("win32") || has("win64")
let g:opsystem = "windows"
else
let g:opsystem = substitute(system('uname'), "\n", "", "")
endif
" To make sure vim works with fish, adjust shell
if $SHELL =~ "/fish$"
set shell="/bin/bash"
endif
" Load all own bundles
" let s:vundle_path = expand('<sfile>:p:h') . '/vundles.vim'
if g:opsystem == "windows"
" No vundle on windows just snapshots of repos under bundle
" We have pathogen for that
runtime bundle/vim-pathogen/autoload/pathogen.vim
execute pathogen#infect()
else
source $HOME/.vim/plugs.vim
endif
call dirsettings#Install("init.vim")
" Have pathogen load the other local/non-git plugins
call pathogen#infect("bundle/{}")
filetype on
" }}}
" {{{ Helper variables
let s:ac_file="/sys/class/power_supply/AC/online"
if filereadable(s:ac_file)
let s:power_online = readfile(s:ac_file)[0]
else
" if there is no battery we are on AC power
let s:power_online = '1'
endif
" }}}
" {{{ Fixes
" {{{ Workaround for neovim not reszing itself, see https://github.com/neovim/neovim/issues/11330
if has("nvim-0.7.2")
lua <<EOF
vim.api.nvim_create_autocmd({"VimEnter"}, {
callback = function()
local pid, WINCH = vim.fn.getpid(), vim.loop.constants.SIGWINCH
vim.defer_fn(function() vim.loop.kill(pid, WINCH) end, 20)
end
})
EOF
endif
" }}}
" }}}
" {{{ Functions
function! EnsureDirExists (dir)
if !isdirectory(a:dir)
if exists("*mkdir")
call mkdir(a:dir,'p')
echo "Created directory: " . a:dir
else
echo "Please create directory: " . a:dir
endif
endif
endfunction
" Run shell command and write output in new buffer
function! s:RunShellCommand(cmdline)
echo a:cmdline
let expanded_cmdline = a:cmdline
for part in split(a:cmdline, ' ')
if part[0] =~ '\v[%#<]'
let expanded_part = fnameescape(expand(part))
let expanded_cmdline = substitute(expanded_cmdline, part, expanded_part, '')
endif
endfor
botright new
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
call setline(1, 'You entered: ' . a:cmdline)
call setline(2, 'Expanded Form: ' .expanded_cmdline)
call setline(3,substitute(getline(2),'.','=','g'))
execute '$read !'. expanded_cmdline
setlocal nomodifiable
endfunction
" Capture output of vim command
function! Command(cmd)
redir => message
silent execute a:cmd
redir END
tabnew
silent put=message
set nomodified
endfunction
function! OpenCustomFT(folder)
if g:opsystem != "windows"
let basefolder = "~/.vim/bundle-own/various-ft-scripts"
else
let basefolder = "$VIM/vimfiles/bundle-own/various-ft-scripts/"
endif
execute "tabe ".basefolder."/".a:folder."/".&ft.".vim"
endfunction
function! CreateTimestamp()
normal! oCreated:
normal! a TIMESTAMP
" call EnhancedCommentify('', 'first')
normal! oLast modified:
" this is a comment to prevent TIMESTAMP from being evaluated
normal! a TIME
normal! aSTAMP
endfunction
" Copy the name of a task in personal time tracking
function! CopyTaskName()
let l:save_cursor = getcurpos()
normal! 0Ely$
call setpos('.', l:save_cursor)
endfunction
" Paste the name of a task in personal time tracking
function! PasteTaskName()
let l:save_cursor = getcurpos()
normal! 0$p
call setpos('.', l:save_cursor)
endfunction
" Replace the name of a task in personal time tracking
function! ReplaceTaskName()
let l:save_cursor = getcurpos()
normal! 0El"_D$p
call setpos('.', l:save_cursor)
normal! zO
endfunction
function InsertTaskName(name)
call append(line('.'), a:name)
normal! J
normal! :s/\t/ /g<CR>
normal! :s/\s\+/ /g<CR>
endfunction
function InsertAsNeorgLink(input)
let l:split=split(a:input, ' ')
let l:title=l:split[0]
let l:title=substitute(l:title, "\{", "\\\\{", "g")
let l:title=substitute(l:title, "\}", "\\\\}", "g")
let l:url=l:split[1]
call append(line('.'), printf('{%s}[%s]', l:url, l:title))
normal! J
endfunction
function InsertTaskDetails(title_details)
let l:split=split(a:title_details, ' ')
let l:title=l:split[0]
let l:details=l:split[1]
call append(line('.'), l:title . ' #STORY ' . l:details)
normal! J
normal! zO
endfunction
function InsertGitIDs(link)
let l:lines_id=systemlist(["rev-git-ids", split(a:link, " ")[1]])
for line in l:lines_id
call append(line('.'), line)
endfor
endfunction
" Jump to next closed fold
function! NextClosedFold(dir)
let cmd = 'norm!z' . a:dir
let view = winsaveview()
let [l0, l, open] = [0, view.lnum, 1]
while l != l0 && open
exe cmd
let [l0, l] = [l, line('.')]
let open = foldclosed(l) < 0
endwhile
if open
call winrestview(view)
endif
endfunction
" Set the color column depending on what filetype is set
function! SetCustomColorColumn()
if get(w:, "currentcolorcolumn") > 0
call matchdelete(w:currentcolorcolumn)
let w:currentcolorcolumn = 0
endif
if exists("g:colorcolumn_custom") && has_key(g:colorcolumn_custom, &ft)
let l:linewidth = g:colorcolumn_custom[&ft]
elseif &textwidth > 0
let l:linewidth = &textwidth
else
let l:linewidth = 80
endif
let w:currentcolorcolumn=matchadd("CustomColorColumn", "\%" . l:linewidth+1 . "v")
endfunction
" Dynamically adjust guifontsize
function! GuifontsizeModify(adjustment)
let l:split = split(&guifont, "h")
let l:fontsize = l:split[-1]
let l:fontname = join(l:split[:-2], "h")
let l:new_font = join([l:fontname, (l:fontsize + a:adjustment)], "h")
let &guifont=l:new_font
endfunction
" Search for the ... arguments separated with whitespace (if no '!'),
" or with non-word characters (if '!' added to command).
function! SearchMultiLine(bang, ...)
if a:0 > 0
let sep = (a:bang) ? '\_W\+' : '\_s\+'
let @/ = join(a:000, sep)
endif
endfunction
if !exists(":RgFromSearch")
" TODO: Push upstream
function! RgFromSearch() "{{{
let search = getreg('/')
" translate vim word boundaries
let search = substitute(search, '\(\\<\|\\>\)', '\\b', 'g')
call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case -- ".shellescape(search), 1, fzf#vim#with_preview(), 0)
endfunction "}}}
endif
" }}}
" {{{ Commands
command! -bang -nargs=* -complete=tag S call SearchMultiLine(<bang>0, <f-args>)|normal! /<C-R>/<CR
command! RgFromSearch call RgFromSearch()
" Enable folding
command! Folds set fdm=syntax
" Shell with output captured
command! -complete=shellcmd -nargs=+ Shell call s:RunShellCommand(<q-args>)
" Command with output captured
command! -nargs=+ -complete=command Command call Command(<q-args>)
command! SOvnorm let g:neosolarized_visibility="normal" | colorscheme NeoSolarized
command! SOvlow let g:neosolarized_visibility="low" | colorscheme NeoSolarized
command! Plugs tabe $HOME/.vim/plugs.vim
command! -nargs=0 MakeTags !ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
" Open vimrc/tex in new tab
if g:opsystem != "windows"
if has('nvim')
command! -nargs=0 Vimrc tabe $HOME/.vimrc
else
command! -nargs=0 Vimrc tabe $MYVIMRC
endif
else
command! -nargs=0 Vimrc tabe $VIM/vimfiles/vimrc
endif
" command! -nargs=0 ReadOldTimeTable read ~/wiki/template_timelog.md
command! -nargs=0 ReadTimeTable read ~/wiki/neorg/template_timelog.norg
command! -nargs=0 ReadJournalTemplate read ~/wiki/neorg/template_journal.norg
command! -nargs=0 FT call OpenCustomFT("ftplugin")
command! -nargs=0 FTA call OpenCustomFT("after")
" Spelling
command! -nargs=0 Spde setlocal spelllang=de
command! -nargs=0 Thde setlocal thesaurus=
\ /usr/share/mythes/th_de_DE.v2.dat
command! -nargs=0 Spen setlocal spelllang=en
command! -nargs=0 Then setlocal thesaurus=
\ /usr/share/mythes/th_en_US.v2.dat
" Compute how often each item appears in time log
" command! TimeStats exec '0/^\(\*\|#\) Time log$/+2,$w !grep "^[0-9]\{2\}:[0-9]\{2\}" | sed -e "s/[0-9][0-9]:[0-9][0-9] \?//g" -e "/^$/d" -e "/^\s*\*/d" -e "s:\s*\#STORY.*$::g" | sort | uniq -c | gawk -f ~/.vim/utils/transform_time.awk'
" command! TimeStats :!bash -c "revcli progress timelog --show --file % | grep -v '^▶'"
command! TimeStats :!revcli progress timelog --show --file %
command! TS TimeStats
" Lazy bunch
command! -nargs=0 SA setf apache
" :Man command
if g:opsystem == "Linux"
source $VIMRUNTIME/ftplugin/man.vim
end
command! -nargs=0 GoLines % !golines %
" }}}
" {{{ General Mappings
" Plugin specific mappings are found in Plugins-section
" let mapleader=";"
let mapleader=" "
let maplocalleader=";"
" {{{ prefixes
nmap <leader>d [dbg]
nnoremap [dbg] <nop>
nmap <leader>u [unite]
nnoremap [unite] <Nop>
nmap <leader>g [coc]
nnoremap [coc] <Nop>
nmap <leader>a [ale]
nnoremap [ale] <Nop>
nmap <leader>s [usnips]
nnoremap [usnips] <Nop>
nmap <leader><leader> [hop]
nnoremap [hop] <Nop>
" }}}
" noremap <Esc><Esc> <Esc>
map <f8> :setlocal spell!<CR>
" have Q reformat the current paragraph (or selected text if there is any):
nnoremap Q gqap
vnoremap Q gq
if has('nvim-0.10')
lua <<EOF
vim.keymap.set('n', '<leader>th', function() vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end)
vim.lsp.inlay_hint.enable(true)
EOF
endif
" Use <c-s> as prefix for <S>et-font related commands
" TODO: Use hydra for this
nnoremap <silent> <c-s><c-=> :call GuifontsizeModify(1)<cr>
nnoremap <silent> <c-s><c--> :call GuifontsizeModify(-1)<cr>
" reset windows (Great Reset)
nnoremap <silent> gr :resize 200<CR><c-w>=
" Make bulletin
nnoremap <silent> <leader>bt :keeppattern s:^\s*\zs:* :<CR>
" Make todo
nnoremap <silent> <leader>td :keeppattern s:^\s*\zs:* [ ] :<CR>
" Make Y work like C and D..
" changed for yankring
map Y y$
imap <silent> <C-D><C-E> <C-R>=strftime("%d.%m.%Y %H:%M:%S")<CR>
imap <silent> <C-D><C-D> <C-R> --obreitwi, <C-R>=strftime("%d-%m-%y %H:%M:%S")<CR>
imap <silent> <C-D><C-F> <C-R>=strftime("%Y-%m-%d %H:%M:%S")<CR>
imap <silent> <C-D><C-R> <C-R>=strftime("%Y/%m/%d")<CR>
imap <silent> <C-D><C-W> <C-R>=strftime("%Y-%m-%d")<CR>
nnoremap <silent> <c-u> :nohl<CR>
inoremap <silent> <c-u> <c-o>:nohl<CR>
" center after these jumps
" <c-q> is more comfortable to reach on regular keyboards
nnoremap <c-q> <c-u>zz
inoremap <c-q> <c-u>zz
xnoremap <c-q> <c-u>zz
" <c-f> is easier to reach on model 100
nnoremap <c-f> <c-u>zz
inoremap <c-f> <c-u>zz
xnoremap <c-f> <c-u>zz
nnoremap <c-d> <c-d>zz
xnoremap <c-d> <c-d>zz
inoremap <c-d> <c-d>zz
nnoremap n nzz
nnoremap N Nzz
noremap M J
noremap J M
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
if v:version >= 703
" Toggle relative numbers
nnoremap <leader>ss :set rnu!<CR>
endif
" copy current filename to clipboard
nnoremap <leader>cp :let @" = expand("%")<CR>
" copy full current filename to clipboard
nnoremap <leader>cP :let @" = expand("%:p")<CR>
" Toggle character listing (col in unimpaired)w
" nmap <Leader>ll :set list!<CR>
" Lazy movement, for the few times it actually is faster than easymotion
nmap J 8j
vmap J 8j
nmap K 8k
vmap K 8k
" Disable annoying insert-mode bindings
imap <c-w> <nop>
imap <c-h> <nop>
map L <nop>
" Jump to next closed fold
nnoremap <silent> <leader>zj :call NextClosedFold('j')<cr>
nnoremap <silent> <leader>zk :call NextClosedFold('k')<cr>
" Use <leader>y/<leader>p to yank/paste to/from system clipboard
vnoremap <silent> <leader>y "+y
vnoremap <silent> <leader>p "+p
nnoremap <silent> <leader>y "+y
nnoremap <silent> <leader>p "+p
" Use <leader>Y to copy with surrounding backticks for quick markdown pasting
vnoremap <silent> <leader>Y "+y<CR>:let @+ = "```\n" . @+ . "```"<CR>
" select put text, via http://stackoverflow.com/a/4775281/955926
nnoremap <expr> gV "`[".getregtype(v:register)[0]."`]"
nnoremap <c-e><c-h> :tabp<CR>
nnoremap <c-e><c-l> :tabn<CR>
" decode quoted printable
nnoremap <Leader>Q :%s/=\(\x\x\<BAR>\n\)/\=submatch(1)=='\n'?'':nr2char('0x'.submatch(1))/ge<CR>
vnoremap <Leader>Q :s/=\(\x\x\<BAR>\n\)/\=submatch(1)=='\n'?'':nr2char('0x'.submatch(1))/ge<CR>
" TODO: The following mapping deletes the whole buffer
" -> figure out which text-object is called here, for now: disable
nmap cie <NOp>
" }}}
" {{{ Filetype Mappings
autocmd vimrc FileType markdown,norg nmap <silent> <localleader>y :call CopyTaskName()<CR>
autocmd vimrc FileType markdown,norg nmap <silent> <localleader>p :call PasteTaskName()<CR>
autocmd vimrc FileType markdown,norg nmap <silent> <localleader>r :call ReplaceTaskName()<CR>0
autocmd vimrc FileType markdown,norg nmap <silent> <localleader>s :call fzf#run(fzf#wrap({'source': 'revcli stories --list --title', 'sink': function("InsertAsNeorgLink"), 'options': '-d " " --with-nth 1'}))<CR>
autocmd vimrc FileType markdown,norg nmap <silent> <localleader>t :call fzf#run(fzf#wrap({'source': 'revcli tasks --list --timesheet', 'sink': function("InsertTaskName"), 'options': '-d " " --with-nth 1'}))<CR>
autocmd vimrc FileType markdown,norg nmap <silent> <localleader>T :call fzf#run(fzf#wrap({'source': 'revcli tasks --other --list --timesheet', 'sink': function("InsertTaskName"), 'options': '-d " " --with-nth 1'}))<CR>
autocmd vimrc FileType norg nmap <silent> ]d :e =system(["neorg-existing-day", expand("%:t:r"), "+1"])<CR><CR>
autocmd vimrc FileType norg nmap <silent> [d :e =system(["neorg-existing-day", expand("%:t:r"), "-1"])<CR><CR>
autocmd vimrc FileType dart nmap <silent> <leader>gc :call jobstart([expand("~/.vim/utils/flutter-pub-get-recursive"), expand("%")])<CR>
autocmd vimrc BufRead *.dart call jobstart([expand("~/.vim/utils/flutter-pub-get-ensure-recursive"), expand("%")])
autocmd vimrc BufNewFile,BufRead *.yaml.tpl set filetype=yaml
autocmd vimrc FileType gitcommit nmap <silent> <localleader>c :call fzf#run(fzf#wrap({'source': 'revcli stories --list --title', 'sink': function("InsertGitIDs"), 'options': '-d " " --with-nth 1'}))<CR>
if !g:lsp_enabled
autocmd vimrc FileType terraform nmap <silent> <leader>cf :!terraform fmt %<CR>
endif
" }}}
" {{{ Settings
set nocompatible
set encoding=utf-8
" Adjust number of recent files to 1000
set shada=!,'1000,<50,s10,h
set foldlevelstart=99
set splitright
"
set hidden
set nowrap
" Wrap at word
set linebreak
set showbreak=↳\
set list
set virtualedit=all
" do not update screen while executing macros
set lazyredraw
" ttyfast: are we using a fast terminal? Let's try it for a while.
set ttyfast
set cul
" set timeoutlen=250
set timeoutlen=500
set scrolloff=4
if v:version >= 703 && !has('nvim')
set cm=blowfish2
endif
" relative line numbers
set relativenumber
set number
" assume the /g flag on :s substitutions to replace all matches in a line:
set gdefault
set sessionoptions=blank,curdir,tabpages,folds,resize
"make backspace work
set backspace=indent,eol,start
set smarttab
set number
set noautoindent
set smartindent
set incsearch
set hlsearch
set ignorecase
" case only matters if search contains Upper case letters
set smartcase
set pastetoggle=<leader>tp " read as: toggle paste
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set shiftround
set completeopt=menu,menuone,preview,noinsert,noselect
set wildmenu
set wildmode=list,full
" IMPORTANT: win32 users will need to have 'shellslash' set so that latex
" can be called correctly.
set shellslash
" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse Latex-Suite. Set your grep
" program to always generate a file-name.
set grepprg=grep\ -nH\ $*
" read files in automatically
set autoread
" Options for diff mode
set diffopt=filler,vertical,context:10,internal,indent-heuristic
" disable diff mode on close
set diffopt+=closeoff
" improve linematching
set diffopt+=linematch:100
" No menu if we don't need it
if has("gui_running") || exists('g:neovide')
" No Pop Ups but console
set guioptions=ck
set termguicolors
end
" Taken form: https://github.com/gregstallings/vimfiles/blob/master/vimrc
" Delete comment character when joining commented lines
set formatoptions+=c
" set current comment leader when using o/O
set formatoptions+=o
" format comments using gq
set formatoptions+=q
" Format
set formatoptions+=n
set formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s*\\\|^\\s*\\*\\s\\?
if v:version > 703 || v:version == 703 && has("patch541")
" Remove comment leader when joining commented lines
set formatoptions+=j
endif
" Use only 1 space after "." when joining lines instead of 2
set nojoinspaces
" {{{ Backup/undo settings
if g:opsystem != "windows"
" keep .vim repository free from temporary files
call EnsureDirExists( $HOME . '/.vimbackup' )
call EnsureDirExists( $HOME . '/.vimbackup/writebackup' )
set directory=~/.vimbackup//
set backupdir=~/.vimbackup/writebackup//
endif
set backup
" persistent undo
if g:opsystem != "windows"
" keep .vim repository free from temporary files
if has("nvim-0.5.0")
call EnsureDirExists( $HOME . '/.local/share/nvim/undo' )
set undodir=~/.local/share/nvim/undo//
else
call EnsureDirExists( $HOME . '/.vimundo' )
set undodir=~/.vimundo//
endif
set undofile
endif
" }}}
" {{{ List Chars (Make sure they work on all platforms)
set listchars=tab:>\ ,trail:\ ,extends:>,precedes:<,nbsp:+
if (g:opsystem != "windows") && (&termencoding ==# 'utf-8' || &encoding ==# 'utf-8')
" NOTE: These two lines are NOT the same characters!
" let &listchars = "tab:\u21e5 ,trail:\u2423,extends:\u21c9,precedes:\u21c7,nbsp:\u00b7"
" set listchars=tab:▸·,extends:⇉,precedes:⇇,nbsp:·,eol:¬,trail:␣
set listchars=tab:▸·,extends:⇉,precedes:⇇,nbsp:·,eol:↵,trail:␣
endif
" }}}
" }}}
" {{{ Filetype Settings
" {{{ Common
filetype plugin on
filetype indent on
autocmd vimrc BufNewFile,BufRead wscript* set filetype=python
autocmd vimrc filetype tex hi MatchParen ctermbg=black guibg=black
" }}}
" Reload vimrc after writing (does not work as well as it used to)
" autocmd! vimrc BufWritePost .vimrc source $MYVIMRC
" autocmd! vimrc BufWritePost vundles.vim source $MYVIMRC
" autocmd vimrc FileType python setlocal omnifunc=pythoncomplete#Complete
" {{{ spell checking in comments only
if has('nvim-0.8')
autocmd vimrc FileType go setlocal spelloptions+=noplainbuffer
endif
" }}}
" {{{ Tab-Settings
autocmd vimrc FileType arduino setlocal tabstop=4 | setlocal shiftwidth=4 | setlocal softtabstop=4
autocmd vimrc FileType bash setlocal tabstop=4 | setlocal shiftwidth=4 | setlocal softtabstop=4
autocmd vimrc FileType c setlocal tabstop=4 | setlocal shiftwidth=4 | setlocal softtabstop=4
autocmd vimrc FileType cpp setlocal tabstop=4 | setlocal shiftwidth=4 | setlocal softtabstop=4
autocmd vimrc FileType dart setlocal tabstop=2 | setlocal shiftwidth=2 | setlocal softtabstop=2
autocmd vimrc FileType exim setlocal tabstop=4 | setlocal shiftwidth=4 | setlocal softtabstop=4 | setlocal expandtab
autocmd vimrc FileType gitcommit setlocal tabstop=2 | setlocal softtabstop=2 | setlocal shiftwidth=2 | setlocal expandtab
autocmd vimrc FileType go setlocal tabstop=4 | setlocal softtabstop=4 | setlocal shiftwidth=4 | setlocal noexpandtab
autocmd vimrc FileType haskell setlocal tabstop=2 | setlocal shiftwidth=2 | setlocal expandtab
autocmd vimrc FileType html setlocal tabstop=4 | setlocal shiftwidth=4 | setlocal softtabstop=4
autocmd vimrc FileType java setlocal tabstop=4 | setlocal shiftwidth=4 | setlocal softtabstop=4
autocmd vimrc FileType javascript setlocal tabstop=4 | setlocal shiftwidth=4 | setlocal expandtab
autocmd vimrc FileType javascript setlocal tabstop=4 | setlocal shiftwidth=4 | setlocal softtabstop=4
autocmd vimrc FileType jinja setlocal tabstop=2 | setlocal shiftwidth=2 | setlocal softtabstop=2 | setlocal expandtab
autocmd vimrc FileType json setlocal tabstop=4 | setlocal shiftwidth=4 | setlocal expandtab
autocmd vimrc FileType lua setlocal tabstop=2 | setlocal shiftwidth=2 | setlocal expandtab
autocmd vimrc FileType mail setlocal textwidth=72 | setlocal wrapmargin=8 | setlocal spell
autocmd vimrc FileType markdown setlocal tabstop=2 | setlocal shiftwidth=2 | setlocal softtabstop=2 | setlocal expandtab
autocmd vimrc FileType matlab setlocal tabstop=4 | setlocal shiftwidth=4 | setlocal expandtab
autocmd vimrc FileType norg setlocal tabstop=2 | setlocal shiftwidth=2 | setlocal expandtab | setlocal fo=tqnj
autocmd vimrc FileType proto setlocal tabstop=2 | setlocal shiftwidth=2 | setlocal softtabstop=2
autocmd vimrc FileType python setlocal tabstop=4 | setlocal shiftwidth=4 | setlocal expandtab
autocmd vimrc FileType sh setlocal tabstop=4 | setlocal softtabstop=4 | setlocal shiftwidth=4 | setlocal expandtab
autocmd vimrc FileType text setlocal tabstop=2 | setlocal shiftwidth=2 | setlocal expandtab | setlocal comments=fb:*,fb:#
autocmd vimrc FileType vim setlocal tabstop=2 | setlocal shiftwidth=2 | setlocal expandtab
autocmd vimrc FileType vimwiki setlocal tabstop=2 | setlocal shiftwidth=2 | setlocal expandtab | setlocal foldlevel=0 | setlocal comments=fb:*,fb:# | setlocal foldminlines=0
autocmd vimrc FileType yaml setlocal tabstop=2 | setlocal shiftwidth=2 | setlocal expandtab
autocmd vimrc FileType zsh setlocal expandtab | setlocal tabstop=4 | setlocal shiftwidth=4
" }}}
" {{{ cpp
autocmd vimrc FileType cpp setlocal cinoptions=g0,hs,N-s,+0
" }}}
" {{{ Latex
" NOTE: If editing other tex-flavors, set locally..
let g:tex_flavor = "latex"
" "}}}
" {{{ Autohotkey
autocmd vimrc BufNewFile,BufRead *.ahk setf autohotkey
autocmd vimrc BufNewFile,BufRead *.txt setf text
" }}}
" {{{ Apache config files
autocmd vimrc BufNewFile,BufRead /etc/apache2/* setf apache
" }}}
" {{{ Jenkinfiles
autocmd vimrc BufNewFile,BufRead Jenkinsfile setf groovy
autocmd vimrc BufNewFile,BufRead *.Jenkinsfile setf groovy
autocmd vimrc BufNewFile,BufRead Jenkinsfile.* setf groovy
" }}}
" {{{ SLI
autocmd vimrc BufNewFile,BufRead *.sli setf sli
" }}}
" {{{ Haskell
" autocmd vimrc BufEnter *.hs compiler ghc
" }}}
" {{{ mutt
" au BufRead,BufNewFile /tmp/mutt-* set filetype=mail | nohl | set bg=dark | colo solarized | setlocal omnifunc=QueryCommandComplete
au vimrc BufRead,BufNewFile /tmp/*mutt-* set filetype=mail | nohl | setlocal omnifunc=QueryCommandComplete
let g:qcc_query_command="nottoomuch-addresses-reformatted"
" }}}
" {{{ rust
" Workaround for second line getting replaced by crate name on safe: Disable folding via expr
" NOTE: setlocal does _not_ work.
" au vimrc FileType rust set foldmethod=manual | set foldexpr=0
" }}}
" }}}
" {{{ Font config
" Font settings
if g:opsystem == "windows"
command! FIncon set guifont=Inconsolata\ Medium\ 8
command! FInconP set guifont=Inconsolata\ for\ Powerline\ Medium\ 8
command! FDejaP set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 6
command! FInconL set guifont=Inconsolata\ Medium\ 10
command! FInconPL set guifont=Inconsolata\ for\ Powerline\ Medium\ 10
command! FDejaPL set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 10
command! FEnvy set guifont=Envy\ Code\ R\ 8
else
" These settings were found experimentally
command! FIncon set guifont=Inconsolata\ Medium:h12
command! FInconP set guifont=Inconsolata\ Nerd\ Font\ Mono\ Medium:h12
command! FDejaP set guifont=DejaVuSansM\ Nerd\ Font:w57:h9
command! FInconL set guifont=Inconsolata\ Medium:h16
command! FDejaPS set guifont=DejaVuSansM\ Nerd\ Font:w57:h8
command! FInconPL set guifont=Inconsolata\ Nerd\ Font\ M\ Medium:h14
command! FDejaPL set guifont=DejaVuSansM\ Nerd\ Font:w57:h14
command! FDejaPVL set guifont=DejaVuSansM\ Nerd\ Font:w57:h16
command! FEnvy set guifont=Envy\ Code\ R:h11
endif
command! FMeslo set guifont=MesloLGS\ NF:h9
command! FMesloS set guifont=MesloLGS\ NF:h8
command! FMesloXS set guifont=MesloLGS\ NF:h6
command! FIosevka set guifont=IosevkaTerm\ NF:h10
command! FIosevkaS set guifont=IosevkaTerm\ NF:h9
command! FIosevkaXS set guifont=IosevkaTerm\ NF:h6
" Default font
if g:opsystem == "windows"
set guifont=Consolas:h10:cANSI
elseif exists('g:started_by_firenvim')
" FIosevkaS
FMesloS
elseif exists("g:neovide")
FMeslo
else
FMeslo
" FIosevka
end
if has('gui_running') && g:opsystem != "windows" && !exists("g:neovide")
set clipboard=unnamedplus
endif
" }}}
" {{{ Clipboard settings
let s:hosts_clipboard_enabled = ["abed"]
if index(s:hosts_clipboard_enabled, hostname()) < 0 && !has('nvim')
" disable clipboard if host not in list
set clipboard=exclude:.*
end
" }}}
" {{{ Color management
let g:gitgutter_override_sign_column_highlight=1
" Put a linewidth indicator on a custom colum instead of the default 80
let g:colorcolumn_custom = {
\ 'python': 88
\}
" {{{ gruvbox settings
" {{{ gruvbox.nvim
if has('nvim')
lua <<EOF
-- Default options:
require("gruvbox").setup({
terminal_colors = true, -- add neovim terminal colors
undercurl = true,
underline = true,
bold = true,
italic = {
strings = false,
emphasis = true,
comments = true,
operators = false,
folds = true,
},
strikethrough = true,
invert_selection = false,
invert_signs = false,
invert_tabline = false,
invert_intend_guides = false,
inverse = true, -- invert background for search, diffs, statuslines and errors
contrast = "hard", -- can be "hard", "soft" or empty string
palette_overrides = {},
overrides = {},
dim_inactive = false,
transparent_mode = false,
})
vim.cmd("colorscheme gruvbox")
EOF
endif
" }}}
" These need to come prior to setting the colorscheme
if exists("g:neovide")
let g:gruvbox_italic=1
let g:gruvbox_undercurl=1
let g:gruvbox_underline=1
let g:gruvbox_inverse=1
endif
let g:gruvbox_contrast_dark='hard'
let g:gruvbox_guisp_fallback='bg'
" }}}
" {{{ Common / GUI-Term settings
" syntax enable " Disable to help with treesitter
if ($BG == "dark") || ($BG == "light")
execute 'set background=' . $BG
else
set background=dark
endif
if exists("g:neovide") || has("gui_running") || exists('g:started_by_firenvim')
" colorscheme NeoSolarized
" let g:airline_theme = 'solarized'
" let g:neosolarized_contrast="normal"
" let g:neosolarized_visibility="low"
" let g:neosolarized_diffmode="high"
" " let g:neosolarized_termtrans=0
" " let g:neosolarized_bold=1
" " let g:neosolarized_underline=1
" " let g:neosolarized_italic=1
" " let g:neosolarized_termcolors=16
" " let g:neosolarized_hitrail=0
" " let g:neosolarized_menu=1
colorscheme gruvbox
let g:airline_theme = 'gruvbox'
" let g:airline_theme = 'base16_gruvbox_dark_hard'
elseif $TERM == "linux" && !exists('g:neovide')
colorscheme default
" set nolist
else
" " let g:neosolarized_termcolors=256
" " let g:neosolarized_contrast="normal"
" " let g:neosolarized_visibility="low"
" " let g:neosolarized_diffmode="high"
" " let g:neosolarized_termtrans=1
" let g:neosolarized_termcolors=256
" " let g:neosolarized_degrade=1
" " colorscheme NeoSolarized
" colorscheme tigrana-256-dark
" let g:airline_theme = 'powerlineish'
" colorscheme xoria256
colorscheme gruvbox
let g:airline_theme = 'gruvbox'
" let g:airline_theme = 'base16_gruvbox_dark_hard'
endif
if $COLORTERM == "truecolor" && has('nvim')
" Set 24-bit colors if terminal supports it
set termguicolors
endif
" }}}
" This is a test of a line that will exceed 81 characters per line and should trigger the new setting
" Highlight when a line exceeds 81 characters
" highlight CustomColorColumn ctermbg=magenta ctermfg=black
" autocmd Syntax * call SetCustomColorColumn()
" autocmd vimrc BufWinEnter * call SetCustomColorColumn()
" trailing whitespace (disable due to issues with completions)
" highlight default link ExtraWhitespace Error
" autocmd vimrc Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/
" }}}
" {{{ Digraphs
digraph el 8230 " …
digraph li 8212 " —
digraph al 8592 " ←
digraph au 8593 " ↑
digraph ar 8594 " →
digraph ad 8595 " ↓
digraph Al 8656 " ⇐
digraph Au 8657 " ⇑
digraph Ar 8658 " ⇒
digraph Ad 8659 " ⇓
digraph tm 8482 " ™
digraph pm 177 " ±
digraph cm 10003 " ✓
digraph tu 128077 " :thumbsup:
digraph td 128078 " :thumbdsdown:
" }}}
" {{{ neovide
if exists("g:neovide")
" config options for neovide
let g:neovide_cursor_vfx_mode = "railgun"
" let g:neovide_cursor_animation_length=0.13
let g:neovide_cursor_animation_length=0.08
let g:neovide_cursor_trail_length=0.8
let g:neovide_cursor_antialiasing=v:true
endif
" }}}
" {{{ Other
" Call par if availible
if executable("par") && system( "par help | wc -l" ) == 22
" Width of 78, justified lines
" set formatprg=PARPROTECT\=_x09\ par\ -w80qrg
" set formatprg=par\ -w80qrg
autocmd FileType mail set formatprg=par\ -w72qrg
" PARPROTECT prevents tabs from being converted!
command! -nargs=0 Parwide setlocal formatprg=par\ -w100
" autocmd FileType markdown setlocal formatprg=PARQUOTE\=_x09\ par\ -w80T4
endif
" Taken from tpope sensible
" Load matchit.vim, but only if the user hasn't installed a newer version.
if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
runtime! macros/matchit.vim
endif
" }}}
" {{{ Statusline
" {{{ lualine
if !g:airline_enabled
lua <<EOF
require('lualine').setup({
options = { theme = 'gruvbox' },
extensions = { "toggleterm" },
sections = {
lualine_c = {
{ 'filename', path = 1, file_status = true }
},
},
})
EOF
endif
" }}}
" Powerline
" disable on all machines unless specifically enabled
if has('nvim-0.7')
set laststatus=3
else
set laststatus=2
endif
set noshowmode
let g:powerline_available=1
if has('nvim') || (!has("python") && !has("python3"))
let g:powerline_available=0
else
if has("pythonx")
source $HOME/.vim/compatibility/enable_powerline.pythonx.vim
elseif has("python3")
source $HOME/.vim/compatibility/enable_powerline.python3.vim
elseif has("python")
source $HOME/.vim/compatibility/enable_powerline.python.vim
endif
endif
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#show_buffers = 0
if 0 && !g:powerline_available
let g:powerline_loaded=1
set showmode
" Git branch
" set statusline=%{GitBranch()}
" Custom status line
set statusline= " clear the statusline for when vimrc is reloaded
set statusline+=%f\ " file name
set statusline+=[%{strlen(&ft)?&ft:'none'}, " filetype
set statusline+=%{strlen(&fenc)?&fenc:&enc}, " encoding
set statusline+=%{&fileformat}] " file format
set statusline+=%{fugitive#statusline()}
set statusline+=%h%m%r%w " flags
set statusline+=%#warningmsg#
if match(&runtimepath, 'syntastic') != -1
set statusline+=%{SyntasticStatuslineFlag()}
endif
set statusline+=%*
set statusline+=%= " left/right separator
" set statusline+=%{synIDattr(synID(line('.'),col('.'),1),'name')}\ " highlight
set statusline+=%b,0x%-6B " current char
set statusline+=%c,%l/ " cursor column/total lines
set statusline+=%L\ %P " total lines/percentage in file
endif
" }}}
" {{{ Plugins
" {{{ ALE
if s:power_online == '0'
" disable power consuming features of ale when not running on AC power
let g:ale_lint_on_text_changed = "never"
endif
let g:ale_echo_msg_format = '%linter%% (code)%: %s'
let g:ale_linters = {
\ "c": [],
\ "cpp": [],