-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
1219 lines (891 loc) · 32.7 KB
/
vimrc
File metadata and controls
1219 lines (891 loc) · 32.7 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
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
" vim:foldmethod=expr:foldlevel=0:foldexpr=MDFold(v\:lnum):foldtext=FoldText()
" # File Help
"
" Tips to navigate this file
" -----------------------------------------------------------------------------
" ----------+-----------------------------------
" Command | Description
" ----------+-----------------------------------
" zo | Open fold under cursor
" zc | Close fold under cursor
" zR | Open all folds
" zM | Close all folds
" :help zo | More help
" # Preamble
" -----------------------------------------------------------------------------
" This vimrc file depends on Vundle (https://github.com/VundleVim/Vundle.vim)
" Before using it, you'll need to clone vundle to your .vim folder:
"
" $ git clone https://github.com/VundleVim/Vundle.vim.git \
" ~/.vim/bundle/Vundle.vim
"
" After updating this vimrc with new plugins (or the first time vim is run with
" this vimrc) you'll need to update the plugins. Inside vim run:
"
" :PluginInstall
"
" To remove unused plugins run:
" :PluginClean
"
" Must be first line !!!!
set nocompatible " disable Vi compatible mode (must be first line!!!)
" For homebrewed (neo)vim, do it uses the python it was installed with,
" regardelss of the active (virtual)env
let g:python_host_prog = '/usr/local/bin/python'
let g:python3_host_prog = '/usr/local/bin/python3'
" ## OS specific stuff
" to do platform specific configs
let os = substitute(system('uname'), "\n", "", "")
" " for example
" if os == "Darwin"
" " Do OS X stuff.
" nnoremap <M-{> gT
" nnoremap <M-}> gt
" elseif os == "Linux"
" " Do Linux-specific stuff.
" nnoremap <S-h> gT
" nnoremap <S-l> gt
" else
" " Do Linux-specific stuff.
" nnoremap <S-h> gT
" nnoremap <S-l> gt
" endif
" # Plugins
" -----------------------------------------------------------------------------
" Install vim-plug if not present
" (Vim version)
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
" Install vim-plug if not present
" (NVim version)
if empty(glob('~/.config/nvim/autoload/plug.vim'))
silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall
endif
" vim-plug will handle plugins
call plug#begin('~/.vim/bundle')
" To access help for vim-plug itself
Plug 'maxbrunsfeld/vim-yankstack'
Plug 'junegunn/vim-plug'
" General purpose plugins
""""""""""""""""""""""""""""""""""""""""
" Currently being evaluated
""""""""""""""""""""""""""""""""""""""""
Plug 'terryma/vim-expand-region'
" Visualize undo tree
Plug 'mbbill/undotree'
""""""""""""""""""""""""""""""""""""""""
" Approved plugins
""""""""""""""""""""""""""""""""""""""""
" Plug 'tpope/vim-fugitive'
Plug 'scrooloose/nerdtree', { 'on': ['NERDTreeToggle', 'NERDTreeFind'] } "Loads only when opening NERDTree
" Plug 'scrooloose/nerdcommenter'
Plug 'godlygeek/tabular'
Plug 'w0rp/ale'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-obsession'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-abolish'
Plug 'airblade/vim-gitgutter'
Plug 'junegunn/goyo.vim'
Plug 'severin-lemaignan/vim-minimap'
Plug 'sirver/ultisnips'
" Ultisnippets are separated from the engine. Add this if you want them:
Plug 'honza/vim-snippets'
Plug 'itchyny/vim-gitbranch'
Plug 'itchyny/lightline.vim'
Plug 'maximbaz/lightline-ale'
Plug 'gerw/vim-HiLinkTrace'
Plug 'majutsushi/tagbar'
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
Plug 'danro/rename.vim'
" Simple buffer explorer
Plug 'jeetsukumaran/vim-buffergator'
Plug 'bling/vim-bufferline'
" File coloring
Plug 'tiagofumo/vim-nerdtree-syntax-highlight', { 'on': ['NERDTreeToggle', 'NERDTreeFind'] } "Loads only when opening NERDTree
" Plug 'ryanoasis/vim-devicons', { 'on': ['NERDTreeToggle', 'NERDTreeFind'] } "Loads only when opening NERDTree
" Google's code formatting tools
Plug 'google/vim-maktaba'
Plug 'google/vim-codefmt'
Plug 'google/vim-glaive'
" expanded targets and text objects. See
" http://owen.cymru/vim-text-objects-extend-vims-natural-language-2/
Plug 'wellle/targets.vim'
Plug 'kana/vim-textobj-user'
Plug 'kana/vim-textobj-function'
Plug 'kana/vim-textobj-indent'
Plug 'sgur/vim-textobj-parameter'
Plug 'bps/vim-textobj-python'
Plug 'libclang-vim/vim-textobj-clang'
" Plug 'poetic/vim-textobj-javascript' " this one doesn't seem to work
Plug 'thinca/vim-textobj-function-javascript'
" Markdown
Plug 'plasticboy/vim-markdown'
Plug 'JamshedVesuna/vim-markdown-preview'
" Python
Plug 'Vimjas/vim-python-pep8-indent'
" Plug 'tmhedberg/SimpylFold'
" Other languages
Plug 'motus/pig.vim'
Plug 'honza/dockerfile.vim'
" HTML, Javascript, Jinja, etc.
Plug 'pangloss/vim-javascript'
Plug 'othree/html5.vim'
Plug 'othree/html5-syntax.vim'
" Plug 'moll/vim-node'
" Plug 'mxw/vim-jsx'
Plug 'Glench/Vim-Jinja2-Syntax'
Plug 'maksimr/vim-jsbeautify'
" C/C++
Plug 'rhysd/vim-clang-format'
" GoLang
Plug 'fatih/vim-go'
" LaTeX
Plug 'lervag/vimtex'
Plug 'matze/vim-tex-fold'
" Neo4j / Cypher
" Plug 'neo4j-contrib/cypher-vim-syntax'
" CSS, SASS, Stylus, etc
Plug 'ap/vim-css-color'
" Plug 'chrisbra/Colorizer'
Plug 'wavded/vim-stylus'
" TOML syntax
Plug 'cespare/vim-toml'
" Last but not least
Plug 'jorgehatccrma/vim-cheerful'
" " Brief help
" " :PlugList - lists configured plugins
" " :PlugInstall - installs plugins; append `!` to update or just
" " :PlugUpdate
" " :PlugSearch foo - searches for foo; append `!` to refresh local cache
" " :PlugClean - confirms removal of unused plugins; append `!` to
" " auto-approve removal
" "
" " see :h vundle for more details or wiki for FAQ
" vim-plug surrenders control now
call plug#end()
" " Put your non-Plugin stuff after this line
" ## Plugin configs
" Add plugin customizations/configurations here
" " ### Powerline
" let g:Powerline_symbols = 'fancy'
" set laststatus=2
" call Pl#Theme#RemoveSegment('fileencoding')
" call Pl#Theme#RemoveSegment('fileformat')
"
" ### NERDTree
" file browser mapped to \p
nmap <silent> <Leader>p :execute "NERDTreeToggle" getcwd()<CR>
" hightlight current file on the tree
nmap <Leader>f :NERDTreeFind<CR>
" Hide certain files and folders
let NERDTreeIgnore=[
\ '__pycache__$[[dir]]',
\ '\.pyc$[[file]]',
\ ]
" ### NERDCommenter
" let g:NERDDefaultAlign = 'left'
" " let g:NERDDefaultAlign = 'start'
" " add extrace space after comment character, for every language
" let NERDSpaceDelims = 1
" " change comment character for .ini files
" let g:NERDCustomDelimiters = {
" \ 'text': { 'left': '#'},
" \ 'python': { 'left': '#', 'leftAlt': '#' },
" \ }
" if has("autocmd")
" augroup Comments
" autocmd FileType * let g:NERDDefaultAlign='left'
" autocmd FileType dosini let g:NERDDefaultAlign='start'
" augroup END
" endif
" ### Markdown
" Disable plasticboy/vim-markdown's folding
let g:vim_markdown_folding_disable = 1
" ### Mardown preview
" use grip (i.e. GitHub flavored markdown, I think)
let g:vim_markdown_preview_github=1
let g:vim_markdown_preview_hotkey='<C-m>'
let vim_markdown_preview_browser='Google Chrome'
" let vim_markdown_preview_browser='Opera'
" ### Minimap
let g:minimap_toggle='<leader>mm'
" ### ALE
" Specify linters for specific languages (other languages will use all availbale
" linters
" let g:ale_linters = { 'python': ['flake8', ], }
let g:ale_linters = {
\ 'python': ['pylint', 'flake8'],
\ 'javascript': ['prettier_eslint'],
\}
" let g:ale_fixers = { 'python': ['yapf', ], }
let g:ale_fixers = {
\ 'python': ['yapf', 'autopep8'],
\ 'javascript': ['prettier'],
\ 'css': ['prettier'],
\ 'json': ['fixjson'],
\}
" for the JS/CSS fixer and linter, you'll need to run these commands:
" `npm install --global prettier`
" `npm install --global prettier-eslint-cli`
let g:ale_python_flake8_options = '--ignore=E402'
" Better message format
let g:ale_echo_msg_error_str = 'E'
let g:ale_echo_msg_warning_str = 'W'
let g:ale_echo_msg_format = '[%linter%] %code:% %s [%severity%]'
" let g:ale_sign_error = ''
let g:ale_sign_error = ''
" let g:ale_sign_error = ''
" let g:ale_sign_error = '✗'
" let g:ale_sign_error = ''
" let g:ale_sign_warning = ''
" let g:ale_sign_warning = ''
" let g:ale_sign_warning = ''
" let g:ale_sign_warning = ''
let g:ale_sign_warning = ''
" let g:ale_sign_warning = ''
" let g:ale_sign_warning = 'ﬤ'
" let g:ale_sign_warning = ''
" let g:ale_sign_warning = ''
" let g:ale_sign_warning = '⚠'
" Add new mappings (this will override some default vim-unimpaired mappings
" I don't really use
let g:nremap = {"[a": "", "]a": ""}
noremap [a :ALEPreviousWrap<CR>
noremap ]a :ALENextWrap<CR>
let g:ale_fix_on_save = 1
" ### Lightline
set noshowmode
set laststatus=2
" \ 'separator': { 'left': '', 'right': '' },
" \ 'subseparator': { 'left': '', 'right': '│'},
let g:lightline = {
\ 'colorscheme': 'wombat',
\ 'separator': { 'left': '', 'right': '' },
\ 'subseparator': { 'left': '┆', 'right': '┆'},
\ 'component_function': {
\ 'gitbranch': 'LightlineGitBranch',
\ 'filename': 'LightlineFilename',
\ 'modified': 'LightlineModified',
\ 'mode': 'LightlineMode',
\ 'filetype': 'LightlineFiletype',
\ 'fileencoding': 'LightlineFileencoding',
\ 'fileformat': 'LightlineFileformat',
\ },
\ 'active': {
\ 'left': [
\ ['mode', 'paste'],
\ ['linter_checking', 'linter_errors', 'linter_warnings', 'linter_ok'],
\ ['readonly', 'gitbranch', 'filename'],
\ ],
\ 'right': [
\ ['modified'],
\ ['filetype', 'fileencoding','fileformat', 'lineinfo']
\ ],
\ },
\ 'inactive': {
\ 'left': [[], ['filename']],
\ 'right': [[], ['lineinfo']],
\ },
\ 'tabline_separator': {
\ 'left': '???',
\ 'right': '!!!',
\ }
\ }
" Adding ALE to lightline via lightline-ale plugin
let g:lightline.component_expand = {
\ 'linter_checking': 'lightline#ale#checking',
\ 'linter_warnings': 'lightline#ale#warnings',
\ 'linter_errors': 'lightline#ale#errors',
\ 'linter_ok': 'lightline#ale#ok',
\ }
let g:lightline.component_type = {
\ 'linter_checking': 'ALEchecking',
\ 'linter_warnings': 'ALEwarning',
\ 'linter_errors': 'ALEerror',
\ 'linter_ok': 'ALEok',
\ }
" Use FontAwesome icons
" let g:lightline#ale#indicator_warnings = "\uf071"
" let g:lightline#ale#indicator_errors = "\uf05e"
" let g:lightline#ale#indicator_ok = "\uf00c"
" let g:lightline#ale#indicator_checking = "\uf110"
let g:lightline#ale#indicator_warnings = ' '
let g:lightline#ale#indicator_errors = ' '
let g:lightline#ale#indicator_ok = " "
" let g:lightline#ale#indicator_ok = " "
" let g:lightline#ale#indicator_checking = " ..."
let g:lightline#ale#indicator_checking = "嗢..."
" let g:lightline#ale#indicator_checking = " "
" let g:lightline#ale#indicator_checking = " "
function! LightlineFilename()
" let fname = winwidth(0) > 120 ? expand('%:p') : expand('%:t')
let fname = winwidth(0) > 120 ? expand('%:f') : expand('%:t')
let nr = bufnr('')
return nr . ":" . fname
endfunction
function! LightlineModified()
return &mod ? ' ' : ''
endfunction
let s:special_filetypes = ['help', 'vundle', 'nerdtree', 'vim-minimap']
function! LightlineMode()
if index(s:special_filetypes, &filetype) >= 0
return ''
endif
return lightline#mode()
endfunction
function! LightlineFiletype()
if index(s:special_filetypes, &filetype) >= 0
return ''
endif
return &ft !=# "" ? &ft : "no ft"
endfunction
function! LightlineFileencoding()
if index(s:special_filetypes, &filetype) >= 0
return ''
endif
return &fenc !=# "" ? &fenc : &enc
endfunction
function! LightlineFileformat()
if index(s:special_filetypes, &filetype) >= 0
return ''
endif
return &ff
endfunction
function! LightlineGitBranch()
if index(s:special_filetypes, &filetype) >= 0
return ''
endif
let bname = gitbranch#name()
if bname ==? ''
return ''
endif
return ' ' . bname
endfunction
" ### UltiSnips
" Custom snippets location
let g:UltiSnipsSnippetsDir = '~/.vim/UltiSnips'
" use google style docstrings
let g:ultisnips_python_style = "google"
" ### Bufferline
" custom highlight groups to integrate with vim-airline/theme/cheerfully*
" let g:bufferline_active_highlight = 'Float'
" let g:bufferline_inactive_highlight = 'String'
" let g:bufferline_active_highlight = 'ActiveBuffer'
" let g:bufferline_inactive_highlight = 'InactiveBuffer'
" ### Buffergator
" Remove buffergator key mappings
let g:buffergator_suppress_keymaps = 1
" replace buffer gator's default Open mapping with Toggle
map <Leader>b :BuffergatorToggle<CR>
" ### Tagbar
" set focus to TabBar automatically
let g:tagbar_autofocus = 1
" toggle tag bar
nmap <Leader>tb :TagbarToggle<CR>
" ### AutoPairs
" to wrap the whole word if right next to one
" This might need to be wrapped in the OS X specifi section, but need testing
" over ssh AND locally in a linux box
let g:AutoPairsShortcutFastWrap = '<ESC>e'
" ### Clang-format
" let g:clang_format#code_style = 'llvm'
" let g:clang_format#code_style = 'google'
let g:clang_format#code_style = 'chromium'
" let g:clang_format#code_style = 'mozilla'
let g:clang_format#command = 'clang-format-3.8'
" detect a .clang-format
let g:clang_format#detect_style_file = 1
let g:javascript#command = 'js-beautify'
" ### Indentation disaproval
" let g:LookOfDisapprovalTabTreshold=5
" let g:LookOfDisapprovalSpaceTreshold=(&tabstop*5)
" ### LaTeX
" " From vim-latex documentation
" " IMPORTANT: grep will sometimes skip displaying the file name if you
" " search in a singe file. This will confuse Latex-Suite. Set your grep
" " program to always generate a file-name.
" set grepprg=grep\ -nH\ $*
" " OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" " 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" " The following changes the default filetype back to 'tex':
" let g:tex_flavor='latex'
" for vimtex
let g:vimtex_compiler_latexmk = {
\ 'continuous' : 1,
\ 'executable' : 'latexmk',
\ 'options' : [
\ '-pdf',
\ '-verbose',
\ '-file-line-error',
\ '-synctex=1',
\ '-interaction=nonstopmode',
\ ],
\}
" ### Goyo
" changing from the default 80
let g:goyo_width = 100
" ### VimTex
if has('nvim')
let g:vimtex_compiler_progname='nvr'
end
" ### NerdTreeSyntax Highlight
" highlight full name (not only icons, which I'm not currently using)
let g:NERDTreeFileExtensionHighlightFullName = 1
let g:NERDTreeExactMatchHighlightFullName = 1
let g:NERDTreePatternMatchHighlightFullName = 1
" add new file extensions/change existing color mappings
let g:NERDTreeExactMatchHighlightColor = {} " this line is needed to avoid error
let g:NERDTreeExactMatchHighlightColor['.gitignore'] = "999999"
let g:NERDTreePatternMatchHighlightColor = {} " this line is needed to avoid error
let g:NERDTreePatternMatchHighlightColor['.*\.tfrecords$'] = "3F51B5"
let g:NERDTreePatternMatchHighlightColor = {} " this line is needed to avoid error
let g:NERDTreePatternMatchHighlightColor['.*\.sh$'] = "EA80FC"
" ### Undotree
nnoremap <Leader>u :UndotreeToggle<CR>
" ### Yankstack
" nmap <leader>p <Plug>yankstack_substitute_older_paste
" nmap <leader>P <Plug>yankstack_substitute_newer_paste
" Force loading YanStack asap, to avoid overriding my custom `S` mapping
" (similar to https://github.com/maxbrunsfeld/vim-yankstack/issues/9)
call yankstack#setup()
" ### Fzf
" This is the default extra key bindings
let g:fzf_action = {
\ 'ctrl-t': 'tab split',
\ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
" Default fzf layout
" - down / up / left / right
let g:fzf_layout = { 'down': '~40%' }
" Customize fzf colors to match your color scheme
let g:fzf_colors =
\ { 'fg': ['fg', 'Statement'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'VimVar'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'String'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Identifier'],
\ 'marker': ['fg', 'Statement'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
" Enable per-command history.
" CTRL-N and CTRL-P will be automatically bound to next-history and
" previous-history instead of down and up. If you don't like the change,
" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS.
let g:fzf_history_dir = '~/.local/share/fzf-history'
" ### Vim Expand Region
map <M-+> <Plug>(expand_region_expand)
map <M-_> <Plug>(expand_region_shrink)
" ### Git Gutter
" enable line highlighting by default
let g:gitgutter_highlight_lines = 1
map <leader>g :GitGutterToggle<CR>
" ### Vim-commentary
autocmd FileType text setlocal commentstring=#\ %s
" # Basics
" set timeoutlen=500 " max delay (ms) between multy key-stroke commands
" Time out on key codes but not mappings.
" Basically this makes terminal Vim work sanely.
set notimeout
set ttimeout
set ttimeoutlen=100
set wrap linebreak " Soft wrapping without line breaks
set encoding=utf-8 " Default encoding
set backspace=indent,eol,start " Make backspace behave like other apps
set autoread " Reload files written outside Vim
" autoindent (see :help smartindent for more)
set autoindent
set smartindent
set cindent
" keep soft wrapping but prevent inserting line breaks on insert mode when
" going over text width
set formatoptions-=t
" treat all numerals as decimal (otherwise, using <C-a> on 007 will yield 010,
" as numbers preceeded by 0 are considered octal numbers
set nrformats=
" Make Vim able to edit crontab files again.
set backupskip=/tmp/*,/private/tmp/*"
" read the help for this one (currently experimenting with it)
set ttyfast
" use different ctags filenames
set tags=./tags,./.tags,tags,.tags;
" ## Backup, undo, swap and session files
set backup
set noswapfile
" Persistent undo
set undofile
set undolevels=1000
set undoreload=10000
set undodir=~/.vim/tmp/undo// " undo files
set backupdir=~/.vim/tmp/backup// " backups
set directory=~/.vim/tmp/swap// " swap files
set viewdir=~/.vim/tmp/views// " window views (see :h :mkview)
" Make those folders automatically if they don't already exist.
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), "p")
endif
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), "p")
endif
if !isdirectory(expand(&viewdir))
call mkdir(expand(&viewdir), "p")
endif
" ## Invisible chars
set nolist " don't display invisible characters in listchars
" list of characters to show in list mode (:set list)
set listchars=tab:▸\ ,eol:↵,extends:❯,precedes:❮
set showbreak=↪\ " prefix wrapped lines with this character (see `:set wrap`)
" toogle list chars (tabs, returns, etc.)
nnoremap <Leader>hh :set list!<CR>
" # Colors
" -----------------------------------------------------------------------------
set t_Co=256 " Explicitly tell vim that the terminal supports 256 colors
set t_ut= " fixes background incompatibility between vim and tmux
" general color theme
let g:bolero#maincolor = 'Light Blue'
" let g:bolero#maincolor = 'Deep Orange'
colorscheme bolero_dark
let g:lightline.colorscheme = 'bolero'
if has('termguicolors') && $TERM_PROGRAM ==# 'iTerm.app'
" set t_8f=^[[38;2;%lu;%lu;%lum
" set t_8b=^[[48;2;%lu;%lu;%lum
set termguicolors
endif
" ## Mappings
" dark/light color scheme
" nmap <Leader>chd :colorscheme cheerfully_dark<CR>
" nmap <Leader>chl :colorscheme cheerfully_light<CR>
" or more convenient, toggle between them
nmap <Leader>C :call Cheers()<CR>
" # Spaces And Tabs
" -----------------------------------------------------------------------------
" read one line (last one) for set commands (sed in this file to fold .vimrc
" upon opening
set modelines=1
set shiftwidth=2
set tabstop=2
set softtabstop=2
" Replace tab with spaces
set expandtab
" # UI Config
" -----------------------------------------------------------------------------
syntax enable " enable syntax highlighting
set colorcolumn=80 " visible mark at 80 characters
set textwidth=80 " define text width
set mouse=a " Mouse on in every mode
set number " show line numbers
set relativenumber " display relaive numbers by default
set cursorline " always hightlight cursor line
set foldcolumn=1 " show 3 fold levels in the gutter
" set lazyredraw " redraw only when we need to.
set showmatch " highlight matching [{()}]
set scrolloff=5 " number of context lines above and below the cursor
if !has('nvim')
set ttymouse=sgr " to allow mouse to resize panels
let g:python2_host_prog = '/usr/local/bin/python'
endif
match ErrorMsg '\s\+$' " Highlight trailing whitespace
"saner autocomplete menu behavior
set completeopt=longest,menuone
inoremap <expr> <M-,> pumvisible() ? '<C-n>' :
\ '<C-x><C-o><C-n><C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
"nicer pane separators
set fillchars=vert:│
" Font to use in MacVim
" if has("gui_running")
if has("gui_macvim")
set guifont=CodeZen\ Nerd\ Font:h14,Menlo:h14,Monaco:h14,monospace:h14
endif
" ## Wildmenu
" set wildmode=list:longest
" set wildmode=longest:full,full
" set wildmode=full
set wildmode=longest:full
set wildmenu " visual autocomplete for command menu
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
set wildignore+=*.spl " compiled spelling word lists
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.DS_Store " OSX bullshit
set wildignore+=*.luac " Lua byte code
set wildignore+=migrations " Django migrations
set wildignore+=*.pyc " Python byte code
set wildignore+=__pycache__ " Python cache
set wildignore+=*.orig " Merge resolution files
" ## Mappings
" close a buffer w/o closing window
map <Leader>q :bp<bar>sp<bar>bn<bar>bd<CR>
" Press space to turn off highlighting and clear any message already displayed
nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
" Show syntax highlighting groups for word under cursor
" (pressing control-shift-P)
nmap <C-S-H> :call <SID>SynStack()<CR>
" toggle line numbers
nmap <Leader>l :set nonumber!<CR>
" toggle relative line numbers
nmap <Leader>r :set relativenumber!<CR>
" pretty print JSON file
nmap <Leader>json :%!python -m json.tool<CR>
" preserve selection when indenting with < & > keys
vnoremap < <gv
vnoremap > >gv
" # Tabs and splits
" -----------------------------------------------------------------------------
" defaults for where to open splitted windows
set splitright
set splitbelow
" ## Mappings
" nnoremap th :tabprev<CR>
" nnoremap tj :tabfirst<CR>
" nnoremap tk :tablast<CR>
" nnoremap tl :tabnext<CR>
" nnoremap tt :tabedit<CR>
" nnoremap tm :tabm<CR>
" nnoremap td :tabclose<CR>
" nnoremap tn :tabnew<CR>
" nnoremap <S-h> gT
" nnoremap <S-l> gt
" # Buffer management
" -----------------------------------------------------------------------------
" close all open buffers except the current one
noremap <Leader>cab :%bd\|e#<CR>
" # Editing text
" -----------------------------------------------------------------------------
" Keep the cursor in place while joining lines
nnoremap J mzJ`z
" Split line (sister to [J]oin lines)
" The normal use of S is covered by cc, so don't worry about shadowing it.
nnoremap S i<cr><esc>^mwgk:silent! s/\v +$//<cr>:noh<cr>`w
" shortcuts to add/remove surrounding function (depends on vim-surround)
" delete function when cursor in arguments
nmap <Leader>daf ds(db
" delete function when cursor function name
nmap <Leader>df diwds(
" add function around word
nmap <Leader>af ysiw)i
" add function around visual selection
vmap <Leader>af S)i
" shortcuts to add/remove surrounding dict (depends on vim-surround)
" delete dict when cursor in key (thanks to Tim O'Brien)
nmap <Leader>dad ds'ds[db
" add dict around word
nmap <Leader>ad ysiw]lysiw'hi
" sane placement of the cursor for p and P
" (see https://unix.stackexchange.com/a/5061/151275)
noremap p gp
noremap P gP
noremap gp p
noremap gP P
" # Saving files
" Sudo to write
cnoremap w!! w !sudo tee % >/dev/null
" # Copy/Paste
" use the unnamed register as clipboar (instead of the default * register)
" set clipboard=unnamed
" # Utils
" Delete trailing whitespace
nnoremap <Leader>rtw :%s/\s\+$//e<CR>
" shortcut to write and execute current python file
nmap <Leader>xp :w \| :! python %<CR>
" Source current line or visual selection
vnoremap <leader>S y:@"<CR>
nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
" # Searching & Movements
" -----------------------------------------------------------------------------
set hlsearch " highlight all search matches
set incsearch " search as characters are entered
set ignorecase smartcase " case insensitive search
" Easier to type, and I never use the default behavior.
noremap H ^
noremap L $
vnoremap L g_
" Keep search matches in the middle of the window.
nnoremap n nzzzv
nnoremap N Nzzzv
" make jump to mark center in screen
:map <expr> M printf('`%c zz',getchar())