-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
2024 lines (1710 loc) · 53.9 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
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
"----------------------------------------------------------------
" _
" _ __(_)___ ___ __________
" | | / / / __ `__ \/ ___/ ___/
" _| |/ / / / / / / / / / /__
" (_)___/_/_/ /_/ /_/_/ \___/
"
"----------------------------------------------------------------
" Version : 2.6.0
" License : MIT
" Author : Gerard Bajona
" URL : https://github.com/gerardbm/vimrc
"----------------------------------------------------------------
" Index:
" 1. General settings
" 2. Plugins (Plug)
" 3. Plugins settings
" 4. User interface
" 5. Scheme and colors
" 6. Files and backup
" 7. Buffers management
" 8. Tabs management
" 9. Multiple windows
" 10. Indentation tabs
" 11. Moving around lines
" 12. Paste mode
" 13. Search, vimgrep and grep
" 14. Text edition()
" 15. Make settings
" 16. Filetype settings
" 17. Helper functions
" 18. External tools integration
"----------------------------------------------------------------
"----------------------------------------------------------------
" 1. General settings
"----------------------------------------------------------------
" Disable vi compatibility
if !has("nvim")
set nocompatible
endif
" Reload .vimrc
nnoremap <F12> :so $MYVIMRC<CR>
" Lines of memory to remember
set history=10000
" Leader key to add extra key combinations
let mapleader = ','
let g:mapleader = ','
" Time delay on <Leader> key
set timeoutlen=3000 ttimeoutlen=100
" Update time
set updatetime=250
" Trigger InsertLeave autocmd
inoremap <C-c> <Esc>
" No need for Ex mode
nnoremap Q <NOP>
" Open help in a vertical window
cnoreabbrev help vert help
" Terminal (nvim)
if has("terminal") && has("nvim")
nnoremap <silent> <F7> :call <SID>ToggleTerminal()<CR>
tnoremap <silent> <F7> <C-\><C-n><Bar>:wincmd p<CR>
tnoremap <Esc> <C-\><C-n>
endif
" Set inc/dec
set nrformats-=octal
set clipboard+=unnamedplus
"----------------------------------------------------------------
" 2. Plugins (Plug)
"----------------------------------------------------------------
" List of plugins installed
call plug#begin('~/.vim/plugged')
Plug 'morhetz/gruvbox'
" Plug 'mhinz/vim-startify'
Plug 'mhinz/vim-startify', {'branch': 'master'}
" Plug 'mhinz/vim-startify', {'branch': 'center'}
" Statusbar
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" Git tools
Plug 'airblade/vim-gitgutter'
Plug 'tpope/vim-fugitive'
Plug 'junegunn/gv.vim'
" Sessions
Plug 'xolox/vim-session'
Plug 'xolox/vim-misc'
" Tools
Plug 'preservim/nerdcommenter', { 'commit': 'a5d1663' }
Plug 'preservim/nerdtree'
Plug 'valloric/listtoggle'
Plug 'majutsushi/tagbar'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'mbbill/undotree'
Plug 'dense-analysis/ale'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
" Deoplete, specific for Vim8
if !has("nvim")
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
" Autocomplete
" Plug 'Shougo/deoplete.nvim', { 'commit': '17ffeb9' }
Plug 'Shougo/ddc.vim'
Plug 'vim-denops/denops.vim'
Plug 'Shougo/neosnippet.vim', { 'commit': '037b7a7' }
Plug 'Shougo/neosnippet-snippets'
Plug 'Shougo/context_filetype.vim'
Plug 'ervandew/supertab'
Plug 'LumaKernel/ddc-file'
Plug 'Shougo/ddc-zsh'
" C/C++ support
" Plug 'deoplete-plugins/deoplete-clang', { 'commit': '30f17cb' }
" Go support
Plug 'fatih/vim-go', { 'tag': 'v1.19' }
Plug 'nsf/gocode', { 'rtp': 'vim', 'do': '~/.vim/plugged/gocode/vim/symlink.sh' }
" Plug 'deoplete-plugins/deoplete-go', { 'commit': 'fa73f06'}
" Perl support
Plug 'c9s/perlomni.vim'
" Python support
" Plug 'deoplete-plugins/deoplete-jedi', { 'commit': '46121d9' }
" Ruby support
Plug 'vim-ruby/vim-ruby'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-endwise'
Plug 'tpope/vim-liquid'
" PHP support
Plug 'shawncplus/phpcomplete.vim'
" Haskell support
Plug 'eagletmt/neco-ghc'
" Rust support
Plug 'racer-rust/vim-racer'
" Zsh support
" Plug 'deoplete-plugins/deoplete-zsh', { 'commit': '12141ad' }
" JavaScript support
Plug 'ternjs/tern_for_vim', { 'do': 'npm install' }
" Plug 'carlitux/deoplete-ternjs', { 'do': 'npm install -g tern' }
Plug 'othree/jspc.vim'
Plug 'maksimr/vim-jsbeautify'
" VimL support
Plug 'Shougo/neco-vim', { 'commit' : '4c0203b' }
" Additional syntax files
Plug 'othree/html5.vim'
Plug 'vim-language-dept/css-syntax.vim'
Plug 'hail2u/vim-css3-syntax'
Plug 'pangloss/vim-javascript'
Plug 'Shougo/neco-syntax', { 'commit': '98cba4a' }
Plug 'mboughaba/i3config.vim'
Plug 'aklt/plantuml-syntax'
Plug 'gerardbm/asy.vim'
Plug 'gerardbm/eukleides.vim'
Plug 'zaid/vim-rec'
Plug 'sirtaj/vim-openscad'
" Edition
Plug 'junegunn/vim-easy-align'
Plug 'godlygeek/tabular'
Plug 'jiangmiao/auto-pairs'
Plug 'alvan/vim-closetag'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-capslock'
Plug 'wellle/targets.vim'
Plug 'christoomey/vim-sort-motion'
Plug 'terryma/vim-expand-region'
Plug 'Valloric/MatchTagAlways'
Plug 'FooSoft/vim-argwrap'
Plug 'gerardbm/vim-md-headings'
Plug 'matze/vim-move'
" Misc
Plug 'christoomey/vim-tmux-navigator'
Plug 'tpope/vim-characterize'
Plug 'tyru/open-browser.vim'
Plug 'junegunn/goyo.vim'
Plug 'mattn/webapi-vim'
Plug 'mattn/emmet-vim'
Plug 'vimwiki/vimwiki', { 'branch': 'master' }
" Color schemes
Plug 'morhetz/gruvbox'
call plug#end()
"----------------------------------------------------------------
" 3. Plugins settings
"----------------------------------------------------------------
" --- Statusbar ---
" Airline settings
let g:airline_theme = 'atomic'
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline_section_z = airline#section#create([
\ '%1p%% ',
\ 'Ξ%l%',
\ '\⍿%c'])
call airline#parts#define_accent('mode', 'black')
" --- Git tools ---
" Gitgutter settings
let g:gitgutter_max_signs = 5000
let g:gitgutter_sign_added = '+'
let g:gitgutter_sign_modified = '»'
let g:gitgutter_sign_removed = '_'
let g:gitgutter_sign_modified_removed = '»╌'
let g:gitgutter_map_keys = 0
let g:gitgutter_diff_args = '--ignore-space-at-eol'
nmap <Leader>j <Plug>(GitGutterNextHunk)zz
nmap <Leader>k <Plug>(GitGutterPrevHunk)zz
nnoremap <silent> <C-g> :call <SID>ToggleGGPrev()<CR>zz
nnoremap <Leader>ga :GitGutterStageHunk<CR>
nnoremap <Leader>gu :GitGutterUndoHunk<CR>
" Fugitive settings
nnoremap <C-s> :call <SID>ToggleGstatus()<CR>
nnoremap <Leader>gv :Gvdiffsplit<CR>:windo set wrap<CR>
nnoremap <Leader>gh :Gvdiffsplit HEAD<CR>:windo set wrap<CR>
nnoremap <Leader>gb :Gblame<CR>
" Searching for text added or removed by a commit
nnoremap <Leader>gg :call <SID>GrepWrapper('Gclog', '-i -G', '--')<CR>
" GV settings
nnoremap <silent> <Leader>gz :call <SID>PreventGV()<CR>
vnoremap <silent> <Leader>gz :call <SID>PreventGV()<CR>
" --- Sessions ---
" Vim-session settings
let g:session_autosave = 'no'
let g:session_autoload = 'no'
let g:session_directory = '~/.vim/sessions/'
nnoremap <C-b> :OpenSession<CR>
" --- Tools ---
" NERDCommenter settings
let g:NERDDefaultAlign = 'left'
let g:NERDSpaceDelims = 1
let g:NERDCompactSexyComs = 1
let g:NERDCommentEmptyLines = 0
let g:NERDCreateDefaultMappings = 0
let g:NERDCustomDelimiters = {
\ 'python': {'left': '#'},
\ }
nnoremap cc :call NERDComment(0,'toggle')<CR>
vnoremap cc :call NERDComment(0,'toggle')<CR>
" NERDTree settings
nnoremap <silent> <C-n> :call <SID>ToggleNERDTree()<CR>
" ALE settings
let g:ale_linters = {
\ 'c' : ['clang'],
\ 'vim' : ['vint'],
\ 'python' : ['pylint'],
\ 'javascript' : ['jshint'],
\ 'css' : ['csslint'],
\ 'tex' : ['chktex'],
\ }
" FZF settings
let $FZF_PREVIEW_COMMAND = 'cat {}'
nnoremap <C-f><C-f> :Files<CR>
nnoremap <C-f><C-g> :Commits<CR>
nnoremap <C-f><Space> :BLines<CR>
" Navigate between errors
nnoremap <Leader>h :lprevious<CR>zz
nnoremap <Leader>l :lnext<CR>zz
" Listtoggle settings
let g:lt_location_list_toggle_map = '<leader>e'
let g:lt_quickfix_list_toggle_map = '<leader>q'
" Tagbar toggle (custom function)
nnoremap <silent> <C-t> :call <SID>ToggleTagbar()<CR>
let g:tagbar_autofocus = 1
let g:tagbar_show_linenumbers = 2
let g:tagbar_sort = 0
" CtrlP settings
let g:ctrlp_map = '<C-p>'
let g:ctrlp_cmd = 'CtrlPBuffer'
let g:ctrlp_working_path_mode = 'rc'
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:85'
let g:ctrlp_show_hidden = 1
let g:ctrlp_follow_symlinks = 1
let g:ctrlp_open_multiple_files = '0i'
let g:ctrlp_prompt_mappings = {
\ 'PrtHistory(1)' : [''],
\ 'PrtHistory(-1)' : [''],
\ 'ToggleType(1)' : ['<C-l>', '<C-up>'],
\ 'ToggleType(-1)' : ['<C-h>', '<C-down>'],
\ 'PrtCurLeft()' : ['<C-b>', '<Left>'],
\ 'PrtCurRight()' : ['<C-f>', '<Right>'],
\ 'PrtBS()' : ['<C-s>', '<BS>'],
\ 'PrtDelete()' : ['<C-d>', '<DEL>'],
\ 'PrtDeleteWord()' : ['<C-w>'],
\ 'PrtClear()' : ['<C-u>'],
\ 'ToggleByFname()' : ['<C-g>'],
\ 'AcceptSelection("e")' : ['<C-m>', '<CR>'],
\ 'AcceptSelection("h")' : ['<C-x>'],
\ 'AcceptSelection("t")' : ['<C-t>'],
\ 'AcceptSelection("v")' : ['<C-v>'],
\ 'OpenMulti()' : ['<C-o>'],
\ 'MarkToOpen()' : ['<c-z>'],
\ 'PrtExit()' : ['<esc>', '<c-c>', '<c-p>'],
\ }
" Undotree toggle
nnoremap <Leader>u :UndotreeToggle<CR>
" --- Languages ---
" Go settings
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
let g:go_bin_path = expand('~/.gotools')
let g:go_list_type = 'quickfix'
let g:go_version_warning = 0 " Keep until vim v8.0.1453, nvim v3.2
" CSS3 settings
augroup VimCSS3Syntax
autocmd!
autocmd FileType css setlocal iskeyword+=-
augroup END
" Javascript settings
let g:javascript_plugin_jsdoc = 1
let g:javascript_plugin_ngdoc = 1
let g:javascript_plugin_flow = 1
" Tern_for_vim settings
let g:tern#command = ['tern']
let g:tern#arguments = ['--persistent']
" JS-Beautify
let g:config_Beautifier = {}
let g:config_Beautifier['js'] = {}
let g:config_Beautifier['js'].indent_style = 'tab'
let g:config_Beautifier['jsx'] = {}
let g:config_Beautifier['jsx'].indent_style = 'tab'
let g:config_Beautifier['json'] = {}
let g:config_Beautifier['json'].indent_style = 'tab'
let g:config_Beautifier['css'] = {}
let g:config_Beautifier['css'].indent_style = 'tab'
let g:config_Beautifier['html'] = {}
let g:config_Beautifier['html'].indent_style = 'tab'
augroup beautify
autocmd!
autocmd FileType javascript nnoremap <buffer> <Leader>bf :call JsBeautify()<cr>
autocmd FileType javascript vnoremap <buffer> <Leader>bf :call RangeJsBeautify()<cr>
autocmd FileType json nnoremap <buffer> <Leader>bf :call JsonBeautify()<cr>
autocmd FileType json vnoremap <buffer> <Leader>bf :call RangeJsonBeautify()<cr>
autocmd FileType jsx nnoremap <buffer> <Leader>bf :call JsxBeautify()<cr>
autocmd FileType jsx vnoremap <buffer> <Leader>bf :call RangeJsxBeautify()<cr>
autocmd FileType html nnoremap <buffer> <Leader>bf :call HtmlBeautify()<cr>
autocmd FileType html vnoremap <buffer> <Leader>bf :call RangeHtmlBeautify()<cr>
autocmd FileType css nnoremap <buffer> <Leader>bf :call CSSBeautify()<cr>
autocmd FileType css vnoremap <buffer> <Leader>bf :call RangeCSSBeautify()<cr>
augroup end
" --- Autocomplete ---
" SuperTab settings
let g:SuperTabDefaultCompletionType = '<TAB>'
" Deoplete settings
" - «Deoplete requires Neovim with Python3 enabled»
" let g:python3_host_prog = '/usr/bin/python3'
" let g:python3_host_skip_check = 1
" autocmd CompleteDone * if pumvisible() == 0 | pclose | endif
" let g:deoplete#enable_at_startup = 1
" let g:deoplete#enable_smart_case = 1
" let g:deoplete#omni#functions = {}
" call deoplete#custom#option('auto_complete_delay', 250)
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" Python autocompletion
" let g:deoplete#sources#jedi#show_docstring = 1
" Go autocompletion
" let g:deoplete#sources#go#gocode_binary = $GOPATH.'/bin/gocode'
" let g:deoplete#sources#go#sort_class = ['package', 'func', 'type', 'var', 'const']
" let g:deoplete#sources#go#use_cache = 1
" Javascript autocompletion
" let g:deoplete#omni#functions.javascript = [
" \ 'tern#Complete',
" \ 'jspc#omni',
" \ ]
" Clang autocompletion
" let g:deoplete#sources#clang#libclang_path = '/usr/lib/llvm-4.0/lib/libclang.so'
" let g:deoplete#sources#clang#clang_header = '/usr/lib/clang'
" --- Snippets ---
" Neosnippet settings
imap <C-s> <Plug>(neosnippet_expand_or_jump)
smap <C-s> <Plug>(neosnippet_expand_or_jump)
xmap <C-s> <Plug>(neosnippet_expand_target)
" Behaviour like SuperTab
smap <expr><TAB>
\ neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers
if has('conceal')
set conceallevel=0 concealcursor=niv
nnoremap <silent> coi :set conceallevel=0<CR>:set concealcursor=niv<CR>
nnoremap <silent> coo :set conceallevel=2<CR>:set concealcursor=vc<CR>
nnoremap <silent> cop :set conceallevel=2<CR>:set concealcursor=niv<CR>
nnoremap <silent> com :set conceallevel=3<CR>:set concealcursor=niv<CR>
endif
augroup all
autocmd InsertLeave * NeoSnippetClearMarkers
augroup end
" --- Edition ---
" Easy align settings
xmap gi <Plug>(EasyAlign)
nmap gi <Plug>(EasyAlign)
" Tabularize (e.g. /= or /:)
vnoremap <Leader>x :Tabularize /
" Tabularize only the first match on the line (e.g. /=.*/)
vnoremap <Leader>X :Tabularize /.*/<Left><Left><Left>
" Auto-pairs settings
" Maps for normal and insert modes
let g:AutoPairsFlyMode = 0
let g:AutoPairsMultilineClose = 0
let g:AutoPairsShortcutJump = '<C-z>'
let g:AutoPairsShortcutToggle = '<C-q>'
" Workaround to fix an Auto-pairs bug until it gets fixed
if has("nvim")
autocmd VimEnter,BufEnter,BufWinEnter * silent! iunmap <buffer> <M-">
endif
" Closetag settings
let g:closetag_filenames = '*.html,*.xhtml,*.phtml,*.xml,*.html.erb,*.md'
" Surround settings
" Use 'yss?', 'yss%' or 'yss=' to surround a line
autocmd FileType php let b:surround_{char2nr('p')} = "<?php \r ?>"
autocmd FileType erb let b:surround_{char2nr('=')} = "<%= \r %>"
autocmd FileType erb let b:surround_{char2nr('-')} = "<% \r %>"
autocmd FileType html,markdown,liquid let b:surround_{char2nr('p')} = "{% \r %}"
autocmd FileType markdown,liquid let b:surround_{char2nr('i')} = "_\r_"
autocmd FileType markdown,liquid let b:surround_{char2nr('o')} = "**\r**"
autocmd FileType markdown,liquid let b:surround_{char2nr('x')} = "«\r»"
autocmd FileType markdown,liquid let b:surround_{char2nr('h')} = "\[\r\]\(//\)"
autocmd FileType markdown,liquid let b:surround_{char2nr('j')} = "!\[\r\]
\\(/images/\){: .align-}"
autocmd FileType markdown,liquid let b:surround_{char2nr('e')} = "\[\r\]
\\(\){:rel=\"noopener noreferrer\" target=\"_blank\"}"
autocmd FileType markdown,liquid let b:surround_{char2nr('y')} = "<a href=\"\"
\ rel=\"noopener noreferrer\" target=\"_blank\">\r<\/a>"
" Caps Lock settings
imap <expr><C-l> deoplete#smart_close_popup()."\<Plug>CapsLockToggle"
cmap <silent> <C-l> <Plug>CapsLockToggle
" Expand region settings
vmap v <Plug>(expand_region_expand)
vmap <C-v> <Plug>(expand_region_shrink)
" MatchTagAlways settings
let g:mta_filetypes = {
\ 'html' : 1,
\ 'xhtml' : 1,
\ 'xml' : 1,
\ 'jinja' : 1,
\ 'php' : 1,
\ }
" ArgWrap settings
let g:argwrap_tail_comma = 1
let g:argwrap_padded_braces = '[{'
nnoremap <Leader>W :ArgWrap<CR>
" Vim-move settings. Use Shift
let g:move_key_modifier = 'S'
" --- Misc ---
" Vim-tmux navigator settings
let g:tmux_navigator_no_mappings = 1
" Open-browser settings
let g:openbrowser_browser_commands = [{
\ 'name': 'w3m',
\ 'args': 'tmux new-window w3m {uri}',
\ }]
nmap <Leader>gl <Plug>(openbrowser-open)
" Goyo settings
let g:goyo_width = "80"
let g:goyo_height = "100%"
let g:goyo_linenr = 0
nnoremap <F11> :Goyo<CR>
" Vimwiki settings
let g:vimwiki_url_maxsave = 0
let g:vimwiki_global_ext = 0
let g:vimwiki_syntax = 'markdown'
let g:vimwiki_list = [
\ {'path': '~/Workspace/vimwiki'},
\ {'path': '~/Workspace/vimwiki/Articles'},
\ {'path': '~/Workspace/vimwiki/Codes'},
\ {'path': '~/Workspace/vimwiki/Notes'},
\ {'path': '~/Workspace/vimwiki/Projects'},
\ {'path': '~/Workspace/vimwiki/Studies'},
\ {'path': '~/Workspace/vimwiki/ToDos'},
\ {'path': '~/Workspace/vimwiki/Unix'}
\ ]
nnoremap <Leader>we :VimwikiToggleListItem<CR>
vnoremap <Leader>we :VimwikiToggleListItem<CR>
let g:startify_custom_header = [
\ ' ⣴⣶⣤⡤⠦⣤⣀⣤⠆ ⣈⣭⣭⣿⣶⣿⣦⣼⣆ ',
\ ' ⠉⠻⢿⣿⠿⣿⣿⣶⣦⠤⠄⡠⢾⣿⣿⡿⠋⠉⠉⠻⣿⣿⡛⣦ ',
\ ' ⠈ ⠈⢿⣿⣟⠦⠄⣾⣿⣿⣷ ⠻⠿⢿⣿⣧⣄ ',
\ ' ⣸⣿⣿⢧⠄⢻⠻⣿⣿⣷⣄⣀⠄⠢⣀⡀⠈⠙⠿⠄ ',
\ ' ⢀ ⢠⣿⣿⣿⠈ ⠡⠌⣻⣿⣿⣿⣿⣿⣿⣿⣛⣳⣤⣀⣀ ',
\ ' ⢠⣧⣶⣥⡤⢄⠄⣸⣿⣿⠘⠄ ⢀⣴⣿⣿⡿⠛⣿⣿⣧⠈⢿⠿⠟⠛⠻⠿⠄ ',
\ ' ⣰⣿⣿⠛⠻⣿⣿⡦⢹⣿⣷⠄ ⢊⣿⣿⡏ ⢸⣿⣿⡇ ⢀⣠⣄⣾ ',
\ '⣠⣿⠿⠛ ⢀⣿⣿⣷⠘⢿⣿⣦⡀ ⢸⢿⣿⣿⣄ ⣸⣿⣿⡇⣪⣿⡿⠿⣿⣷⡄ ',
\ '⠙⠃ ⣼⣿⡟ ⠈⠻⣿⣿⣦⣌⡇⠻⣿⣿⣷⣿⣿⣿⠐⣿⣿⡇ ⠛⠻⢷⣄',
\ ' ⢻⣿⣿⣄ ⠈⠻⣿⣿⣿⣷⣿⣿⣿⣿⣿⡟ ⠫⢿⣿⡆ ⠁',
\ ' ⠻⣿⣿⣿⣿⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⡟⢀⣀⣤⣾⡿⠃ ',
\ ]
let g:startify_custom_header = [
\ ' :---::. .::---: ',
\ ' ========-:. :-========. ',
\ ' .==: .:-===-: .-===-:. :==: ',
\ ' :==: .-===--------===-: :==: ',
\ ' :==: .:===----===-. :==: ',
\ ' .==- :==: ',
\ ' === ===. ',
\ ' .==-:: ::-==: ',
\ ' :==== ====- ',
\ ' ===. .::. .::. .=== ',
\ ' .==- -====. .====- :==: ',
\ ' -==. .:==: :==-. .==- ',
\ ' -==. .==- -==. === ',
\ ' -====--:. === === .:--===== ',
\ ' ..::--===-===. .:..===-====-::.. ',
\ ' .:====:.-=::====:. ',
\ ' .===----===. ',
\ ' :--==--: ',
\ ' ',
\ ]
let g:startify_custom_header = [
\ ' :===--:. .:--===: ',
\ ' -=:.:-==-:. :-==-:.:=- ',
\ ' -=. .:==------==-. .== ',
\ ' -=: :::..:::. :== ',
\ ' :=- -=: ',
\ ' ==-: :-==. ',
\ ' .==- .. .. -==. ',
\ ' .==. :==- -==: ==. ',
\ ' :=- .==: :==. :=- ',
\ ' -=-::. :=- :=- .::-=- ',
\ ' .::--==--== .. -=--==--::. ',
\ ' .:-==.--.==-:. ',
\ ' .-====-: ',
\ ' .. ',
\ ]
function! s:truncate_filename(fname)
let fname = fnamemodify(a:fname, ':~:p')
let maxchars = winwidth(0) - (g:startify_padding_left * 2 + 6)
if strdisplaywidth(fname) - 1 > maxchars
while strdisplaywidth(fname) > maxchars
let fname = substitute(fname, '.$', '', '')
endwhile
let fname = fname . '>'
endif
return fname
endfunction
let g:startify_transformations = [
\ ['.*', function('s:truncate_filename')],
\ ]
let g:startify_center = 50
"----------------------------------------------------------------
" 4. User interface
"----------------------------------------------------------------
" Set X lines to the cursor when moving vertically
set scrolloff=0
" Always show mode
set showmode
" Show command keys pressed
set showcmd
" Enable the WiLd menu
set wildmenu
" Show the current position
set ruler
" Command bar height
set cmdheight=2
" Backspace works on Insert mode
set backspace=eol,start,indent
" Don't redraw while executing macros (good performance config)
set lazyredraw
" Show matching brackets when text indicator is over them
set showmatch
" How many tenths of a second to blink when matching brackets
set matchtime=2
" No annoying sound on errors
set noerrorbells
set novisualbell
if !has("nvim")
set t_vb=
" Terminal keycodes
if &term =~ 'screen'
set <F1>=[11~
set <F2>=[12~
set <F3>=[13~
set <F4>=[14~
set <F5>=[15~
set <F6>=[17~
set <F7>=[18~
set <F8>=[19~
set <F9>=[20~
set <F10>=[21~
set <F11>=[23~
set <F12>=[24~
set <S-F1>=[11;2~
set <S-F2>=[12;2~
set <S-F3>=[13;2~
set <S-F4>=[14;2~
set <S-F5>=[15;2~
set <S-F6>=[17;2~
set <S-F7>=[18;2~
set <S-F8>=[19;2~
set <S-F9>=[20;2~
set <S-F10>=[21;2~
set <S-F11>=[23;2~
set <S-F12>=[24;2~
endif
endif
" Mouse
set mouse=a
" Highlight cursor line and cursor column
set cursorline
set nocursorcolumn
" Always show the status line
set laststatus=2
" Change the cursor shape
if !has("nvim")
let &t_SI = "\<Esc>[6 q"
let &t_SR = "\<Esc>[4 q"
let &t_EI = "\<Esc>[2 q"
else
set guicursor=n-v:block-Cursor/lCursor-blinkon0
set guicursor+=i-ci-c:ver100-Cursor/lCursor-blinkon0
set guicursor+=r-cr:hor100-Cursor/lCursor-blinkon0
endif
" Omni completion
if has('autocmd') && exists('+omnifunc')
autocmd Filetype *
\ if &omnifunc == "" |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif
endif
" Fix italics issue
if !has("nvim")
let &t_ZH="\e[3m"
let &t_ZR="\e[23m"
endif
"----------------------------------------------------------------
" 5. Scheme and colors
"----------------------------------------------------------------
" True color
" if !has("nvim")
" if has("termguicolors")
" let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
" let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" set termguicolors
" endif
" else
" set termguicolors
" endif
" Syntax highlighting
syntax enable
" Color scheme
colorscheme gruvbox
" Show syntax highlighting groups
nnoremap <Leader>B :call <SID>SynStack()<CR>
"----------------------------------------------------------------
" 6. Files and backup
"----------------------------------------------------------------
" Disable swap files
set noswapfile
" No backup (use Git instead)
set nobackup
" Prevents automatic write backup
set nowritebackup
" Use UTF-8 as default encoding
set encoding=utf8
" Use Unix as the standard file type
set fileformats=unix,dos,mac
" Autoread a file when it is changed from the outside
set autoread
" Reload a file when it is changed from the outside
let g:f5msg = 'Buffer reloaded.'
nnoremap <F5> :e<CR>:echo g:f5msg<CR>
" Enable filetype plugins
filetype plugin on
filetype indent on
" Allow us to use Ctrl-s and Ctrl-q as keybinds
" Restore default behaviour when leaving Vim.
if !has("nvim")
silent !stty -ixon
autocmd VimLeave * silent !stty ixon
endif
" Save the current buffer
nnoremap <Leader>s :update<CR>
" Save all buffers
nnoremap <Leader>S :bufdo update<CR>
" :W sudo saves the file
" (useful for handling the permission-denied error)
cnoremap WW w !sudo tee > /dev/null %
" Rename file
nnoremap <F2> :call <SID>RenameFile()<CR>
" Work on buffer
nnoremap yab :%y<CR>
nnoremap dab :%d<CR>
nnoremap vab ggVG
"----------------------------------------------------------------
" 7. Buffers management
"----------------------------------------------------------------
" Buffer hidden when it is abandoned
set hidden
" Close the current buffer
nnoremap <Leader>bd :call <SID>CustomCloseBuffer()<CR>
" Move between buffers
nnoremap <C-h> :bprev<CR>
nnoremap <C-l> :bnext<CR>
" Edit and explore buffers
nnoremap <Leader>bb :edit <C-R>=expand("%:p:h")<CR>/
nnoremap <Leader>bg :buffers<CR>:buffer<Space>
" Switch CWD to the directory of the current buffer
nnoremap <Leader>bw :lcd %:p:h<CR>:pwd<CR>
" Copy the filepath to clipboard
nnoremap <Leader>by :let @+=expand("%:p")<CR>
" Ignore case when autocompletes when browsing files
set fileignorecase
" Specify the behavior when switching between buffers
try
set switchbuf=useopen,usetab,newtab
set showtabline=2
catch
endtry
" Remember info about open buffers on close
" set viminfo^=%
"----------------------------------------------------------------
" 8. Tabs management
"----------------------------------------------------------------
" Create and close tabs
nnoremap <Leader>td :tabclose<CR>
nnoremap <Leader>to :tabonly<CR>
" Open a new tab with the current buffer's path
" Useful when editing files in the same directory
nnoremap <Leader>tt :tabedit <C-R>=expand("%:p:h")<CR>/
" Move tabs position
nnoremap <Leader>tr :execute 'silent! tabmove ' . (tabpagenr()-2)<CR>
nnoremap <Leader>ty :execute 'silent! tabmove ' . tabpagenr()<CR>
"----------------------------------------------------------------
" 9. Multiple windows
"----------------------------------------------------------------
" Remap wincmd
map <Leader>, <C-w>
set winminheight=0
set winminwidth=0
set splitbelow
set splitright
set fillchars+=stlnc:\/,vert:│,fold:―,diff:―
" Split windows
map <C-w>- :split<CR>
map <C-w>. :vsplit<CR>
map <C-w>j :close<CR>
map <C-w>x :q!<CR>
map <C-w>, <C-w>=
" Resize windows
if bufwinnr(1)
map + :resize +1<CR>
map - :resize -1<CR>
map < :vertical resize +1<CR>
map > :vertical resize -1<CR>
endif
" Toggle resize window
nnoremap <silent> <C-w>f :call <SID>ToggleResize()<CR>
" Last, previous and next window; and only one window
nnoremap <silent> <C-w>l :wincmd p<CR>:echo "Last window."<CR>
nnoremap <silent> <C-w>p :wincmd w<CR>:echo "Previous window."<CR>
nnoremap <silent> <C-w>n :wincmd W<CR>:echo "Next window."<CR>
nnoremap <silent> <C-w>o :wincmd o<CR>:echo "Only one window."<CR>
" Move between Vim windows and Tmux panes
" - It requires the corresponding configuration into Tmux.
" - Check it at my .tmux.conf from my dotfiles repository.
" - URL: https://github.com/gerardbm/dotfiles/blob/master/tmux/.tmux.conf
" - Plugin required: https://github.com/christoomey/vim-tmux-navigator
if !has("nvim")
set <M-h>=h
set <M-j>=j
set <M-k>=k
set <M-l>=l
endif
nnoremap <silent> <M-h> :TmuxNavigateLeft<CR>
nnoremap <silent> <M-j> :TmuxNavigateDown<CR>
nnoremap <silent> <M-k> :TmuxNavigateUp<CR>
nnoremap <silent> <M-l> :TmuxNavigateRight<CR>
" Remove the Windows ^M - when the encodings gets messed up
noremap <Leader><BS> mmHmt:%s/<C-v><CR>//ge<CR>'tzt`m
" Close the preview window
nnoremap <silent> <Leader>. :pclose<CR>
" Scroll the preview window
if !has("nvim")
set <M-d>=d
set <M-u>=u
endif
nnoremap <silent> <M-d> :wincmd P<CR>5<C-e>:wincmd p<CR>
nnoremap <silent> <M-u> :wincmd P<CR>5<C-y>:wincmd p<CR>
"----------------------------------------------------------------
" 10. Indentation tabs
"----------------------------------------------------------------
" Enable autoindent & smartindent
set autoindent
set smartindent
" Use tabs, no spaces
set noexpandtab
" Be smart when using tabs
set smarttab
" Tab size (in spaces)
set shiftwidth=2
set tabstop=2
" Remap indentation
nnoremap <TAB> >>
nnoremap <S-TAB> <<
vnoremap <TAB> >gv
vnoremap <S-TAB> <gv
inoremap <TAB> <C-i>
inoremap <S-TAB> <C-d>
" Don't show tabs
set list
let g:f6msg = 'Toggle list.'
nnoremap <F6> :set list!<CR>:echo g:f6msg<CR>
" Show tabs and end-of-lines
set listchars=tab:│\ ,trail:¬
"----------------------------------------------------------------
" 11. Moving around lines
"----------------------------------------------------------------
" Specify which commands wrap to another line
set whichwrap+=<,>,h,l
" Many jump commands move the cursor to the start of line
set nostartofline
" Wrap lines into the window
set wrap
" Don't break the words
" Only works if I set nolist (F6)
set linebreak
set showbreak=├——»
" Stop automatic wrapping
set textwidth=0
" Column at 80 width
set colorcolumn=80
" Listings don't pause
set nomore