-
Notifications
You must be signed in to change notification settings - Fork 2
/
init.vim
1321 lines (1139 loc) · 44.3 KB
/
init.vim
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
" ---------------------------------------------------------------------------
"
" Neovim Configuration
"
" ---------------------------------------------------------------------------
"
" Useful commands:
"
" :verbose set <var>? find where a setting was made
" :scriptnames list vimscripts loaded
" ---------------------------------------------------------------------------
" General
" ---------------------------------------------------------------------------
set hidden " easy buffer switching
set isk+=%,#,- " additional vim word characters
set cursorline " highlight current line
set modeline " make sure modeline support is enabled
set noerrorbells " quiet, please
set nofoldenable " disable folding
set complete+=i " complete filenames
set noshowmode " hide <INSERT>
filetype indent on " indent based on filetype
"set isk-=(,) " characters to remove from word list
" reduce keycode mapping timeout delay
set ttimeoutlen=5
set timeoutlen=500
" Mouse support
" https://github.com/neovim/neovim/wiki/Following-HEAD#20170403
set mouse=a
" Remap leader / localleader
let mapleader = ";"
let g:mapleader = ";"
let maplocalleader = ","
" Fast save/quit
nmap <leader>w :update<cr>
nmap <leader>q :q<cr>
nmap <leader>z :wq<cr>
" remap macro recording to Q
nnoremap Q q
nnoremap q <nop>
" home/end key tmux work-around
" https://github.com/neovim/neovim/issues/9012
inoremap <C-a> <Home>
inoremap <C-e> <End>
noremap <C-a> <Home>
noremap <C-e> <End>
" specify python installation to use
let g:python3_host_prog = '~/conda/bin/python3'
" ---------------------------------------------------------------------------
" vim-plug
" ---------------------------------------------------------------------------
call plug#begin()
" plugins
" Plug 'airblade/vim-gitgutter'
Plug 'andymass/vim-matchup'
Plug 'bfredl/nvim-ipy'
Plug 'burneyy/vim-snakemake'
Plug 'chrisbra/csv.vim'
Plug 'dense-analysis/ale'
Plug 'dylanaraps/wal.vim'
Plug 'drzel/vim-line-no-indicator'
Plug 'embark-theme/vim', { 'as': 'embark' }
Plug 'ervandew/supertab'
Plug 'guns/xterm-color-table.vim'
Plug 'henrik/vim-indexed-search'
Plug 'honza/vim-snippets'
Plug 'jalvesaq/Nvim-R'
Plug 'JuliaEditorSupport/julia-vim'
Plug 'fatih/vim-go'
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
Plug 'kshenoy/vim-signature'
Plug 'kana/vim-operator-user'
Plug 'MarcWeber/vim-addon-mw-utils'
Plug 'mboughaba/i3config.vim'
Plug 'mllg/vim-devtools-plugin'
Plug 'mzlogin/vim-markdown-toc'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'ncm2/float-preview.nvim'
Plug 'psf/black', { 'branch': 'stable' }
Plug 'raimon49/requirements.txt.vim'
Plug 'rrethy/vim-hexokinase', { 'do': 'make hexokinase' }
Plug 'romgrk/barbar.nvim'
Plug 'Shougo/denite.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'Shougo/neomru.vim'
Plug 'scrooloose/nerdcommenter'
" Plug 'sslivkoff/vim-scroll-barnacle'
Plug 'stephpy/vim-yaml'
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'tomtom/tlib_vim'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'wellle/targets.vim'
Plug 'wincent/terminus'
Plug 'xolox/vim-colorscheme-switcher'
Plug 'xolox/vim-misc'
Plug '/usr/share/vim/vimfiles'
" Plug 'qpkorr/vim-bufkill'
"Plug 'manabuishii/vim-cwl'
"Plug 'mrk21/yaml-vim'
"Plug 'plasticboy/vim-markdown'
" Plug 'majutsushi/tagbar'
"Plug 'zhaozg/vim-diagram'
"Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
"Plug 'tikhomirov/vim-glsl'
"Plug 'terryma/vim-expand-region'
"Plug 'gcavallanti/vim-noscrollbar'
"Plug 'ekiim/vim-mathpix'
Plug 'glts/vim-textobj-comment'
Plug 'kana/vim-textobj-user'
Plug 'tyru/vim-textobj-underscore', { 'branch': 'support-3-cases' }
"Plug 'vim-scripts/argtextobj.vim'
"Plug 'vimtaku/vim-textobj-keyvalue'
Plug 'agreco/vim-citylights'
Plug 'ayu-theme/ayu-vim'
Plug 'challenger-deep-theme/vim'
Plug 'connorholyday/vim-snazzy'
Plug 'cseelus/vim-colors-lucid'
Plug 'cseelus/vim-colors-tone'
Plug 'danilo-augusto/vim-afterglow'
Plug 'davidklsn/vim-sialoquent'
Plug 'dikiaap/minimalist'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'drewtempelmeyer/palenight.vim'
Plug 'Dru89/vim-adventurous'
Plug 'fcpg/vim-orbital'
Plug 'fenetikm/falcon'
Plug 'fmoralesc/molokayo'
Plug 'jacoborus/tender.vim'
Plug 'joshdick/onedark.vim'
Plug 'KeitaNakamura/neodark.vim'
Plug 'liuchengxu/space-vim-dark'
Plug 'lu-ren/SerialExperimentsLain'
Plug 'mhartington/oceanic-next'
Plug 'morhetz/gruvbox'
Plug 'NLKNguyen/papercolor-theme'
Plug 'rakr/vim-one'
Plug 'reedes/vim-colors-pencil'
Plug 'Rigellute/rigel'
Plug 'sheerun/vim-wombat-scheme'
Plug 'sonph/onehalf', {'rtp': 'vim/'}
Plug 'tyrannicaltoucan/vim-quantum'
Plug 'tyrannicaltoucan/vim-deep-space'
Plug 'vim-scripts/pyte'
Plug 'vim-scripts/summerfruit256.vim'
Plug 'whatyouhide/vim-gotham'
Plug 'wimstefan/Lightning'
Plug 'yuttie/hydrangea-vim'
Plug 'zanloy/vim-colors-grb256'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
"Plug 'bioSyntax/bioSyntax-vim'
"Plug 'chriskempson/base16-vim'
"Plug 'severin-lemaignan/vim-minimap'
"Plug 'yuttie/comfortable-motion.vim'
"Plug 'hkupty/iron.nvim'
"Plug 'hyiltiz/vim-plugins-profile'
"Plug 'troydm/zoomwintab.vim'
"Plug 'liuchengxu/vim-which-key', { 'on': ['WhichKey', 'WhichKey!'] }
"Plug 'davidoc/taskpaper.vim'
"Plug 'Shougo/neosnippet.vim'
"Plug 'Shougo/neosnippet-snippets'
"Plug 'freitass/todo.txt-vim'
"Plug 'Alok/notational-fzf-vim'
"Plug 'itchyny/lightline.vim'
"Plug 'mengelbrecht/lightline-bufferline'
"Plug 'deoplete-plugins/deoplete-jedi'
"Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
"Plug 'Shougo/deoplete-terminal'
"Plug 'vimwiki/vimwiki'
"Plug 'godlygeek/tabular'
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
"
" overrides filetype tabstop, etc. options
"Plug 'editorconfig/editorconfig-vim'
" conflicts with lightline-bufferline
"Plug 'nightsense/night-and-day'
" Requires +conceal feature not compiled in Arch
" Plug 'vim-pandoc/vim-pandoc'
" Plug 'vim-pandoc/vim-pandoc-syntax'
" Plug 'vim-pandoc/vim-rmarkdown'
" devicons should always be loaded last
Plug 'kyazdani42/nvim-web-devicons'
Plug 'ryanoasis/vim-devicons'
call plug#end()
" ----------------------------------------------------------------------------
" Vim Shortcut Helper
"
" TODO: create func to open markdown cheatsheet in sidepane / close
" the buffer if it is already open/visible..
" ----------------------------------------------------------------------------
" if bufwinnr("~/d/notes/linux/vim/cheatsheet.md") > 0
" echo "Already open"
" endif
" ----------------------------------------------------------------------------
" Backups
" ----------------------------------------------------------------------------
set backup " keep backups after close
set writebackup " keep a backup while working
set noswapfile " don't keep swp files
set backupdir=$HOME/.vim/tmp/backup " directory to store backups in
set backupcopy=yes " keep attributes of original file
set backupskip=/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*
" ----------------------------------------------------------------------------
" UI
" ----------------------------------------------------------------------------
set scrolloff=5 " keep cursor at least this far away from top/bottom
set sidescrolloff=1 " keep cursor this far from sides of screen
set wildignore=*.o,*~,*.pyc " ignore compiled files
set wildmode=longest,list " for filename completion, fill longest and list others
set ruler " show the cursor position all the time
set showcmd " show incomplete commands and selection info
set nolazyredraw " turn off lazy redraw
set number " line numbers
set whichwrap+=<,>,h,l,[,] " backspace and cursor keys wrap to
set shortmess=filtIoOA " shorten messages
set report=0 " tell us about changes
set nostartofline " don't jump to the start of line when scrolling
"set display+=lastline " don't hide long lines
" ----------------------------------------------------------------------------
" Visual Cues
" ----------------------------------------------------------------------------
set showmatch " brackets/braces that is
set mat=5 " duration to show matching brace (1/10 sec)
set colorcolumn=89 " show right margin
set novisualbell " no thank you
" ----------------------------------------------------------------------------
" Navigation
" ----------------------------------------------------------------------------
inoremap <M-h> <C-o>h
inoremap <M-j> <C-o>j
inoremap <M-k> <C-o>k
inoremap <M-l> <C-o>l
" ----------------------------------------------------------------------------
" Text Formatting
" ----------------------------------------------------------------------------
"disablign smart-indent: may be preventing comments from indenting?
"http://stackoverflow.com/questions/191201/indenting-comments-to-match-code-in-vim
"set smartindent " be smart about it
set nowrap " do not wrap lines
set softtabstop=4 " tab width
set shiftwidth=4
set shiftround " round indents to multiple of shift width
set tabstop=4
set expandtab " expand tabs to spaces
set smarttab
set textwidth=88 " stick to 88 characters or less, when possible
set formatoptions+=n " support for numbered/bullet lists
set virtualedit=block " allow virtual edit in visual block ..
set pastetoggle=<F6> " paste-mode toggle
" Shortuct to toggle textwidth wrapping
nmap <silent><localleader>r :call ToggleTextWidth()<CR>
function! ToggleTextWidth()
if &textwidth != 0
let b:oldtextwidth = &textwidth
set textwidth=0
elseif exists("b:oldtextwidth")
let &textwidth = b:oldtextwidth
else
set textwidth=99
endif
endfunction
" shortcut to insert a space in normal mode
nnoremap ss i<space><esc>
" ----------------------------------------------------------------------------
" Moving around, tabs, windows and buffers
" ----------------------------------------------------------------------------
" Treat long lines as break lines (useful when moving around in them)
map <silent> j gj
map <silent> k gk
" Use bufkill to preserve splits when closing buffers
" cabbrev bd BD
"map <C-w> :BD<cr>
" Quick buffer switching using tab / shift + arrow keys
" nnoremap <Tab> :bnext<CR>
" nnoremap <S-Tab> :bprev<CR>
" nnoremap <s-left> :bprev<CR>
" nnoremap <s-right> :bnext<CR>
" Switch to ]b and [b for improved coc.nvim support
" nnoremap [b :bprevious<CR>
" nnoremap ]b :bnext<CR>
" Close the current buffer
" map <leader>bd :BD<cr>
" Close all the buffers
map <leader>ba :1,1000 bd!<cr>
" Switch CWD to the directory of the open buffer
map <leader>cd :cd %:p:h<cr>:pwd<cr>
" Copy and comment current line
nmap zz yy<leader>ccp
vmap zz ygv<leader>cc`.jP
" Specify the behavior when switching between buffers
try
set switchbuf=useopen,usetab,newtab
set stal=2
catch
endtry
" create file under cursor
map <localleader>gf :e <cfile><cr>
" Return to last edit position when opening files
au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Save current view settings on a per-window, per-buffer basis.
function! AutoSaveWinView()
if !exists("w:SavedBufView")
let w:SavedBufView = {}
endif
let w:SavedBufView[bufnr("%")] = winsaveview()
endfunction
" Restore current view settings.
function! AutoRestoreWinView()
let buf = bufnr("%")
if exists("w:SavedBufView") && has_key(w:SavedBufView, buf)
let v = winsaveview()
let atStartOfFile = v.lnum == 1 && v.col == 0
if atStartOfFile && !&diff
call winrestview(w:SavedBufView[buf])
endif
unlet w:SavedBufView[buf]
endif
endfunction
" When switching buffers, preserve window view.
if v:version >= 700
autocmd BufLeave * call AutoSaveWinView()
autocmd BufEnter * call AutoRestoreWinView()
endif
" Remember info about open buffers on close
set viminfo^=%
" Enable cursor shape support
set guicursor=n-v-c:block-Cursor/lCursor-blinkon0,
\i-ci:ver25-Cursor/lCursor,
\r-cr:hor20-Cursor/lCursor
" Easier switching to normal mode
inoremap jk <Esc>
" Faster command execution
nnoremap ! :!
" Sloppyness is okay
cabbrev qw :wq
" ---------------------------------------------------------------------------
" Appearance
" ---------------------------------------------------------------------------
if $TERM != 'linux'
set t_Co=256
endif
" fix background bleeding in screen
" http://sunaku.github.io/vim-256color-bce.html
set t_ut=""
" enable true colors (disable for pywal support)
set termguicolors
if has("gui_running")
set guioptions-=m " remove menu bar
set guioptions-=T " remove toolbar
nnoremap <F11> :if &go=~#'m'<Bar>set go-=m<Bar>else<Bar>set go+=m<Bar>endif<CR>
nnoremap <F12> :if &go=~#'T'<Bar>set go-=T<Bar>else<Bar>set go+=T<Bar>endif<CR>
" font
set guifont=DejaVu\ Sans\ Mono\ for\ Powerline\ 12
" Make shift-insert work like in Xterm
map <S-Insert> <MiddleMouse>
map! <S-Insert> <MiddleMouse>
endif
" ---------------------------------------------------------------------------
" Copy and Paste
" ---------------------------------------------------------------------------
" Remap vim register to CLIPBOARD selection
" unnamed CLIPBOARD (shift-control v)
" unnamedplus PRIMARY (middlemouse)
" autoselect Automatically save visual selections
"set clipboard=unnamed,autoselect
"set clipboard=unnamed
" switching to unnamedplus to allow pasting to chromium, etc. in wayland
set clipboard^=unnamed,unnamedplus
" work-around to preserve yank buffer when pasting; the solution below first
" deletes selected text to an unused register
xnoremap p "_dP
" stay at last selected character after yanking text in visual mode
"
vmap y y`]
" paste from primary in normal mode
noremap <Leader>p "*p
noremap <Leader>P "*P
" ----------------------------------------------------------------------------
" Highlight Trailing Whitespace
" ----------------------------------------------------------------------------
"set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
highlight SpecialKey ctermfg=DarkGray ctermbg=Black
" ---------------------------------------------------------------------------
"
" CriticMarkup highlight
"
" ---------------------------------------------------------------------------
vmap <leader>l c<C-R>=substitute(@", '\v(.*)', '\{==\1==\}\{>><<\}', '')<ESC>
" ---------------------------------------------------------------------------
" Backup and undo
" ---------------------------------------------------------------------------
set undofile
set history=5000
set undolevels=200
set undodir=~/.vim/tmp/undo
" enable undo using c-u in insert mode
" http://vim.wikia.com/wiki/Recover_from_accidental_Ctrl-U
inoremap <c-u> <c-g>u<c-u>
" ---------------------------------------------------------------------------
" paste bug work-around
" https://github.com/neovim/neovim/issues/7994#issuecomment-388296360
" ---------------------------------------------------------------------------
nnoremap p p`]<Esc>
" insert blank line without entering insert mode
" nmap <c-o> O<Esc> " used to navigate jump list..
" nmap <CR> o<Esc>
" ---------------------------------------------------------------------------
" Strip all trailing whitespace in file
" ---------------------------------------------------------------------------
function! StripWhitespace ()
exec ':%s/ \+$//gc'
endfunction
map ,s :call StripWhitespace ()<CR>
" ----------------------------------------------------------------------------
" Scratchpad
" ----------------------------------------------------------------------------
function! AddScratchpadEntry ()
" find entries heading and move cursor to following line
exec ":normal /Entries/\<CR>"
normal! 2j
" add timestamp
" exec ":put=strftime('-%c-')"
exec ":put=strftime('-%b %d %Y %H:%M:%S-')"
" add new lines
call append(line("."), ["", "", ""])
" go down two lines
" exec ":normal "
call cursor(line('.') + 2, 1)
" enter insert mode
call feedkeys('A', 'n')
endfunction
" similar to above, but for adding simple timestamps to markdown files
function! AddTimeStamp ()
" go to top of file
normal! gg
" then find first empty line and go down one more line
exec ":normal /^$/\<CR>"
" add timestamp
exec ":put=strftime('**%b %d %Y**')"
" add new lines
call append(line("."), ["", "", ""])
" go down two lines
call cursor(line('.') + 2, 1)
" enter insert mode
call feedkeys('A', 'n')
" :startinsert!
endfunction
autocmd BufNewFile,BufRead s set syntax=scratch
autocmd BufNewFile,BufRead s set filetype=scratch
autocmd FileType scratch map <silent><leader>s :call AddScratchpadEntry ()<CR>
autocmd FileType markdown map <silent><leader>s :call AddTimeStamp()<CR>
" ---------------------------------------------------------------------------
" Search Options
" ---------------------------------------------------------------------------
set incsearch " do incremental searching
set wrapscan " search wrap around the end of the file
nohlsearch " avoid highlighting when reloading vimrc
" turn off highlighting
nnoremap <leader>n :nohl<CR>
" ---------------------------------------------------------------------------
" Tab completion
" ---------------------------------------------------------------------------
set infercase " case insensitive tab completion
set ignorecase " ignore case search
set smartcase " override 'ignorecase' if the search pattern contains upper case
" enable completion of filenames following '='
set isfname-==
" ---------------------------------------------------------------------------
" terminal
" ---------------------------------------------------------------------------
tnoremap <C-h> <C-\><C-n><C-w>h
tnoremap <C-j> <C-\><C-n><C-w>j
tnoremap <C-k> <C-\><C-n><C-w>k
tnoremap <C-l> <C-\><C-n><C-w>l
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" terminal cntl + arrow keys
tnoremap <C-Left> <m-b>
tnoremap <C-Right> <m-f>
" automatically enter insert mode
au BufWinEnter,WinEnter term://* startinsert
" Exclude terminal from buffer list
au TermOpen * set nobuflisted
au TermOpen * noremap <buffer> <tab> <nop>
au TermOpen * noremap <buffer> <s-tab> <nop>
" Disable terminal line numbers
au TermOpen * setlocal nonumber norelativenumber
" ---------------------------------------------------------------------------
"
" Scriptnames helper function
" https://vim.fandom.com/wiki/List_loaded_scripts
"
" ---------------------------------------------------------------------------
function! s:Scratch (command, ...)
redir => lines
let saveMore = &more
set nomore
execute a:command
redir END
let &more = saveMore
call feedkeys("\<cr>")
new | setlocal buftype=nofile bufhidden=hide noswapfile
put=lines
if a:0 > 0
execute 'vglobal/'.a:1.'/delete'
endif
if a:command == 'scriptnames'
%substitute#^[[:space:]]*[[:digit:]]\+:[[:space:]]*##e
endif
silent %substitute/\%^\_s*\n\|\_s*\%$
let height = line('$') + 3
execute 'normal! z'.height."\<cr>"
0
endfunction
command! -nargs=? Scriptnames call <sid>Scratch('scriptnames', <f-args>)
command! -nargs=+ Scratch call <sid>Scratch(<f-args>)
" ---------------------------------------------------------------------------
" airline
" ---------------------------------------------------------------------------
let g:airline_powerline_fonts = 1
let g:airline#extensions#ale#enabled = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#wordcount#enabled = 1
"let g:airline_theme = 'onedark'
" ---------------------------------------------------------------------------
" ale
" ---------------------------------------------------------------------------
" nmap <silent> <C-k> <Plug>(ale_previous_wrap)
" nmap <silent> <C-j> <Plug>(ale_next_wrap)
let g:ale_fixers = {'r': ['styler', 'trim_whitespace'], 'rmd': ['styler', 'trim_whitespace']}
let g:ale_r_lintr_options = "with_defaults(line_length_linter(100),single_quotes_linter=NULL,commented_code_linter=NULL,object_name_linter=NULL,object_usage_linter=NULL)"
" ---------------------------------------------------------------------------
" barbar.nvim
" ---------------------------------------------------------------------------
nnoremap <silent> <leader>bd :BufferClose<CR>
nnoremap <silent> <S-Tab> :BufferPrevious<CR>
nnoremap <silent> <Tab> :BufferNext<CR>
nnoremap <silent> <S-left> :BufferPrevious<CR>
nnoremap <silent> <S-right> :BufferNext<CR>
" ---------------------------------------------------------------------------
" black
" ---------------------------------------------------------------------------
"au BufWritePre *.py execute ':Black'
" ---------------------------------------------------------------------------
" csv.vim
" ---------------------------------------------------------------------------
let g:csv_no_conceal = 1
" ---------------------------------------------------------------------------
" coc.nvim
" ---------------------------------------------------------------------------
" disable backups (may be neccessary...)
" https://github.com/neoclide/coc.nvim/issues/649
" setlocal nobackup
" setlocal nowritebackup
" Better display for messages
" set cmdheight=2
"
" " You will have bad experience for diagnostic messages when it's default 4000.
" set updatetime=300
"
" " don't give |ins-completion-menu| messages.
" set shortmess+=c
"
" " always show signcolumns
" set signcolumn=yes
"
" " if nvm is set to lazy-load via zplugin, path will need to be manually specified
" "let g:coc_node_path="/home/keith/.nvm/versions/node/v12.9.1/bin/node"
"
" " extensions to install
" let g:coc_global_extensions = ['coc-r-lsp']
"
" " Use tab for trigger completion with characters ahead and navigate.
" inoremap <silent><expr> <TAB>
" \ pumvisible() ? "\<C-n>" :
" \ <SID>check_back_space() ? "\<TAB>" :
" \ coc#refresh()
" inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
"
" function! s:check_back_space() abort
" let col = col('.') - 1
" return !col || getline('.')[col - 1] =~# '\s'
" endfunction
"
" " Use <c-space> to trigger completion.
" inoremap <silent><expr> <c-space> coc#refresh()
"
" " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
" " Coc only does snippet and additional edit on confirm.
" inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
"
" " Also allow confirmation using <TAB>
" inoremap <expr> <TAB> pumvisible() ? "\<C-y>" : "\<C-g>u\<TAB>"
"
" " Or use `complete_info` if your vim support it, like:
" " inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
"
" " Use `[g` and `]g` to navigate diagnostics
" nmap <silent> [g <Plug>(coc-diagnostic-prev)
" nmap <silent> ]g <Plug>(coc-diagnostic-next)
"
" " Remap keys for gotos
" nmap <silent> gd <Plug>(coc-definition)
" nmap <silent> gy <Plug>(coc-type-definition)
" nmap <silent> gi <Plug>(coc-implementation)
" nmap <silent> gr <Plug>(coc-references)
"
" " Use K to show documentation in preview window
" nnoremap <silent> K :call <SID>show_documentation()<CR>
"
" function! s:show_documentation()
" if (index(['vim','help'], &filetype) >= 0)
" execute 'h '.expand('<cword>')
" else
" call CocAction('doHover')
" endif
" endfunction
"
" " Highlight symbol under cursor on CursorHold
" " 2020-01-28: disabled for now due to conflict with coc-r-lsp
" " autocmd CursorHold * silent call CocActionAsync('highlight')
"
" " Remap for rename current word
" nmap <leader>rn <Plug>(coc-rename)
"
" " Remap for format selected region
" xmap <leader>f <Plug>(coc-format-selected)
" nmap <leader>f <Plug>(coc-format-selected)
"
" augroup mygroup
" autocmd!
" " Setup formatexpr specified filetype(s).
" autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected')
" " Update signature help on jump placeholder
" autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
" augroup end
"
" " Remap for do codeAction of selected region, ex: `<leader>aap` for current paragraph
" xmap <leader>a <Plug>(coc-codeaction-selected)
" nmap <leader>a <Plug>(coc-codeaction-selected)
"
" " Remap for do codeAction of current line
" nmap <leader>ac <Plug>(coc-codeaction)
" " Fix autofix problem of current line
" nmap <leader>qf <Plug>(coc-fix-current)
"
" " Create mappings for function text object, requires document symbols feature of languageserver.
" xmap if <Plug>(coc-funcobj-i)
" xmap af <Plug>(coc-funcobj-a)
" omap if <Plug>(coc-funcobj-i)
" omap af <Plug>(coc-funcobj-a)
"
" " Use <TAB> for select selections ranges, needs server support, like: coc-tsserver, coc-python
" nmap <silent> <TAB> <Plug>(coc-range-select)
" xmap <silent> <TAB> <Plug>(coc-range-select)
"
" " Use `:Format` to format current buffer
" command! -nargs=0 Format :call CocAction('format')
"
" " Use `:Fold` to fold current buffer
" command! -nargs=? Fold :call CocAction('fold', <f-args>)
"
" " use `:OR` for organize import of current buffer
" command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
"
" " Add status line support, for integration with other plugin, checkout `:h coc-status`
" set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')}
"
" " Using CocList
" " Show all diagnostics
" nnoremap <silent> <space>a :<C-u>CocList diagnostics<cr>
" " Manage extensions
" nnoremap <silent> <space>e :<C-u>CocList extensions<cr>
" " Show commands
" nnoremap <silent> <space>c :<C-u>CocList commands<cr>
" " Find symbol of current document
" nnoremap <silent> <space>o :<C-u>CocList outline<cr>
" " Search workspace symbols
" nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr>
" " Do default action for next item.
" nnoremap <silent> <space>j :<C-u>CocNext<CR>
" " Do default action for previous item.
" nnoremap <silent> <space>k :<C-u>CocPrev<CR>
" " Resume latest coc list
" nnoremap <silent> <space>p :<C-u>CocListResume<CR>
" ---------------------------------------------------------------------------
" vim-hexokinase
" ---------------------------------------------------------------------------
"let g:Hexokinase_highlighters = ['backgroundfull']
let g:Hexokinase_highlighters = ['sign_column']
" ---------------------------------------------------------------------------
" colorscheme-switcher.vim
" ---------------------------------------------------------------------------
let g:colorscheme_switcher_exclude = [
\ 'blue', 'darkblue', 'default', 'delek', 'desert', 'elflord',
\ 'evening', 'fi', 'gotham256', 'industry', 'koehler', 'morning',
\ 'murphy', 'pablo', 'peachpuff', 'ron', 'shine', 'slate',
\ 'torte', 'zellner']
" ---------------------------------------------------------------------------
" deoplete
" ---------------------------------------------------------------------------
"
" key bindings:
"
" tab next
" c-n next
" c-p prev
" c-y select
"
"
" abbreviations:
"
" [↑] after cursor
" [↓] before cursor
" [*] in changes
" [F] file
" [T] tag
" [ns] neosnippet
"
"
" TODO: normalize behavior between zsh + fzf and deoplete
"
" 1. autocomplete expressions upon <tab> when only a single match exists
" 2. include relative filepaths without having to include prefix "./"
" 3. don't include typed expression at all (currently cycles through it, even though
" it's not displayed..)
" 4. automatically insert first match upon opening deoplete menu; currently
" insertion only occurs upon cycling of completion choices.
" 5. automatically refresh completion candidates after additional characters are typed.
" 6. When entering a filepath, exclude all other completions (can just <tab> expand
" filepath very quickly that way, esp. if only one sub-dir at each level..)
" enable at start-up
"let g:deoplete#enable_at_startup = 1
" only show popup upon request
"let g:deoplete#disable_auto_complete = 1
" call deoplete#custom#var('around', {
" \ 'range_above': 25,
" \ 'range_below': 25,
" \ 'mark_above': '[↑]',
" \ 'mark_below': '[↓]',
" \ 'mark_changes': '[*]',
" \})
" number of results to show
" call deoplete#custom#option({'max_list': 10})
" use <tab> / <s-tab> to cycle through completions
" function! s:check_back_space() abort "{{{
" let col = col('.') - 1
" return !col || getline('.')[col - 1] =~ '\s'
" endfunction"}}}
" inoremap <silent><expr> <TAB>
" \ pumvisible() ? "\<C-n>" :
" \ <SID>check_back_space() ? "\<TAB>" :
" \ deoplete#manual_complete()
"
" inoremap <silent><expr><S-TAB> pumvisible() ? "\<C-p>" : "\<S-TAB>"
"
" " automatically select the first match
" set completeopt+=noinsert
"
" " don't insert a newline when selecting with <Enter>
" inoremap <expr> <CR> (pumvisible() ? "\<c-y>" : "\<CR>")
"
" " matchers
" " head - exact matches
" " length - don't show typed word
" call deoplete#custom#source('_', 'matchers', ['matcher_head', 'terminal', 'matcher_length'])
"
" " sort results alphabetically
" call deoplete#custom#source('_', 'sorters', ['sorter_word'])
"
" " disable the candidates in Comment/String syntaxes.
" call deoplete#custom#source('_', 'disabled_syntaxes', ['Comment', 'String'])
"
" " prioritize file matches when present
" call deoplete#custom#source('file', 'rank', 9999)
"
" " disable buffer source
" let g:deoplete#ignore_sources = {}
" let g:deoplete#ignore_sources._ = ['buffer']
"
" " shortcuts
" call deoplete#custom#option('candidate_marks', ['A', 'S', 'D', 'F', 'G'])
" inoremap <expr><m-a> deoplete#insert_candidate(0)
" inoremap <expr><m-s> deoplete#insert_candidate(1)
" inoremap <expr><m-d> deoplete#insert_candidate(2)
" inoremap <expr><m-f> deoplete#insert_candidate(3)
" inoremap <expr><m-g> deoplete#insert_candidate(4)
" ---------------------------------------------------------------------------
" float-preview.nvim
" ---------------------------------------------------------------------------
let g:float_preview#docked = 1
" ---------------------------------------------------------------------------
" gitgutter
" ---------------------------------------------------------------------------
let g:gitgutter_async = 1
let g:gitgutter_eager = 0
let g:gitgutter_enabled = 1
let g:gitgutter_highlight_lines = 0
let g:gitgutter_map_keys = 1
let g:gitgutter_max_signs = 1000
let g:gitgutter_diff_args = '--ignore-all-space'
" ---------------------------------------------------------------------------
" indent guides
" ---------------------------------------------------------------------------
let g:indent_guides_auto_colors = 0
let g:indent_guides_auto_colors = 1
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
" ---------------------------------------------------------------------------
" julia-vim
" ---------------------------------------------------------------------------
" autocmd BufNewFile,BufRead *.jl set syntax=julia
" ---------------------------------------------------------------------------
" NERDcommenter
" ---------------------------------------------------------------------------
let g:NERDDefaultAlign = 'left'
let g:NERDSpaceDelims = 1
let g:NERDCommentEmptyLines = 1
let g:NERDTrimTrailingWhitespace = 1
let g:NERDCustomDelimiters = {
\ 'snakemake' : { 'left': '#' },
\ 'rmd': { 'left': '#' }
\ }
" disabled sept 7, 2020 (nvim-ipy compat)
" nmap <space> <leader>c<space>
" vmap <space> <leader>c<space>
" ---------------------------------------------------------------------------
" night-and-day
" ---------------------------------------------------------------------------
let g:nd_themes = [
\ ['04:00', 'PaperColor', 'light' , 'PaperColor' ],
\ ['11:00', 'quantum', 'dark', 'quantum'],
\ ]
let g:nd_lightline = 1
" ---------------------------------------------------------------------------
" notational-fzf-vim
" ---------------------------------------------------------------------------
"let g:nv_use_short_pathnames = 1
" let g:nv_search_paths = ['~/d/notes', './doc']
" let g:nv_search_paths = ['~/d/notes']
" let g:nv_ignore_pattern = ['personal', 'meetings']
" let g:nv_default_extension = '.md'
" nnoremap <silent> <c-y> :NV<CR>
" ---------------------------------------------------------------------------
" vim-markdown
" ---------------------------------------------------------------------------
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_frontmatter = 1
let g:vim_markdown_toc_autofit = 1
let g:vim_markdown_strikethrough = 1
let g:vim_markdown_math = 1
" au BufNewFile,BufRead *.md set filetype=markdown nofoldenable
au BufNewFile,BufRead *.md set conceallevel=2
" replace tagbar binding
" au FileType markdown nmap <F9> :Toc<CR>
" au FileType markdown imap <F9> :Toc<CR>
" override default conceal colors
syntax match Normal /\*/ conceal cchar=∗
" italic latex work-around
" https://stackoverflow.com/a/34645680/554531
syn region math start=/\$\$/ end=/\$\$/
" inline math
syn match math '\$[^$].\{-}\$'
" actually highlight the region we defined as "math"