Repository navigation
Expand file tree
/
Copy pathvimrc
More file actions
622 lines (464 loc) · 14.9 KB
/
Copy pathvimrc
File metadata and controls
622 lines (464 loc) · 14.9 KB
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
set encoding=utf-8
scriptencoding utf-8
" FOLDERS
if has('unix')
let s:cache_dir = expand('~/.cache/vim/')
else
let s:cache_dir = expand('~/_cache/vim/')
endif
let s:backup_dir = s:cache_dir . 'backup/'
let s:swap_dir = s:cache_dir . 'swap/'
let s:undo_dir = s:cache_dir . 'undo/'
let g:classpath_cache = s:cache_dir . 'classpath/'
let s:plugin_dir = s:cache_dir . 'plugged/'
let g:netrw_home = s:cache_dir
silent! call mkdir(s:backup_dir, 'p')
silent! call mkdir(s:swap_dir, 'p')
silent! call mkdir(s:undo_dir, 'p')
let &backupdir = fnameescape(s:backup_dir) . '/'
let &directory = fnameescape(s:swap_dir) . '/'
let &undodir = fnameescape(s:undo_dir) . '/'
if empty(get(g:, 'vimfiles_dir', ''))
if has('win32')
let g:vimfiles_dir = expand('~/vimfiles/')
elseif has('unix')
let g:vimfiles_dir = expand('~/.vim/')
endif
endif
" PACKAGE MANAGEMENT
let s:has_pluginmgr = 0
if filereadable(g:vimfiles_dir . 'autoload/plug.vim')
let s:has_pluginmgr = 1
elseif confirm('Plugin manager not found. Install it?', "&yes\n&no") == 1
" ^^^ FIXME this confirm() isn't working on windows...
" XXX Make Vim-plug auto-installation less platform-specific.
let s:msg = system('curl -fLo ' . fnameescape(g:vimfiles_dir . 'autoload/plug.vim') . ' --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim')
if v:shell_error == 0
echomsg 'Plugin manager was installed successfully'
let s:has_pluginmgr = 1
else
echoerr 'Plugin manager could not be installed:'
echoerr s:msg
endif
endif
if s:has_pluginmgr == 1
call plug#begin(s:plugin_dir)
" 256 colours
Plug 'nanotech/jellybeans.vim'
" gui colours
Plug 'romainl/flattened'
Plug 'yasukotelin/shirotelin'
Plug 'molok/vim-vombato-colorscheme'
Plug 'morhetz/gruvbox'
Plug 'vim-scripts/Align'
Plug 'tpope/vim-commentary'
if has('win32')
Plug 'ctrlpvim/ctrlp.vim'
else
Plug 'junegunn/fzf'
" " fzf plugin breaks if you're not a rolling-release meme
" Plug 'junegunn/fzf.vim', { 'commit': '23dda8602f138a9d75dd03803a79733ee783e356' }
Plug 'junegunn/fzf.vim'
endif
Plug 'mattn/emmet-vim'
Plug 'tpope/vim-surround'
" | Plug 'tpope/vim-repeat'
" | Plug 'guns/vim-sexp'
" | Plug 'tpope/vim-sexp-mappings-for-regular-people'
Plug 'tomtom/tlib_vim'
\ | Plug 'marcweber/vim-addon-mw-utils'
\ | Plug 'garbas/vim-snipmate'
" TODO: check if vim's built-in plugins are enough
" * program in <language>.
" * see if there's something missing in <language>.
" * see if I can quickly hack my way around it.
" * if so, delete plugin
" * if not, reenable plugin
Plug 'prabirshrestha/vim-lsp'
" Plug 'tpope/vim-fireplace'
Plug 'tpope/vim-fugitive'
" Plug 'https://git.sr.ht/~sircmpwn/hare.vim'
Plug 'tikhomirov/vim-glsl'
" Plug 'fatih/vim-go'
" Plug 'quabug/vim-gdscript'
" Plug 'juliaeditorsupport/julia-vim'
Plug 'sophacles/vim-bundle-mako'
Plug 'jceb/vim-orgmode'
Plug 'tetralux/odin.vim'
Plug 'peterhoeg/vim-qml'
Plug 'rust-lang/rust.vim'
" Plug 'lervag/vimtex'
call plug#end()
endif
" EDITING
if !exists('g:loaded_vimrc')
set tabstop=8
set softtabstop=4
set shiftwidth=4
set expandtab
set textwidth=80
set nowrap
" For some reason filetype plugins love to override 'formatoptions',
" so I have to apply brute force here... (-_-)"
augroup ForceFormatOptions
autocmd!
autocmd BufEnter * set formatoptions=rqnl1
augroup END
set nofoldenable
endif
set undofile
set complete+=kspell
set spellcapcheck=
set cpoptions+=J
set ignorecase
set smartcase
set incsearch
set hlsearch
if exists('&inccommand')
set inccommand=nosplit
endif
set showcmd
set mouse=a
set splitright
set splitbelow
set virtualedit=all
set backspace=indent,eol,start
set hidden
" TODO: move the command defs to the place where commands are defed
command! Deutsch setlocal spell spelllang=de_de
command! British setlocal spell spelllang=en_gb
augroup CursorToLastKnownPosition
autocmd!
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exec "normal! g'\"zvzz" |
\ endif
augroup END
" KEY BINDINGS
nnoremap <C-g> <Esc>
vnoremap <C-g> <Esc>gV
onoremap <C-g> <Esc>
inoremap <C-g> <Esc>
cnoremap <C-g> <C-c>
" Normal/Visual Mode Bindings
nnoremap j gj
nnoremap k gk
nnoremap gK :<c-u>exec '!apropos ' . expand('<cword>')<cr>
noremap H ^
noremap L $
noremap ä }
noremap Ä <C-d>
noremap ü {
noremap Ü <C-u>
nnoremap ö <C-w>
nnoremap öö <C-w><C-w>
nnoremap öä :<c-u>cclose|lclose<cr>
"nnoremap öÄ :<c-u>lclose<cr>
nnoremap <c-w>ä :<c-u>cclose|lclose<cr>
noremap n nzzzv
noremap N Nzzzv
nnoremap Q @
nnoremap QQ @@
noremap Y y$
noremap , :
noremap / /\v
noremap ? ?\v
noremap ' #
noremap # `
noremap ´ Q
nnoremap <silent> - :<C-u>MoveLineUp v:count1<cr>
nnoremap <silent> + :<C-u>MoveLineDown v:count1<cr>
nnoremap <silent> * :<c-u>let b:saved_view = winsaveview()<cr>*:call winrestview(b:saved_view)<cr>
vnoremap <silent> * :<c-u>let b:saved_view = winsaveview()<cr>*:call winrestview(b:saved_view)<cr>gv
" Insert Mode Bindings
noremap! <silent> <c-k> <c-r>=DigraphMenu()<cr>
inoremap <c-x><c-t> <c-x><c-]>
inoremap <c-z> <c-x><c-o>
inoremap <c-t> <c-x><c-]>
" Leader Key Bindings
nnoremap <space><space> :<c-u>buffer #<cr>
nnoremap <space>a :<c-u>Ag '
if executable('rg')
" `rg --vimgrep` does not support \V\C...
nnoremap <space>ga :<c-u>Ag '\b' . escape(expand('<cword>'), '\/') . '\b'<cr>
elseif executable('ag')
" `ag --vimgrep` does not support \<...\>
nnoremap <space>ga :<c-u>Ag '\V\C\b' . escape(expand('<cword>'), '\/') . '\b'<cr>
else
nnoremap <space>ga :<c-u>Ag '\V\C\<' . escape(expand('<cword>'), '\/') . '\>'<cr>
endif
if has('win32')
nnoremap <space>b :<c-u>CtrlPBuffer<cr>
else
nnoremap <space>b :<c-u>Buffers<cr>
endif
nnoremap <space>B :<c-u>ToggleBackground<cr>
nnoremap <space>c "+
vnoremap <space>c "+
nnoremap <space>d :<c-u>cd %:h<cr>
nnoremap <space>ec :<c-u>edit ~/.when/calendar<cr>
nnoremap <space>ed :<c-u>Vexec 'edit ++enc=cp437'<cr>
nnoremap <space>ej :<c-u>Vexec 'edit ++enc=sjis'<cr>
nnoremap <space>ee :<c-u>Vexec 'edit'<cr>
nnoremap <space>ef :<c-u>exec 'edit ' . fnameescape(g:vimfiles_dir . 'ftplugin/' . &filetype . '.vim')<cr>
nnoremap <space>eh :<c-u>edit <c-r>=expand('%:p:h')<cr>/
nnoremap <space>es :<c-u>exec 'edit ' . fnameescape(g:vimfiles_dir . 'snippets/' . &filetype . '.snippets')<cr>
nnoremap <space>ev :<c-u>edit $MYVIMRC<cr>
if has('win32')
nnoremap <space>f :<c-u>CtrlP<cr>
else
nnoremap <space>f :<c-u>Files<cr>
endif
nnoremap <space>gg :<c-u>Git<cr>
nnoremap <space>gs :<c-u>Git<cr>
nnoremap <space>gw :<c-u>Gw<cr>
nnoremap <space>gc :<c-u>Git commit<cr>
nnoremap <space>h :<c-u>nohlsearch<cr>
nnoremap <space>gh :<c-u>ToggleSyntax<cr>
nnoremap <space>l :<c-u>FindCursor<cr>
nnoremap <space>gl :<c-u>Status<cr>
nnoremap <space>n :<c-u>set invnumber<cr>
nnoremap <space>gn :<c-u>set invrelativenumber<cr>
nnoremap <space>r :<c-u>Underline nr2char(getchar())<cr>
nnoremap <space>gr :<c-u>Overline nr2char(getchar())<cr>
if $XDG_SESSION_TYPE == "wayland"
nnoremap <space>pc :<c-u>.w !wl-copy<cr>
vnoremap <space>pc :w !wl-copy<cr>
nnoremap <space>pp :<c-u>r !wl-paste<cr>
endif
nnoremap <space>s :<c-u>%s/\v
vnoremap <space>s :s/\v
nnoremap <space>S :<c-u>sign unplace *<cr>
if has('win32')
nnoremap <space>t :<c-u>CtrlPTag<cr>
else
nnoremap <space>t :<c-u>Tags<cr>
endif
if executable('rg')
" `rg --vimgrep` does not support \V\C...
nnoremap <space>gt :<c-u>Ag '\b(TODO|FIXME|XXX)\b'<cr>
elseif executable('ag')
" `ag --vimgrep` does not support \<...\>
nnoremap <space>gt :<c-u>Ag '\C\b(TODO|FIXME|XXX)\b'<cr>
else
nnoremap <space>gt :<c-u>Ag '\v\C<(TODO|FIXME|XXX)>'<cr>
endif
" save specific hard-to-type unicode chars to "a
nnoremap <space>uu :<c-u>let @a = '�'<cr>
nnoremap <space>ve :<c-u>edit $MYVIMRC<cr>
nnoremap <space>vh :<c-u>split $MYVIMRC<cr>
nnoremap <space>vs :<c-u>Vexec "source $MYVIMRC"<cr>
nnoremap <space>vv :<c-u>vsplit $MYVIMRC<cr>
nnoremap <space>vl :<c-u>source ./.vimrc<cr>
nnoremap <space>w :<c-u>let b:saved_view = winsaveview()<cr>:CleanWhiteSpace<cr>:call winrestview(b:saved_view)<cr>
vnoremap <space>w :CleanWhiteSpace<cr>
nnoremap <space>x :<c-u>FixSpelling<cr>
nnoremap <space>gx :<c-u>ErrorToDict<cr>
inoremap <c-x><c-x> <c-o>:FixSpelling<cr>
nnoremap <space>z :<c-u>ClRun<space>
nnoremap <space>gz :<c-u>LlRun<space>
nnoremap <space>ö g<c-]>
nnoremap <space>gö :<c-u>!ctags -R .<cr>
nnoremap <space>? /�<cr>
" Muscle Memory Training Facilities
for s:prefix in ['i', 'n', 'v']
for s:key in ['<up>', '<down>', '<left>', '<right>']
exec s:prefix . 'noremap ' . s:key . ' <nop>'
endfor
endfor
for s:prefix in ['n', 'v']
for s:key in ['{', '}', '<C-u>', '<C-d>']
exec s:prefix . 'noremap ' . s:key . ' <nop>'
endfor
endfor
" APPEARANCE
set lazyredraw
set visualbell t_vb=
augroup DisableVisualBellInGVim
autocmd!
autocmd GUIEnter * set visualbell t_vb=
augroup END
let g:loaded_matchparen=1
set showmatch
set wildmenu
set wildignorecase
set suffixes+=.pyc
set scrolloff=1
function! g:Modified() abort
return !&modifiable ? '-' : (&modified ? '*' : '')
endfunction
function! g:GitBranch() abort
if !exists('*fugitive#head')
return ''
endif
let l:branch = fugitive#head()
return l:branch !=# '' ? '{'.l:branch.'} ' : ''
endfunction
set statusline=%{Modified()}%t%R\ %y%=%{GitBranch()}%l:%c\ %P
set list
augroup DontShowListCharsInInsertMode
autocmd!
autocmd InsertEnter * set nolist
autocmd InsertLeave * set list
augroup END
function! s:AwesomeListChars() abort
let &listchars = "tab:\u25b8 ,nbsp:~,eol: ,precedes:\u2190,extends:\u2192,trail:\u2592"
let &showbreak = "\u2190"
endfunction
augroup DontColourConceals
autocmd!
autocmd ColorScheme * highlight clear Conceal
augroup END
augroup TermSpelling
autocmd!
autocmd ColorScheme * highlight SpellBad cterm=underline
autocmd ColorScheme * highlight SpellCap cterm=underline
autocmd ColorScheme * highlight SpellRare cterm=underline
autocmd ColorScheme * highlight SpellLocal cterm=underline
augroup END
if !exists('g:loaded_vimrc')
let &listchars = 'tab:> ,nbsp:~,eol: ,precedes:-,extends:-,trail:_'
let &showbreak = '-'
if has('gui_running')
set lines=35 columns=85
set mousehide
set guioptions=ci
silent! colorscheme shirotelin
call s:AwesomeListChars()
if has('gui_gtk2') || has('gui_gtk3')
set guifont=Monospace\ 12
elseif has('gui_win32')
set guifont=Consolas:h12:cANSI
endif
elseif $TERM =~? '.*256color.*' || $TERM ==# 'xterm-kitty' || $TERM ==# 'foot' || $TERM ==# 'alacritty'
set t_ut=
set termguicolors
silent! colorscheme shirotelin
call s:AwesomeListChars()
endif
endif
augroup KeepSplitsEqualOnResize
autocmd!
autocmd VimResized * exec "normal! \<C-w>="
augroup END
augroup ColourColumnInInsertMode
autocmd!
autocmd InsertEnter * let &colorcolumn = &textwidth
autocmd InsertLeave * set colorcolumn=0
augroup END
" PLUGIN STUFF
" Ada
let g:ada_default_compiler = 'alire'
" Clojure
let g:fireplace_no_maps = 1
let g:clojure_align_multiline_strings = 1
" CtrlP
let g:ctrlp_extensions = ['tag']
" Emmet
let g:user_emmet_leader_key='<c-h>'
let g:user_emmet_install_global = 0
augroup EnableEmmet
autocmd!
autocmd FileType html,css,mako,markdown EmmetInstall
augroup END
" FZF
let g:fzf_preview_window = ''
let g:fzf_layout = { 'down': '40%' }
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
" Go
let g:go_fmt_autosave = 0
let g:go_imports_autosave = 0
let g:go_mod_fmt_autosave = 0
" Haskell
let g:haskell_indent_in = 0
let g:haskell_indent_if = 0
" Org-mode
let g:org_heading_shade_leading_stars = 0
" Perl
" let g:perl_compiler_force_warnings = 1
" Python
let g:python_no_number_highlight = 1
let g:python_space_error_highlight = 1
" Rust
let g:rust_recommended_style = 0
" LaTeX
if has('win32')
set grepprg=findstr\ /N\ $*
else
set grepprg=grep\ -nH\ $*
endif
let g:tex_flavor = 'latex'
let g:tex_conceal = 'abdmg'
let g:vimtex_imaps_enabled = 0
let g:vimtex_matchparen_enabled = 0
let g:vimtex_text_obj_enabled = 0
let g:vimtex_quickfix_mode = 0
let g:vimtex_compiler_latexmk = get(g:, 'vimtex_compiler_latexmk', {})
let g:vimtex_compiler_latexmk.options = [
\ '-verbose',
\ '-file-line-error',
\ '-interaction=nonstopmode']
if has('job')
let g:vimtex_compiler_latexmk.backend = 'jobs'
elseif has('nvim')
let g:vimtex_compiler_latexmk.backend = 'nvim'
endif
let g:vimtex_compiler_latexmk_engines = get(g:, 'vimtex_compiler_latexmk_engines', {})
let g:vimtex_compiler_latexmk_engines['_'] = '-pdfps'
let g:vimtex_compiler_latexmk_engines['dvips'] = '-pdfps'
let g:vimtex_compiler_latexmk_engines['pdflatex'] = '-pdf'
" SnipMate
let g:snipMate = get(g:, 'snipMate', {})
let g:snipMate.snippet_version = 1
" UltiSnips
if has('python3')
let g:UltiSnipsUsePythonVersion = 3
elseif has('python')
let g:UltiSnipsUsePythonVersion = 2
endif
let g:UltiSnipsJumpForwardTrigger = '<tab>'
let g:UltiSnipsJumpBackwardTrigger = '<c-h>'
" Zig
let g:zig_fmt_autosave = 0
" General Plugin Settings
set modeline
set autoindent
filetype plugin indent on
runtime macros/matchit.vim
packadd cfilter
syntax manual
set syntax=
augroup SyntaxOnlyForCertainFiletypes
autocmd!
autocmd Filetype fugitive setlocal syntax=fugitive
autocmd Filetype gitcommit setlocal syntax=gitcommit
autocmd Filetype git setlocal syntax=git
autocmd Filetype help setlocal syntax=help
autocmd Filetype mail setlocal syntax=mail
autocmd Filetype markdown setlocal syntax=markdown
autocmd Filetype org setlocal syntax=org
autocmd Filetype rst setlocal syntax=rst
augroup END
augroup OpenPDFsInBuffer
autocmd!
autocmd BufReadPre *.pdf silent set ro
autocmd BufReadPost *.pdf silent %!pdftotext -nopgbrk -layout -q -eol unix "%" -
augroup END
augroup GitCommitSpelling
autocmd!
autocmd Filetype gitcommit setlocal spell spelllang=en_gb
augroup END
let g:loaded_vimrc=1