This repository has been archived by the owner on Nov 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
548 lines (453 loc) · 17.2 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
" vim: fdm=marker foldlevel=0
" _____ _ _
" | __ \| | (_)
" | |__) | |_ _ __ _ _ _ __ ___
" | ___/| | | | |/ _` | | '_ \/ __|
" | | | | |_| | (_| | | | | \__ \
" |_| |_|\__,_|\__, |_|_| |_|___/
" __/ |
" |___/
" Plugins ----------------------{{{
set nocompatible
" Force windows Vim to use .vim instead of vimfiles
if has('win32') || has('win64')
set runtimepath-=~/vimfiles
set rtp+=$HOME/.vim
let path='$HOME/.vim'
endif
" Start of vim-plug
call plug#begin('~/.vim/plugged')
Plug 'SirVer/ultisnips' " snippet tool
Plug 'Valloric/YouCompleteMe' " auto-complete
Plug 'amix/vim-zenroom2' " emulates iA Writer environment when editing Markdown
Plug 'camspiers/lens.vim' " Automatic window resizing
Plug 'dense-analysis/ale' " Syntax checking
Plug 'ervandew/supertab' " allows you to use <Tab> for all your insert completion needs
Plug 'godlygeek/tabular' " Tabular for aligning text
Plug 'haya14busa/is.vim' " Automatically clear search highlights after you move your cursor.
" Plug 'honza/vim-snippets' " Snippets are separated from the engine.
Plug 'junegunn/fzf.vim' " fuzzy searching
Plug 'junegunn/goyo.vim' " goyo focused editing
Plug 'junegunn/limelight.vim' " Dim paragraphs above and below the active paragraph.
Plug 'kana/vim-textobj-user' " Custom text objects
Plug 'luochen1990/rainbow' " rainbow parenthesis
Plug 'mhinz/vim-startify' " startup
Plug 'mileszs/ack.vim' " silver searcher via ack
Plug 'plasticboy/vim-markdown' " markdown support
Plug 'rust-lang/rust.vim' " rust
Plug 'tpope/vim-commentary' " Comment stuff out.
Plug 'tpope/vim-fugitive' " git integration
Plug 'tpope/vim-surround' " easily modify surrounding pairs
Plug 'tpope/vim-unimpaired' " vim navigation
Plug 'tpope/vim-repeat' " enable better repeating
Plug 'tpope/vim-abolish' " Convert to/from CamelCase crs and crc
Plug 'vim-scripts/argtextobj.vim' " Function arguments as text objects
Plug 'mzlogin/vim-markdown-toc' " Generate Markdown TOC automatically
Plug 'thinca/vim-quickrun' " Quickly execute the current buffer
Plug 'itchyny/lightline.vim'
Plug 'wadackel/vim-dogrun'
Plug 'ap/vim-css-color'
Plug 'junegunn/fzf', { 'do': './install --bin' }
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' }
" color theme(s)
Plug 'NLKNguyen/papercolor-theme'
Plug 'rakr/vim-two-firewatch'
Plug 'AlessandroYorba/Sierra'
Plug 'sts10/vim-pink-moon'
Plug 'Nequo/vim-allomancer'
Plug 'koirand/tokyo-metro.vim'
Plug 'dennougorilla/azuki.vim'
Plug 'fcpg/vim-farout'
Plug 'nightsense/vim-crunchbang'
Plug 'sainnhe/gruvbox-material'
Plug 'arzg/vim-oldbook8'
Plug 'axvr/photon.vim'
Plug 'sainnhe/vim-color-forest-night'
" all Plugins must be added before this line:
call plug#end()
" file encoding - required for YouCompleteMe
set encoding=utf-8
" }}}
" _____ _ _ _____ _ _ _
" | __ \| | (_) / ____| | | | | (_)
" | |__) | |_ _ __ _ _ _ __ | (___ ___| |_| |_ _ _ __ __ _ ___
" | ___/| | | | |/ _` | | '_ \ \___ \ / _ \ __| __| | '_ \ / _` / __|
" | | | | |_| | (_| | | | | | ____) | __/ |_| |_| | | | | (_| \__ \
" |_| |_|\__,_|\__, |_|_| |_| |_____/ \___|\__|\__|_|_| |_|\__, |___/
" __/ | __/ |
" |___/ |___/
" Plugin Settings-----------------------------------------------------{{{
" When using :MarkdownPreview use GitHub CSS for better style
let g:mkdp_markdown_css='~/.vim/markdown/github-markdown.css'
" Enable a preview window for fzf when searching
if has('win32')
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, {'options': ['--layout=reverse', '--info=inline', '--preview', 'cat {}']}, <bang>0)
else
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}), <bang>0)
endif
" disable preview window for you complete me
let g:SuperTabClosePreviewOnPopupClose = 1
let g:ycm_autoclose_preview_window_after_insertion = 1
let g:ycm_autoclose_preview_window_after_completion = 1
" enable it later via :RainbowToggle
let g:rainbow_active = 0
" use ag with ack.vim instead of grep or ack
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
"}}}
" /\
" / \ _ __ _ __ ___ __ _ _ __ __ _ _ __ ___ ___
" / /\ \ | '_ \| '_ \ / _ \/ _` | '__/ _` | '_ \ / __/ _ \
" / ____ \| |_) | |_) | __/ (_| | | | (_| | | | | (_| __/
" /_/ \_\ .__/| .__/ \___|\__,_|_| \__,_|_| |_|\___\___|
" | | | |
" |_| |_|
" Appearance --------------------------------------------{{{
" Presentation mode will enable a light color scheme
" and it will increase the font size
let g:presentation_mode = 0
" set 256 colors
set t_Co=256
" set the colorscheme
if g:presentation_mode == 0
set background=dark
colo dogrun
let g:lightline = { 'colorscheme' : 'dogrun' }
else
set background=light
colo PaperColor
let g:lightline = { 'colorscheme' : 'PaperColor_light' }
endif
" show the ruler on the right side of the status line
set ruler
" enable line numbers
set number
" enable relative line numbers
set relativenumber
" draw a line at column 120
set colorcolumn=120
" don't show the mode as this will be included by the status line
set noshowmode
" always show the status line
set laststatus=2
" gVim options
set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
set guioptions-=L "remove left-hand scroll bar
" font selection
if has('win32')
if has ('nvim')
" exec 'Guifont! Source Code Pro:h10'
" This must be in ginit.vim for NeoVim
else
" normal Vim
if g:presentation_mode == 1
set guifont=Source\ Code\ Pro:h18
else
set guifont=JetBrains\ Mono:h12
endif
endif
else
" Linux Vim
set guifont=Source\ Code\ Pro\ 10
endif
" enable syntax highlighting
syntax on
" highlight the current line
set cursorline
" shows matching pairs of (), [], or {}
set showmatch
" settings to display whitespace characters
set list " show whitespace
set listchars=nbsp:⦸ " CIRCLED REVERSE SOLIDUS (U+29B8, UTF-8: E2 A6 B8)
set listchars+=tab:┈┈ " BOX DRAWINGS LIGHT QUADRUPLE DASH HORIZONTAL' (U+2508, UTF-8: E2 94 88)
set listchars+=extends:» " RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00BB, UTF-8: C2 BB)
set listchars+=precedes:« " LEFT-POINTING DOUBLE ANGLE QUOTATION MARK (U+00AB, UTF-8: C2 AB)
set listchars+=trail:• " BULLET (U+2022, UTF-8: E2 80 A2)
" appearnce of folding
if has('folding')
if has('windows')
set fillchars=vert:┃ " BOX DRAWINGS HEAVY VERTICAL (U+2503, UTF-8: E2 94 83)
set fillchars+=fold:· " MIDDLE DOT (U+00B7, UTF-8: C2 B7)
endif
set foldmethod=indent " not as cool as syntax, but faster
set foldlevelstart=99 " start unfolded
endif
" }}}
" _ __ _ _
" | |/ / | | | |
" | ' / ___ _ _ ___| |_ _ __ ___ | | _____ ___
" | < / _ \ | | / __| __| '__/ _ \| |/ / _ \/ __|
" | . \ __/ |_| \__ \ |_| | | (_) | < __/\__ \
" |_|\_\___|\__, |___/\__|_| \___/|_|\_\___||___/
" __/ |
" |___/
" Keywords ------------------------------------{{{
" set the leader key
let mapleader=" "
" make YCM compatible with UltiSnips (using supertab)
let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
let g:SuperTabDefaultCompletionType = '<C-n>'
" better key bindings for UltiSnipsExpandTrigger
let g:UltiSnipsExpandTrigger = "<tab>"
let g:UltiSnipsJumpForwardTrigger = "<tab>"
let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
" toggle relative numbering and the cursorline, this might prevent lag
" when editing very large files
noremap <leader>rel :set relativenumber!<CR>:set cursorline!<CR>
" Pressing F5 will delete whitespace from lines that only have whitespace (but will not delete the blank line). And
" any trailing whitespace on lines with content.
" Note: this will also save and restore the last search pattern.
:nnoremap <silent> <F5> :let _s=@/ <Bar> :%s/^\s\+$//e <Bar> :%s/\s\+$//e <Bar> :let @/=_s <Bar> :nohl <Bar> :unlet _s <CR>
" Open UltiSnips edit function
nnoremap <leader>ue :UltiSnipsEdit<cr>
" toggle umlaut feature (faster German typing)
nnoremap <leader>de :call ToogleUmlauts()<CR>
nnoremap <leader>det :call ToogleTexUmlauts()<CR>
nnoremap <leader>b :Buffers<CR>
nnoremap <leader>f :Files<CR>
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
nnoremap <leader>sv :source $MYVIMRC<cr>
nnoremap <leader>d :bd<CR>
nnoremap <leader>ag :Ack!<Space>
nnoremap <leader>n :silent! nohls<cr>
" Next ALE finding.
nmap <silent> <M-n> :ALENext<cr>
nmap <silent> <M-e> :ALEPrevious<cr>
nnoremap <A-j> :m .+1<CR>==
nnoremap <A-k> :m .-2<CR>==
" very magic searching
nnoremap / /\v
vnoremap / /\v
" }}}
" ____ _ _
" / __ \ | | (_)
" | | | |_ __ | |_ _ ___ _ __ ___
" | | | | '_ \| __| |/ _ \| '_ \/ __|
" | |__| | |_) | |_| | (_) | | | \__ \
" \____/| .__/ \__|_|\___/|_| |_|___/
" | |
" |_|
" Options ------------------------{{{
" vertically split ultisnips edit window
let g:UltiSnipsEditSplit="vertical"
" --- Indentation Options {{{
" a tab is the width of 4 spaces
set tabstop=4
" when auto-indenting use 4 spaces (default is 8?)
set shiftwidth=4
" Set the text width (to be used with gq)
set textwidth=119 " Less than 120 column
" expand tabs into spaces
set expandtab
" --- Indetation Options }}}
" --- Serarching Options {{{
" Enable incremental searching
set incsearch
" Highlight all items found by searching
set hlsearch
" ignore case when searching
set ignorecase
" automatically switch rearch to case-sensitive when the query contains an
" upper case letter
set smartcase
" --- Serarching Options }}}
" backspace removes all (indents, EOLs, start)
set backspace=indent,eol,start
" Disable filtering by filetype
autocmd FileType * let b:browsefilter = ''
" start scrolling 3 lines before edge of viewport
set scrolloff=3
set wildignore=*.o,*.a,*.pyc,*.swp,.git,.git/*,*.exe
" --- Performance Options {{{
" don't bother updating screen during macro playback
set lazyredraw
" --- Performance Options }}}
" --- UI Options {{{
" disable the mouse
set mouse=
" disable beep on errors
set noerrorbells
" enable visual bell, this will be disabled later with autocommands
set visualbell
" --- UI Options }}}
" location of python
if has('win32')
let g:python3_host_prog = 'C:\Python38\python.exe'
let g:python_host_prog = 'C:\Python27\python.exe'
endif
" }}}
" ______ _ _
" | ____| | | (_)
" | |__ _ _ _ __ ___| |_ _ ___ _ __ ___
" | __| | | | '_ \ / __| __| |/ _ \| '_ \/ __|
" | | | |_| | | | | (__| |_| | (_) | | | \__ \
" |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/
" Functions --------------------------------{{{
" function to enable faster German typing
" starting at 1 will enable the mappings the first time the function is called (disabled by default)
let g:auto_umlaut = 1
function! ToogleUmlauts()
if g:auto_umlaut
echo "Quick entry for umlauts (and ß) ENABLED!"
inoremap ae ä
inoremap oe ö
inoremap ue ü
inoremap ss ß
inoremap Ae Ä
inoremap Oe Ö
inoremap Ue Ü
let g:auto_umlaut = 0
else
echo "Quick entry for umlauts (and ß) DISABLED!"
iunmap ae
iunmap oe
iunmap ue
iunmap ss
iunmap Ae
iunmap Oe
iunmap Ue
let g:auto_umlaut = 1
endif
endfunction
function! ToogleTexUmlauts()
if g:auto_umlaut
echo "Quick entry for umlauts (and ß) ENABLED!"
inoremap ae {\"a}
inoremap oe {\"o}
inoremap ue {\"u}
inoremap ss {\s}
inoremap Ae {\"A}
inoremap Oe {\"O}
inoremap Ue {\"U}
let g:auto_umlaut = 0
else
echo "Quick entry for umlauts (and ß) DISABLED!"
iunmap ae
iunmap oe
iunmap ue
iunmap ss
iunmap Ae
iunmap Oe
iunmap Ue
let g:auto_umlaut = 1
endif
endfunction
" }}}
" _ _____ _
" /\ | | / ____| | |
" / \ _ _| |_ ___ | | ___ _ __ ___ _ __ ___ __ _ _ __ __| |___
" / /\ \| | | | __/ _ \ | | / _ \| '_ ` _ \| '_ ` _ \ / _` | '_ \ / _` / __|
" / ____ \ |_| | || (_) | | |___| (_) | | | | | | | | | | | (_| | | | | (_| \__ \
" /_/ \_\__,_|\__\___/ \_____\___/|_| |_| |_|_| |_| |_|\__,_|_| |_|\__,_|___/
"
" Auto Commands -----------------------------------------------------------{{{
" Disable the visual bell for both Vim and gVim
autocmd GUIEnter * set vb t_vb= " for your GUI
autocmd VimEnter * set vb t_vb=
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
" special behavior for editing LaTeX
au! BufNewFile,BufReadPost,BufEnter *.{latex,tex,tex.tpl} set filetype=tex foldmethod=indent
autocmd FileType tex setlocal ff=unix
au! BufNewFile,BufReadPost,BufEnter *.{c.re} set filetype=c
" }}}
" _____ _ _ _ _
" / ____| | | | | (_)
" | (___ | |_ __ _| |_ _ _ ___| |_ _ __ ___
" \___ \| __/ _` | __| | | / __| | | '_ \ / _ \
" ____) | || (_| | |_| |_| \__ \ | | | | | __/
" |_____/ \__\__,_|\__|\__,_|___/_|_|_| |_|\___|
" Statusline --------------------------------{{{
" let g:lightline = { 'colorscheme' : 'dogrun' }
" }}}
" _____ _ _ _
" / ____| | | | | | |
" | (___ ___ _ __ __ _| |_ ___| |__ _ __ __ _ __| |
" \___ \ / __| '__/ _` | __/ __| '_ \| '_ \ / _` |/ _` |
" ____) | (__| | | (_| | || (__| | | | |_) | (_| | (_| |
" |_____/ \___|_| \__,_|\__\___|_| |_| .__/ \__,_|\__,_|
" | |
" |_|
" Scratchpad -----------------------------------------{{{
" Disable spell checking in tex comments
let g:tex_comment_nospell=1
set spelllang=en_us
syntax spell toplevel
set nospell
" new lines inherig the identation of previous lines
set autoindent
" when schiting line, round the indentatio to the nearest multiple of
" "shiftwidth"
set shiftround
" insert "tabstop" number of spacer whin the "tab" key is pressed
set smarttab
" limit the files searched for auto-complete
set complete-=i
" always try to show a paragrah's last line
set display+=lastline
" delete comment character when joining lines
set formatoptions+=j
" start gVim Maximized
au GUIEnter * simalt ~x
" We can use different key mappings for easy navigation between splits to save a keystroke. So instead of ctrl-w then j, it’s just ctrl-j:
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Taken directly from:
" https://vi.stackexchange.com/questions/4148/can-i-join-lines-with-a-comma-or-another-character
" ================ script ===============================================
" interactive 'J', 'gJ' replacement with optional 'vim-repeat' support
" The last used separator is automatically reused as:
" a. default choice
" b. when repeating (=> non-interactive repeats: same range, same separator)
let g:last_join_separator = " "
function! s:interactiveJoin(use_last_sep,...) range
if (a:use_last_sep == 0) "interactive, ask for separator to use
call inputsave()
echohl Question
let l:sep = input("Separator:", g:last_join_separator)
echohl None
call inputrestore()
redraw!
let g:last_join_separator = l:sep "update last separator value
else "non-interactive (when repeating with '.')
let l:sep = g:last_join_separator
endif
if (a:0 == 0) "with no argument, remove indentation *and trailing spaces*
let l:subst = 's/\s*\n\+\s*/\=' . "'" . l:sep . "'/"
else " don't remove indentation or trailing spaces (act like 'gJ')
let l:subst = 's/\n\+/\=' . "'" . l:sep . "'/"
endif
if a:firstline < a:lastline "join given range
execute a:firstline . ',' . (a:lastline - 1) . l:subst
let l:count = a:lastline - a:firstline + 1 "default count for repeat
else "or join only with next line
execute l:subst
let l:count = 1 "default count for repeat
endif
"make command repeatable
"(with the tpope/vim-repeat plugin: optional, recommended)
if (a:0 == 0)
silent! call repeat#set("\<Plug>(repeatJoin)", l:count)
else
silent! call repeat#set("\<Plug>(repeatGJoin)", l:count)
endif
endfunction
noremap <silent> <Plug>(interactiveJoin) :call <SID>interactiveJoin(0)<CR>
noremap <silent> <Plug>(interactiveGJoin) :call <SID>interactiveJoin(0,'g')<CR>
noremap <silent> <Plug>(repeatJoin) :call <SID>interactiveJoin(1)<CR>
noremap <silent> <Plug>(repeatGJoin) :call <SID>interactiveJoin(1,'g')<CR>
nmap J <Plug>(interactiveJoin)
xmap J <Plug>(interactiveJoin)
nmap gJ <Plug>(interactiveGJoin)
xmap gJ <Plug>(interactiveGJoin)
" }}}