-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmyvimrc
More file actions
652 lines (578 loc) · 21 KB
/
myvimrc
File metadata and controls
652 lines (578 loc) · 21 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
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
" modeline vim: fdm=marker
" General settings {{{
set nocompatible
filetype plugin indent on
set encoding=utf-8
set nu
set rnu
set hlsearch
set incsearch
set ignorecase
set smartcase
set mouse=a
set shiftwidth=4 " Use indents of 4 spaces
set expandtab " Tabs are spaces, not tabs
set tabstop=4 " An indentation every four columns
set softtabstop=4 " Let backspace delete indent
set showmode
set wildmenu
set wildmode=list:longest,full " basically [:] means [&&] [,] means [then]
" set wildoptions=pum,tagfile "nvim's default settings
" set colorcolumn=120 " a mark at col 120 indicating that the line is too long
set showtabline=1
set novisualbell
set noswapfile
set nobackup
set nowritebackup
set hidden
set history=2000
set splitright
let mapleader=" "
" set autochdir
set nolist
set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
set backspace=indent,eol,start
colorscheme default
set background=light
if has('gui_running')
set background=light
endif
" termguicolors, read `:h xterm-true-color` for further help
" the followin' t_8f/t_8b settings are copied from
" https://stackoverflow.com/questions/62702766/termguicolors-in-vim-makes-everything-black-and-white
" set termguicolors
" let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
" let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" Common mappings
" Visual shifting (does not exit Visual mode)
vnoremap < <gv
vnoremap > >gv
vnoremap <leader>f y/<c-r>"
"
"MYVIMRC mappings
nnoremap <leader>sv :source $MYVIMRC<cr>
nnoremap <leader>ev :vsp $MYVIMRC<cr>
tnoremap <esc> <c-\><c-n>
" something interesting saw in coding videos, but seems useful
autocmd InsertEnter * :set norelativenumber
autocmd InsertLeave * :set relativenumber
autocmd FileType qf :set norelativenumber
"}}}
" Share clipboard if possible"{{{
if has('clipboard')
if has('unnamedplus') " When possible use + register for copy-paste
set clipboard=unnamed,unnamedplus
else " On mac and Windows, use * register for copy-paste
set clipboard=unnamed
endif
endif "}}}
" Set a rough statusline "{{{
if v:false && has('statusline')
set laststatus=2
" Broken down into easily includeable segments
set shortmess-=S " display the number of matches from a search, see https://vi.stackexchange.com/questions/15944/how-to-display-in-the-statusline-the-number-of-matches-from-a-search
set statusline=%<%f\ " Filename
set statusline+=%w%h%m%r " Options
set statusline+=\ [%{&ff}/%Y/%{&fileencoding?&fileencoding:&encoding}] " Filetype
" set statusline+=\ [%{getcwd()}] " Current dir
" set statusline+=\ %b\ 0x%B " ga/:ascii
set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info
set statusline+=%{fugitive#statusline()} " Git Hotness
endif "}}}
" Manage plugins using vim-plug, auto load for first time uses {{{
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif
call plug#begin('~/.vim/plugged')
Plug 'fatih/vim-go', {'tag': '*'}
Plug 'SirVer/ultisnips'
Plug 'tpope/vim-commentary'
Plug 'preservim/vim-markdown'
Plug 'godlygeek/tabular'
Plug 'christoomey/vim-tmux-navigator'
" Plug 'mattn/vim-yoshi'
" Plug 'easymotion/vim-easymotion'
" Plug 'vim-airline/vim-airline'
" Plug 'vim-airline/vim-airline-themes'
" Plug 'mengelbrecht/lightline-bufferline'
" Plug 'ap/vim-buftabline' " simpler and maybe more useful for me
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'mbbill/undotree'
Plug 'gcmt/wildfire.vim'
" Plug 'voldikss/vim-floaterm'
Plug 'itchyny/lightline.vim'
" Plug 'rakr/vim-one'
" Plug 'morhetz/gruvbox'
Plug 'NLKNguyen/papercolor-theme'
" Plug 'preservim/nerdtree'
" Plug 'airblade/vim-gitgutter'
" Plug 'terryma/vim-multiple-cursors' " Deprecated
" Plug 'mg979/vim-visual-multi'
Plug 'iamcco/markdown-preview.nvim', {'do': { -> mkdp#util#install() }, 'for': ['markdown', 'vim-plug']}
Plug 'vim-autoformat/vim-autoformat'
if v:false && has('nvim')
" Use release branch (recommend)
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Plug 'lukas-reineke/indent-blankline.nvim'
" " Or build from source code by using yarn: https://yarnpkg.com
" Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}
elseif !has('nvim')
Plug 'ycm-core/YouCompleteMe'
" YCM related
let g:ycm_add_preview_to_completeopt="popup"
nmap <leader>yfs <Plug>(YCMFindSymbolInWorkspace)
if v:version >= 900
augroup YCM
autocmd!
autocmd BufWinEnter *.py,*.cpp {
nnoremap <buffer> gd :YcmCompleter GoToDefinition<CR>
nnoremap <buffer> gr :YcmCompleter GoToReferences<CR>
nnoremap <buffer> gi :YcmCompleter GoToImplementation<CR>
} " in neovim/vim8, a leading '\' is needed, buf vim9 is just the opposite.
augroup END
else
" echom "It is vim8 intepreter!"
augroup YCM
autocmd!
autocmd BufWinEnter *.py,*.cpp nnoremap <buffer> gd :YcmCompleter GoToDefinition<CR> | nnoremap <buffer> gr :YcmCompleter GoToReferences<CR> | nnoremap <buffer> gi :YcmCompleter GoToImplementation<CR>
augroup END
endif
endif
call plug#end() "}}}
" A function for default basic emacs/bash-like moving in insert mode {{{
" might be useful when using Chinese input method
function! ToggleEmacsMapping(prompt)
" vim has defined ctrl-u alt-b for similar functionality
if g:emacs_mapping==1
if (a:prompt)
echo "emacs_mapping is on, turning it off"
endif
iunmap <C-f>
iunmap <C-b>
iunmap <C-n>
iunmap <C-p>
iunmap <C-a>
iunmap <C-e>
iunmap <C-k>
iunmap <A-f>
let g:emacs_mapping=0
else
" TODO: using magarg to save/restore original mapping
" https://vi.stackexchange.com/questions/7734/how-to-save-and-restore-a-mapping
if (a:prompt)
echo "emacs_mapping is off, turning it on"
endif
inoremap <C-f> <Right>
inoremap <C-b> <Left>
inoremap <C-n> <cmd>normal! g<Down> <cr>
inoremap <C-p> <cmd>normal! g<Up> <cr>
inoremap <C-a> <Home>
inoremap <C-e> <End>
inoremap <C-k> <esc>d$a
inoremap <A-f> <esc>lwi
inoremap <A-b> <esc>bi
let g:emacs_mapping=1
endif
endfunction
let g:emacs_mapping=0
call ToggleEmacsMapping(v:false)
command! -nargs=0 ToggleEmacs call ToggleEmacsMapping(v:true) "}}}
" Auto jump back to the last position when opened {{{
function! ResCur()
if line("'\"") <= line("$")
silent! normal! g`"
return 1
endif
endfunction
augroup resCur
autocmd!
autocmd BufWinEnter * call ResCur()
augroup END
" Always switch to the current file directory, now I am using 'autochdir' option
" autocmd BufEnter * if bufname("") !~ "^\[A-Za-z0-9\]*://" | lcd %:p:h | endif "}}}
" FZF key Mappings {{{
" for fzf preview-window
" see https://github.com/junegunn/fzf.vim/issues/358
" let $FZF_DEFAULT_OPTS="--preview-window 'right:57%' --preview 'bat --style=numbers --line-range :300 {}' --bind ctrl-y:preview-up,ctrl-e:preview-down,ctrl-b:preview-page-up,ctrl-f:preview-page-down,ctrl-u:preview-half-page-up,ctrl-d:preview-half-page-down,shift-up:preview-top,shift-down:preview-bottom,alt-up:half-page-up,alt-down:half-page-down"
let $FZF_DEFAULT_OPTS="--preview-window 'right:57%' --bind ctrl-y:preview-up,ctrl-e:preview-down,ctrl-b:preview-page-up,ctrl-f:preview-page-down,ctrl-u:preview-half-page-up,ctrl-d:preview-half-page-down,shift-up:preview-top,shift-down:preview-bottom,alt-up:half-page-up,alt-down:half-page-down"
let $FZF_DEFAULT_COMMAND="fd --hidden --type f"
" noremap <C-p> :Files<CR>
nnoremap <C-p> :FZF<CR>
nnoremap <leader>f :Rg<CR>
nnoremap <leader>b :Buffers<CR>
nnoremap sf :LFiles<CR>
let g:fzf_layout = { 'down': '40%' }
" borrowed from https://github.com/junegunn/fzf.vim/issues/837
" command! -bang -nargs=* PRg
" \ call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case ".shellescape(<q-args>), 1, {'dir': expand('%:p:h')}, <bang>0)
command! -bang -nargs=? -complete=dir LFiles
\ call fzf#vim#files(expand('%:p:h'), fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}, <bang>0))
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--info=inline']}, <bang>0))
command! -bang -nargs=* PRg
\ call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case ".shellescape(<q-args>), 1, fzf#vim#with_preview({'dir': getenv('PWD')}), <bang>0)
command! -nargs=* -complete=dir -bang PFZF call fzf#run(fzf#wrap('FZF', fzf#vim#with_preview({'dir': getenv('PWD')}), <bang>0))
" source play.vim
"
" copied from https://www.reddit.com/r/vim/comments/gpe3tr/ripgrep_from_inside_vim/
" if executable('rg')
" set grepprg=rg\ --vimgrep\ --hidden\ —glob ‘!.git’
" endif
" Then you can just do the following which populates the results in the quick fix list
" :grep <pattern>
" If you want to grep the word under your cursor do
" :grep <c-r><c-w>
" :h c_CTRL-R_CTRL-W to check
"
"}}}
" vim-go navi mappings {{{
autocmd FileType go nnoremap <buffer> gr :GoReferrers<CR>
autocmd FileType go nnoremap <buffer> gi :GoImplements<CR>
autocmd FileType go nnoremap <buffer> goc :GoCallers<CR>
" au filetype go inoremap <buffer> . .<C-x><C-o>
" vim-go settings
let g:go_list_type="quickfix"
let g:go_doc_popup_window = 1
"}}}
" markdown-preview config {{{
" set to 1, nvim will open the preview window after entering the markdown buffer
" default: 0
let g:mkdp_auto_start = 0
" set to 1, the nvim will auto close current preview window when change
" from markdown buffer to another buffer
" default: 1
let g:mkdp_auto_close = 1
" set to 1, the vim will refresh markdown when save the buffer or
" leave from insert mode, default 0 is auto refresh markdown as you edit or
" move the cursor
" default: 0
let g:mkdp_refresh_slow = 0
" set to 1, the MarkdownPreview command can be use for all files,
" by default it can be use in markdown file
" default: 0
let g:mkdp_command_for_global = 0
" set to 1, preview server available to others in your network
" by default, the server listens on localhost (127.0.0.1)
" default: 0
let g:mkdp_open_to_the_world = 0
" use custom IP to open preview page
" useful when you work in remote vim and preview on local browser
" more detail see: https://github.com/iamcco/markdown-preview.nvim/pull/9
" default empty
let g:mkdp_open_ip = ''
" specify browser to open preview page
" for path with space
" valid: `/path/with\ space/xxx`
" invalid: `/path/with\\ space/xxx`
" default: ''
let g:mkdp_browser = ''
" set to 1, echo preview page url in command line when open preview page
" default is 0
let g:mkdp_echo_preview_url = 0
" a custom vim function name to open preview page
" this function will receive url as param
" default is empty
let g:mkdp_browserfunc = ''
" options for markdown render
" mkit: markdown-it options for render
" katex: katex options for math
" uml: markdown-it-plantuml options
" maid: mermaid options
" disable_sync_scroll: if disable sync scroll, default 0
" sync_scroll_type: 'middle', 'top' or 'relative', default value is 'middle'
" middle: mean the cursor position alway show at the middle of the preview page
" top: mean the vim top viewport alway show at the top of the preview page
" relative: mean the cursor position alway show at the relative positon of the preview page
" hide_yaml_meta: if hide yaml metadata, default is 1
" sequence_diagrams: js-sequence-diagrams options
" content_editable: if enable content editable for preview page, default: v:false
" disable_filename: if disable filename header for preview page, default: 0
let g:mkdp_preview_options = {
\ 'mkit': {},
\ 'katex': {},
\ 'uml': {},
\ 'maid': {},
\ 'disable_sync_scroll': 0,
\ 'sync_scroll_type': 'middle',
\ 'hide_yaml_meta': 1,
\ 'sequence_diagrams': {},
\ 'flowchart_diagrams': {},
\ 'content_editable': v:false,
\ 'disable_filename': 0,
\ 'toc': {}
\ }
" use a custom markdown style must be absolute path
" like '/Users/username/markdown.css' or expand('~/markdown.css')
let g:mkdp_markdown_css = ''
" use a custom highlight style must absolute path
" like '/Users/username/highlight.css' or expand('~/highlight.css')
let g:mkdp_highlight_css = ''
" use a custom port to start server or empty for random
let g:mkdp_port = ''
" preview page title
" ${name} will be replace with the file name
let g:mkdp_page_title = '「${name}」'
" recognized filetypes
" these filetypes will have MarkdownPreview... commands
let g:mkdp_filetypes = ['markdown']
" set default theme (dark or light)
" By default the theme is define according to the preferences of the system
let g:mkdp_theme = 'light'
augroup MarkDown
autocmd!
autocmd FileType markdown nnoremap <buffer> <F5> :MarkdownPreview<CR>
augroup END
"}}}
" Memo {{{
" == formatoptions
" set formatoptions=croql
"
" == set encoding for chinese input and vim language in chinese
" see http://edyfox.codecarver.org/html/vim_fileencodings_detection.html
" set encoding=utf-8
" set langmenu=zh_CN.UTF-8
" language message zh_CN.UTF-8
" set termencoding=gbk
" set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1
" == mapleader
" let mapleader="\<space>"
" If the current buffer has never been saved, it will have no name,
" call the file browser to save it, otherwise just save it.
" command -nargs=0 -bar Update if &modified
" \| if empty(bufname('%'))
" \| browse confirm write
" \| else
" \| confirm write
" \| endif
" \|endif
" nnoremap <silent> <C-S> :<C-u>Update<CR>
" let s:uname = system("echo -n \"$(uname)\"")
" if !v:shell_error && s:uname == "Darwin" && !has("gui_running")
" echo "map cmd+s as save"
" inoremap <D-s> <ESC>:Update<CR>
" endif
" }}}
" grep/make integration related stuff {{{
" from http://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/
" jonhoo's config
if executable('ag')
set grepprg=ag\ --nogroup\ --nocolor
endif
if executable('rg')
set grepprg=rg\ --no-heading\ --vimgrep\ $*\ $PWD
set grepformat=%f:%l:%c:%m
endif
" if !executable('rg')
" set grepprg=grep\ -n\ -r\ $*\ %:p:h\ /dev/null
" else
" set grepprg=rg\ --vimgrep\ $*\ %:p:h\ /dev/null
" endif
"}}}
" Trigger configuration. You need to change this to something other than <tab> if you use one of the following:
" - https://github.com/Valloric/YouCompleteMe
" - https://github.com/nvim-lua/completion-nvim
let g:UltiSnipsExpandTrigger="<c-l>"
let g:UltiSnipsJumpForwardTrigger="<c-l>"
let g:UltiSnipsJumpBackwardTrigger="<c-h>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
let g:UltiSnipsSnippetDirectories=["$HOME/" .. ".vim/plugged/vim-go/gosnippets"]
" meta key related settings
" refer to https://github.com/skywind3000/vim-init/wiki/Setup-terminals-to-support-ALT-and-Backspace-correctly
function! Terminal_MetaMode(mode)
set ttimeout
if $TMUX != ''
set ttimeoutlen=30
elseif &ttimeoutlen > 80 || &ttimeoutlen <= 0
set ttimeoutlen=80
endif
if has('nvim') || has('gui_running')
return
endif
function! s:metacode(mode, key)
if a:mode == 0
exec "set <M-".a:key.">=\e".a:key
else
exec "set <M-".a:key.">=\e]{0}".a:key."~"
endif
endfunc
for i in range(10)
call s:metacode(a:mode, nr2char(char2nr('0') + i))
endfor
for i in range(26)
call s:metacode(a:mode, nr2char(char2nr('a') + i))
call s:metacode(a:mode, nr2char(char2nr('A') + i))
endfor
if a:mode != 0
for c in [',', '.', '/', ';', '[', ']', '{', '}']
call s:metacode(a:mode, c)
endfor
for c in ['?', ':', '-', '_']
call s:metacode(a:mode, c)
endfor
else
for c in [',', '.', '/', ';', '{', '}']
call s:metacode(a:mode, c)
endfor
for c in ['?', ':', '-', '_']
call s:metacode(a:mode, c)
endfor
endif
endfunc
" call Terminal_MetaMode(0)
set timeout
" set ttimeout
set timeoutlen=3000
set ttimeoutlen=100
" set Meta based shortcuts
inoremap <M-s> <cmd>update<cr>
noremap <M-s> <cmd>update<cr>
" for vim
" inoremap <Esc>s <Cmd>update<Cr>
" source $HOME/dotfiles/redir.vim
" copy-paste it to here to avoid the location problem,
" not so elegant, but useful.
function! Redir(cmd, rng, start, end)
for win in range(1, winnr('$'))
if getwinvar(win, 'scratch')
execute win . 'windo close'
endif
endfor
if a:cmd =~ '^!'
let cmd = a:cmd =~' %'
\ ? matchstr(substitute(a:cmd, ' %', ' ' . shellescape(escape(expand('%:p'), '\')), ''), '^!\zs.*')
\ : matchstr(a:cmd, '^!\zs.*')
if a:rng == 0
let output = systemlist(cmd)
else
let joined_lines = join(getline(a:start, a:end), '\n')
let cleaned_lines = substitute(shellescape(joined_lines), "'\\\\''", "\\\\'", 'g')
let output = systemlist(cmd . " <<< $" . cleaned_lines)
endif
else
redir => output
execute a:cmd
redir END
let output = split(output, "\n")
endif
vnew
let w:scratch = 1
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
call setline(1, output)
endfunction
" This command definition includes -bar, so that it is possible to "chain" Vim commands.
" Side effect: double quotes can't be used in external commands
command! -nargs=1 -complete=command -bar -range Redir silent call Redir(<q-args>, <range>, <line1>, <line2>)
" This command definition doesn't include -bar, so that it is possible to use double quotes in external commands.
" Side effect: Vim commands can't be "chained".
command! -nargs=1 -complete=command -range Redir silent call Redir(<q-args>, <range>, <line1>, <line2>)
" Let's save undo info!
" if !isdirectory($HOME."/.vim")
" call mkdir($HOME."/.vim", "", 0770)
" endif
" if !isdirectory($HOME."/.vim/undo-dir")
" call mkdir($HOME."/.vim/undo-dir", "", 0700)
" endif
" set undodir=~/.vim/undo-dir
" set undofile
" window operations shortcuts
" nmap <silent> <C-k> :wincmd k<CR>
" nmap <silent> <C-j> :wincmd j<CR>
" nmap <silent> <C-h> :wincmd h<CR>
" nmap <silent> <C-l> :wincmd l<CR>
" ergonomic line operations
nnoremap j gj
nnoremap k gk
nnoremap gj j
nnoremap gk k
" easy operations for quickfix window
nnoremap ++ <cmd>cnext<cr>
nnoremap __ <cmd>cprevious<cr>
" nnoremap +_ <cmd>cnewer<cr>
" nnoremap _+ <cmd>colder<cr>
colorscheme PaperColor
" lightline settings
if !has("nvim")
set laststatus=2
set noshowmode
let g:lightline = {
\ 'colorscheme': 'PaperColor',
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ],
\ [ 'readonly', 'filename', 'modified'] ],
\ },
\ 'component': {
\ 'pwd': '%{getcwd()}',
\ 'filename': '%f' ,
\ },
\ 'component_function': {
\ 'branch': 'FugitiveHEAD'
\}
\ }
endif
nnoremap / /\v
nnoremap ? ?\v
" cnoremap %s/ %sm/ "smagic
let g:vim_markdown_folding_disabled = 1
" let g:vim_markdown_conceal = 0 " see 'conceallevel' for more
"
let g:vim_markdown_math = 1
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_toml_frontmatter = 1
let g:vim_markdown_json_frontmatter = 1
let g:vim_markdown_strikethrough = 1
nnoremap <leader>jq <cmd>%!jq .<cr>
let s:match_highlights = ["ErrorMsg", "StatusLine", "DiffChange", "DiffAdd", "DiffText", "DiffDelete", "SpellRare"]
let s:mh_index = 0
function MyMatch(bang, mode) abort
" execute "normal" "*"
" return
if a:mode == "clear"
echom "all matches cleared"
call clearmatches()
return
endif
if a:mode == "cword"
let pattern = ""
else
let pattern = input("add a match:")
endif
if pattern == ""
let pattern = expand("<cword>")
endif
if a:bang
let pattern = '\<' . pattern . '\>'
endif
echo printf("\nmatching %s", pattern)
" redraw
call feedkeys("\<CR>")
let @/ = pattern
call matchadd(s:match_highlights[s:mh_index], pattern)
let s:mh_index = (s:mh_index + 1) % len(s:match_highlights)
endfunction
command! -nargs=? -bang Match call MyMatch(<bang>0, <q-args>)
nnoremap <M-*> <Cmd>Match clear<CR>
nnoremap <M-8> <Cmd>Match! cword<CR>
nnoremap <M-9> <Cmd>Match cword<CR>
command -nargs=1 Vsb call VsbFunction(<f-args>)
function VsbFunction (arg1)
execute 'vert sb' a:arg1
endfunction
" set formatoptions=
" https://github.com/vim/vim/issues/5200 for more?
" set t_TI=""
" set t_TE=""
inoremap <M-CR> <cmd>normal! $o <cr>
autocmd FileType markdown setl spell
" set spell
" See `man fzf-tmux` for available options
if exists('$TMUX')
let g:fzf_layout = { 'tmux': '-p90%,60%' }
else
let g:fzf_layout = { 'window': { 'width': 0.9, 'height': 0.6 } }
endif