forked from blackcobra1973/kd-vim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvimrc
2204 lines (1919 loc) · 81.1 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
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Maintainer:
" Kurt Dillen
"
" Version:
" 2.0.7.3 - 2017-05-01
"
" Awesome_version:
" Get this config, nice color schemes and lots of plugins!
"
" Sections:
" -> Vim environment
" -> Vim options
" -> Vundle install
" -> Vundle bundles
" -> Vim general
" -> Vim files, backups and undo
" -> Vim user interface
" -> Vim status line
" -> Vim formatting
" -> Vim key (re)mappings
" -> Vim plugins configurations
" -> Vim GUI Settings
" -> Vim functions
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vim Environment
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Environment {
" Identify platform {
silent function! OSX()
return has('macunix')
endfunction
silent function! LINUX()
return has('unix') && !has('macunix') && !has('win32unix')
endfunction
silent function! WINDOWS()
return (has('win32') || has('win64'))
endfunction
" }
" Basics {
set nocompatible " Must be first line
set background=dark " Assume a dark background
if !WINDOWS()
set shell=/bin/sh
endif
" }
" On Windows, also use '.vim' instead of 'vimfiles'; this makes synchronization
" across (heterogeneous) systems easier.
if WINDOWS()
set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
" Be nice and check for multi_byte even if the config requires
" multi_byte support most of the time
if has("multi_byte")
" Windows cmd.exe still uses cp850. If Windows ever moved to
" Powershell as the primary terminal, this would be utf-8
set termencoding=cp850
" Let Vim use utf-8 internally, because many scripts require this
set encoding=utf-8
setglobal fileencoding=utf-8
" Windows has traditionally used cp1252, so it's probably wise to
" fallback into cp1252 instead of eg. iso-8859-15.
" Newer Windows files might contain utf-8 or utf-16 LE so we might
" want to try them first.
set fileencodings=ucs-bom,utf-8,utf-16le,cp1252,iso-8859-15
endif
else
set encoding=utf8
endif
" }
" Arrow Key Fix {
if &term[:4] == "xterm" || &term[:5] == 'screen' || &term[:3] == 'rxvt'
inoremap <silent> <C-[>OC <RIGHT>
endif
" }
" }
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vim Options
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" kd options {
" Prevent automatically changing to open file directory
" let g:kd_no_autochdir = 1
" Disable views
" let g:kd_no_views = 1
" Leader keys
" let g:kd_leader='\'
" let g:kd_localleader='_'
" Disable easier moving in tabs and windows
" let g:kd_no_easyWindows = 1
" Disable wrap relative motion for start/end line motions
" let g:kd_no_wrapRelMotion = 1
" Disable fast tab navigation
" let g:kd_no_fastTabs = 1
" Clear search highlighting
" let g:kd_clear_search_highlight = 1
" Disable neosnippet expansion
" This maps over <C-k> and does some Supertab
" emulation with snippets
" let g:kd_no_neosnippet_expand = 1
" Disable whitespace stripping
" let g:kd_keep_trailing_whitespace = 1
" Enable powerline symbols
" let g:airline_powerline_fonts = 1
" vim files directory
" let g:kd_consolidated_directory = <full path to desired directory>
" eg: let g:kd_consolidated_directory = $HOME . '/.vim/'
" This makes the completion popup strictly passive.
" Keypresses acts normally. <ESC> takes you of insert mode, words don't
" automatically complete, pressing <CR> inserts a newline, etc. Iff the
" menu is open, tab will cycle through it. If a snippet is selected, <C-k>
" expands it and jumps between fields.
" let g:kd_noninvasive_completion = 1
" Don't turn conceallevel or concealcursor
" let g:kd_no_conceal = 1
" For some colorschemes, autocolor will not work (eg: 'desert', 'ir_black')
" Indent guides will attempt to set your colors smartly. If you
" want to control them yourself, do it here.
" let g:indent_guides_auto_colors = 0
" autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd guibg=#212121 ctermbg=233
" autocmd VimEnter,Colorscheme * :hi IndentGuidesEven guibg=#404040 ctermbg=234
" Leave the default font and size in GVim
" To set your own font, do it from ~/.vimrc.local
" let g:kd_no_big_font = 1
" Disable omni complete
" let g:kd_no_omni_complete = 1
" Don't create default mappings for multicursors
" See :help multiple-cursors-mappings
" let g:multi_cursor_use_default_mapping=0
" let g:multi_cursor_next_key='<C-n>'
" let g:multi_cursor_prev_key='<C-p>'
" let g:multi_cursor_skip_key='<C-x>'
" let g:multi_cursor_quit_key='<Esc>'
" Require a special keypress to enter multiple cursors mode
" let g:multi_cursor_start_key='+'
" Mappings for editing/applying kd config
" let g:kd_edit_config_mapping='<leader>ev'
" let g:kd_apply_config_mapping='<leader>sv'
" }
" Use local before if available {
if filereadable(expand("~/.vimrc.before.local"))
source ~/.vimrc.before.local
endif
" }
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vundle Install
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vundle Install {
" Install Vundle {
" Required for Vundle Install
filetype off
" Setting up Vundle - the vim plugin bundler
let iCanHazVundle=1
let vundle_readme=expand('~/.vim/bundle/vundle/README.md')
if !filereadable(vundle_readme)
echo "Installing Vundle.."
echo ""
silent !mkdir -p ~/.vim/bundle
silent !git clone https://github.com/gmarik/vundle ~/.vim/bundle/vundle
let iCanHazVundle=0
endif
" }
" Setup Bundle Support {
" The next three lines ensure that the ~/.vim/bundle/ system works
filetype off
set rtp+=~/.vim/bundle/vundle
call vundle#rc()
" }
" Add an UnBundle command {
function! UnBundle(arg, ...)
let bundle = vundle#config#init_bundle(a:arg, a:000)
call filter(g:vundle#bundles, 'v:val["name_spec"] != "' . a:arg . '"')
endfunction
com! -nargs=+ UnBundle
\ call UnBundle(<args>)
" }
" }
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vundle Bundles
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Bundles {
" Deps {
Bundle 'gmarik/vundle'
Bundle 'MarcWeber/vim-addon-mw-utils'
Bundle 'tomtom/tlib_vim'
if executable('ag')
Bundle 'mileszs/ack.vim'
let g:ackprg = 'ag --nogroup --nocolor --column --smart-case'
elseif executable('ack-grep')
let g:ackprg="ack-grep -H --nocolor --nogroup --column"
Bundle 'mileszs/ack.vim'
elseif executable('ack')
Bundle 'mileszs/ack.vim'
endif
" }
" In your .vimrc.before.local file
" list only the plugin groups you will use
if !exists('g:kd_bundle_groups')
let g:kd_bundle_groups=['general', 'neocomplcache', 'programming', 'markdown', 'ruby', 'ansible', 'python', 'docker', 'javascript', 'html', 'misc',]
endif
" To override all the included bundles, add the following to your
" .vimrc.before.local file:
" let g:override_kd_bundles = 1
if !exists("g:override_kd_bundles")
" General {
if count(g:kd_bundle_groups, 'general')
Bundle 'scrooloose/nerdtree'
Bundle 'jistr/vim-nerdtree-tabs'
Bundle 'tpope/vim-surround'
Bundle 'tpope/vim-repeat'
Bundle 'spf13/vim-autoclose'
Bundle 'ctrlpvim/ctrlp.vim'
Bundle 'tacahiroy/ctrlp-funky'
Bundle 'terryma/vim-multiple-cursors'
Bundle 'easymotion/vim-easymotion'
if has("python") || has("python3")
Bundle 'sjl/gundo.vim'
else
Bundle 'mbbill/undotree'
endif
Bundle 'nathanaelkane/vim-indent-guides'
Bundle 'mhinz/vim-signify'
Bundle 'bronson/vim-trailing-whitespace'
if (has("python") || has("python3")) && exists('g:kd_use_powerline') && !exists('g:kd_use_old_powerline')
Bundle 'Lokaltog/powerline', {'rtp':'/powerline/bindings/vim'}
elseif exists('g:kd_use_powerline') && exists('g:kd_use_old_powerline')
Bundle 'Lokaltog/vim-powerline'
Bundle 'ryanoasis/vim-devicons'
elseif exists('g:kd_use_lightline')
Bundle 'itchyny/lightline.vim'
elseif exists('g:kd_use_agnoster')
Bundle 'i5ar/vim-agnoster-statusline'
else
Bundle 'vim-airline/vim-airline'
Bundle 'vim-airline/vim-airline-themes'
endif
Bundle 'powerline/fonts'
Bundle 'rhysd/conflict-marker.vim'
if !exists('g:kd_no_views')
Bundle 'vim-scripts/restore_view.vim'
endif
Bundle 'osyo-manga/vim-over'
Bundle 'gcmt/wildfire.vim'
Bundle 'blackcobra1973/kd-vim-colors'
Bundle 'noahfrederick/vim-hemisu'
Bundle 'sjl/badwolf'
endif
" }
" Extra General {
if count(g:kd_bundle_groups, 'extra')
Bundle 'jiangmiao/auto-pairs'
Bundle 'vim-scripts/sessionman.vim'
Bundle 'matchit.zip'
Bundle 'bling/vim-bufferline'
Bundle 'tpope/vim-abolish.git'
Bundle 'kana/vim-textobj-user'
Bundle 'kana/vim-textobj-indent'
endif
" }
" Extra Color schemes {
if count(g:kd_bundle_groups, 'colorschemes')
Bundle 'altercation/vim-colors-solarized'
Bundle 'spf13/vim-colors'
Bundle 'flazz/vim-colorschemes'
Bundle 'romainl/apprentice'
Bundle 'lokaltog/vim-distinguished'
Bundle 'tpope/vim-vividchalk'
endif
" }
" Writing {
if count(g:kd_bundle_groups, 'writing')
Bundle 'reedes/vim-litecorrect'
Bundle 'reedes/vim-textobj-sentence'
Bundle 'reedes/vim-textobj-quote'
Bundle 'reedes/vim-wordy'
endif
" }
" General Programming {
if count(g:kd_bundle_groups, 'programming')
" Pick one of the checksyntax, jslint, or syntastic
Bundle 'vim-syntastic/syntastic'
Bundle 'tpope/vim-fugitive'
Bundle 'gregsexton/gitv'
Bundle 'mattn/webapi-vim'
Bundle 'mattn/gist-vim'
Bundle 'scrooloose/nerdcommenter'
Bundle 'tpope/vim-commentary'
Bundle 'godlygeek/tabular'
Bundle 'luochen1990/rainbow'
if executable('ctags')
Bundle 'majutsushi/tagbar'
endif
endif
" }
" Snippets & AutoComplete {
if count(g:kd_bundle_groups, 'snipmate')
Bundle 'garbas/vim-snipmate'
Bundle 'honza/vim-snippets'
" Source support_function.vim to support vim-snippets.
if filereadable(expand("~/.vim/bundle/vim-snippets/snippets/support_functions.vim"))
source ~/.vim/bundle/vim-snippets/snippets/support_functions.vim
endif
elseif count(g:kd_bundle_groups, 'youcompleteme')
Bundle 'Valloric/YouCompleteMe'
Bundle 'SirVer/ultisnips'
Bundle 'honza/vim-snippets'
elseif count(g:kd_bundle_groups, 'neocomplcache')
Bundle 'Shougo/neocomplcache'
Bundle 'Shougo/neosnippet'
Bundle 'Shougo/neosnippet-snippets'
Bundle 'honza/vim-snippets'
elseif count(g:kd_bundle_groups, 'neocomplete')
Bundle 'Shougo/neocomplete.vim.git'
Bundle 'Shougo/neosnippet'
Bundle 'Shougo/neosnippet-snippets'
Bundle 'honza/vim-snippets'
endif
" }
" PHP {
if count(g:kd_bundle_groups, 'php')
Bundle 'spf13/PIV'
Bundle 'arnaud-lb/vim-php-namespace'
Bundle 'beyondwords/vim-twig'
endif
" }
" Python {
if count(g:kd_bundle_groups, 'python')
" Pick either python-mode or pyflakes & pydoc
Bundle 'klen/python-mode'
Bundle 'yssource/python.vim'
Bundle 'python_match.vim'
Bundle 'pythoncomplete'
endif
" }
" Javascript {
if count(g:kd_bundle_groups, 'javascript')
Bundle 'elzr/vim-json'
Bundle 'groenewege/vim-less'
Bundle 'pangloss/vim-javascript'
Bundle 'briancollins/vim-jst'
Bundle 'kchmck/vim-coffee-script'
endif
" }
" Scala {
if count(g:kd_bundle_groups, 'scala')
Bundle 'derekwyatt/vim-scala'
Bundle 'derekwyatt/vim-sbt'
Bundle 'xptemplate'
endif
" }
" Haskell {
if count(g:kd_bundle_groups, 'haskell')
Bundle 'travitch/hasksyn'
Bundle 'dag/vim2hs'
Bundle 'Twinside/vim-haskellConceal'
Bundle 'Twinside/vim-haskellFold'
Bundle 'lukerandall/haskellmode-vim'
Bundle 'eagletmt/neco-ghc'
Bundle 'eagletmt/ghcmod-vim'
Bundle 'Shougo/vimproc.vim'
Bundle 'adinapoli/cumino'
Bundle 'bitc/vim-hdevtools'
endif
" }
" HTML {
if count(g:kd_bundle_groups, 'html')
Bundle 'vim-scripts/HTML-AutoCloseTag'
Bundle 'hail2u/vim-css3-syntax'
Bundle 'gorodinskiy/vim-coloresque'
Bundle 'tpope/vim-haml'
Bundle 'mattn/emmet-vim'
endif
" }
" Ruby {
if count(g:kd_bundle_groups, 'ruby')
Bundle 'tpope/vim-rails'
let g:rubycomplete_buffer_loading = 1
"let g:rubycomplete_classes_in_global = 1
"let g:rubycomplete_rails = 1
endif
" }
" Ansible {
if count(g:kd_bundle_groups, 'ansible')
Bundle 'pearofducks/ansible-vim'
endif
" }
" Puppet {
if count(g:kd_bundle_groups, 'puppet')
Bundle 'rodjek/vim-puppet'
endif
" }
" Go Lang {
if count(g:kd_bundle_groups, 'go')
"Bundle 'Blackrush/vim-gocode'
Bundle 'fatih/vim-go'
endif
" }
" Git {
if count(g:kd_bundle_groups, 'gitonly')
" Disable vim-signify before using this one
Bundle 'airblade/vim-gitgutter'
endif
" }
" Github {
if count(g:kd_bundle_groups, 'github')
"Bundle 'yasuhiroki/github-actions-yaml.vim'
"Bundle 'blackcobra1973/github-actions.vim'
Bundle 'github/copilot.vim'
endif
" }
" Elixir {
if count(g:kd_bundle_groups, 'elixir')
Bundle 'elixir-lang/vim-elixir'
Bundle 'carlosgaldino/elixir-snippets'
Bundle 'mattreduce/vim-mix'
endif
" }
" Docker {
if count(g:kd_bundle_groups, 'docker')
Bundle 'blackcobra1973/Dockerfile.vim'
endif
" }
" Asciidoc {
if count(g:kd_bundle_groups, 'asciidoc')
Bundle 'blackcobra1973/asciidoc-vim'
endif
" }
" Markdown {
if count(g:kd_bundle_groups, 'markdown')
"Bundle 'tpope/vim-markdown'
Bundle 'gabrielelana/vim-markdown'
"Bundle 'dhruvasagar/vim-table-mode'
endif
" }
" Misc {
if count(g:kd_bundle_groups, 'misc')
Bundle 'rust-lang/rust.vim'
Bundle 'spf13/vim-preview'
Bundle 'tpope/vim-cucumber'
Bundle 'cespare/vim-toml'
Bundle 'quentindecock/vim-cucumber-align-pipes'
Bundle 'saltstack/salt-vim'
endif
" }
endif
" }
" Use local bundles config if available {
if filereadable(expand("~/.vimrc.bundles.local"))
source ~/.vimrc.bundles.local
endif
" }
if iCanHazVundle == 0
echo "Installing Bundles, please ignore key map error messages"
echo ""
:BundleInstall
endif
" Setting up Vundle - the vim plugin bundler end
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vim General
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" General {
set background=dark " Assume a dark background
" Allow to trigger background
function! ToggleBG()
let s:tbg = &background
" Inversion
if s:tbg == "dark"
set background=light
else
set background=dark
endif
endfunction
noremap <leader>bg :call ToggleBG()<CR>
"filetype plugin indent on " Automatically detect file types.
filetype plugin on " Automatically detect file types.
syntax on " Syntax highlighting
"set mouse=a " Automatically enable mouse usage
"set mousehide " Hide the mouse cursor while typing
set ttyfast " assume fast terminal connection
scriptencoding utf-8 " Set encoding to UTF8
set history=1000 " Sets how many lines of history VIM has to remember
set autoread " Set to auto read when a file is changed from the outside
set ffs=unix,dos,mac " Use Unix as the standard file type
" Most prefer to automatically switch to the current file directory when
" a new buffer is opened; to prevent this behavior, add the following to
" your .vimrc.before.local file:
" let g:kd_no_autochdir = 1
if !exists('g:kd_no_autochdir')
autocmd BufEnter * if bufname("") !~ "^\[A-Za-z0-9\]*://" | lcd %:p:h | endif
" Always switch to the current file directory
endif
"set autowrite " Automatically write a file when leaving a modified buffer
set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter')
set viewoptions=folds,options,cursor,unix,slash " Better Unix / Windows compatibility
set virtualedit=onemore " Allow for cursor beyond last character
"set spell " Spell checking on
"set hidden " Allow buffer switching without saving
set iskeyword-=. " '.' is an end of word designator
set iskeyword-=# " '#' is an end of word designator
set iskeyword-=- " '-' is an end of word designator
" Instead of reverting the cursor to the last position in the buffer, we
" set it to the first line when editing a git commit message
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])
let g:copilot_filetypes = {
\ '*': v:false,
\ 'python': v:true,
\ 'markdown': v:true,
\ 'yaml': v:true,
\ 'vim': v:true,
\ }
" Enable filetype plugins
"filetype plugin on
"filetype indent on
" enable per-directory .vimrc files
"set exrc
"set secure
if has('clipboard')
if exists('$TMUX')
set clipboard=
endif
if has('unnamedplus') " When possible use + register for copy-paste
set clipboard=unnamed,unnamedplus
else " On mac and Windows, use * register for copy-paste
set clipboard=unnamed
endif
endif
" Misc
highlight FoldColumn ctermfg=darkyellow ctermbg=darkgrey
" Setting up the directories {
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vim Files, backups and undo
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Turn backup off, since most stuff is in SVN, git etc anyway...
set nobackup
set nowb
set noswapfile
"set backup " Backups are nice ...
if has('persistent_undo')
set undofile " So is persistent undo ...
set undolevels=1000 " Maximum number of changes that can be undone
set undoreload=10000 " Maximum number lines to save for undo on a buffer reload
endif
set viminfo='20,\"500 " Keep a .viminfo file.
set viminfo+='100,f1 " Save marks and stuff
set viminfo^=% " Remember info about open buffers on close
" To disable views add the following to your .vimrc.before.local file:
" let g:kd_no_views = 1
if !exists('g:kd_no_views')
" Add exclusions to mkview and loadview
" eg: *.*, svn-commit.tmp
let g:skipview_files = [
\ '\[example pattern\]'
\ ]
endif
" }
" }
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vim user interface
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Vim UI {
if !exists('g:override_kd_bundles') && filereadable(expand("~/.vim/bundle/vim-colors-solarized/colors/solarized.vim"))
let g:solarized_termcolors=256
let g:solarized_termtrans=1
let g:solarized_contrast="normal"
let g:solarized_visibility="normal"
color solarized " Load a colorscheme
else
let g:solarized_termcolors=256
endif
" Add possibility to define the colorsheme in the .vimrc.before.local file
" Example: let g:kd_colorscheme = 'badwolf'
if !exists('g:kd_colorscheme')
"colorscheme grb256
"colorscheme hemisu
colorscheme Tomorrow-Night-Bright
else
exec 'colorscheme ' . g:kd_colorscheme
endif
set tabpagemax=15 " Only show 15 tabs
set modeline " Enable modeline (Vim settings in a file)
"set showmode " Display the current mode
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline)
set cursorline " Highlight current line
highlight clear SignColumn " SignColumn should match background
highlight clear LineNr " Current line number row will have same background color in relative mode
highlight clear CursorLine " Remove highlight color from current line
"highlight clear CursorLineNr " Remove highlight color from current line number
if has('cmdline_info')
set ruler " Show the ruler
"set rulerformat=%30(%=\:b%n%y%m%r%w\ %l,%c%V\ %P%) " A ruler on steroids
set showcmd " Show partial commands in status line and
" Selected characters/lines in visual mode
endif
""""""""""""""""""""""""""""""
" => Vim Status line
""""""""""""""""""""""""""""""
if has('statusline')
" Always show the status line
" Improved status line: always visible, shows [+] modification, read only
" status, git branch, etc.
set laststatus=2
" Broken down into easily includeable segments
set statusline=%<%f\ " Filename
set statusline+=%w%h%m%r " Options
set statusline+=%{SyntasticStatuslineFlag()} " Syntastic
if !exists('g:override_kd_bundles')
set statusline+=%{fugitive#statusline()} " Git Hotness
endif
set statusline+=\ [%{&ff}/%Y] " Filetype
set statusline+=\ [%{getcwd()}] " Current dir
set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info
endif
hi User1 term=inverse,bold cterm=inverse,bold ctermfg=red
" Show (partial) command in status line.
set showcmd
set backspace=indent,eol,start " Backspace for dummies
"set backspace=eol,start,indent " Backspace for dummies
set linespace=0 " No extra spaces between rows
set number " Line numbers on
set showmatch " Show matching brackets/parenthesis
set mat=2 " How many tenths of a second to blink when matching brackets
set hlsearch " Highlight search terms
set incsearch " Find as you type search
set ignorecase " Case insensitive search
set smartcase " Case sensitive when uc present
set winminheight=0 " Windows can be 0 line high
set wildmenu " Show list instead of just completing
"set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all.
set wildmode=longest:full " Command <Tab> completion, list matches, then longest common part, then all.
set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too
"set whichwrap+=<,>,h,l " Backspace and cursor keys wrap too
set scrolljump=5 " Lines to scroll when cursor leaves screen
set scrolloff=3 " Minimum lines to keep above and below cursor
set list
"set listchars=tab:›\ ,trail:•,extends:#,nbsp:. " Highlight problematic whitespace
set listchars=tab:›\ ,extends:#,nbsp:. " Highlight problematic whitespace
set bs=2 " Allow backspacing over everything in insert mode
set so=7 " Set 7 lines to the cursor - when moving vertically using j/k
"set so=10 " Set 10 lines to the cursor
set cmdheight=2 " Height of the command bar
set hid " A buffer becomes hidden when it is abandoned
set lazyredraw " Don't redraw while executing macros (good performance config)
set magic " For regular expressions turn magic on
set showfulltag " Auto-complete things?
set nohls " Remove Space underscores
" No annoying sound on errors
set noerrorbells
set novisualbell
set t_vb=
set tm=500
" Add a bit extra margin to the left
"set foldcolumn=1
"set foldcolumn=3 " Fold column is three bits wide
set foldenable " Enable folds by default
set foldmethod=syntax " Fold via syntax of files
set foldlevelstart=99 " Open all folds by default
let g:xml_syntax_folding=1 " Enable xml folding
" When displaying line numbers, don't use an annoyingly wide number column. This
" doesn't enable line numbers -- :set number will do that. The value given is a
" minimum width to use for the number column, not a fixed size.
if v:version >= 700
set numberwidth=3
endif
" Ignore compiled files
set wildignore=*.o,*~,*.pyc
if has("win32") || has("win64")
set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store
else
set wildignore+=.git\*,.hg\*,.svn\*
endif
" }
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vim Formatting
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Formatting {
set nowrap " Do not wrap long lines
"set wrap "Wrap lines
"set smartindent
"set autoindent " Indent at the same level of the previous line
set shiftwidth=2 " Use indents of 2 spaces
set expandtab " Tabs are spaces, not tabs
set tabstop=2 " An indentation every four columns
set softtabstop=2 " Let backspace delete indent
set smarttab " Be smart when using tabs ;)
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set splitright " Puts new vsplit windows to the right of the current
set splitbelow " Puts new split windows to the bottom of the current
"set matchpairs+=<:> " Match, to be used with %
set pastetoggle=<F2> " pastetoggle (sane indentation on pastes)
"set comments=sl:/*,mb:*,elx:*/ " auto format comment blocks
" Remove trailing whitespaces and ^M chars
" To disable the stripping of whitespace, add the following to your
" .vimrc.before.local file:
" let g:kd_keep_trailing_whitespace = 1
autocmd FileType c,cpp,java,go,php,javascript,puppet,python,rust,twig,xml,yml,perl,sql autocmd BufWritePre <buffer> if !exists('g:kd_keep_trailing_whitespace') | call StripTrailingWhitespace() | endif
"autocmd FileType go autocmd BufWritePre <buffer> Fmt
autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig
autocmd FileType haskell,puppet,ruby,yml setlocal expandtab shiftwidth=2 softtabstop=2
" preceding line best in a plugin but here for now.
autocmd BufNewFile,BufRead *.coffee set filetype=coffee
au BufNewFile,BufRead *.cjs setfiletype javascript
au BufNewFile,BufRead *.thtml setfiletype php
au BufNewFile,BufRead *.pl setfiletype prolog
au BufNewFile,BufRead *.json setfiletype json
au BufNewFile,BufRead *.asc setfiletype asciidoc
autocmd BufNewFile,BufRead *.csv setf csv
autocmd BufNewFile,BufRead *.txt setlocal textwidth=0
au FileType * setl fo-=cro " disable autocomment
" Workaround vim-commentary for Haskell
autocmd FileType haskell setlocal commentstring=--\ %s
" Workaround broken colour highlighting in Haskell
autocmd FileType haskell,rust setlocal nospell
""""""""""""""""""""""""""""""
" => Python section
""""""""""""""""""""""""""""""
let python_highlight_all = 1
au FileType python syn keyword pythonDecorator True None False self
au BufNewFile,BufRead *.jinja set syntax=htmljinja
au BufNewFile,BufRead *.mako set ft=mako
au FileType python map <buffer> F :set foldmethod=indent<cr>
au FileType python inoremap <buffer> $r return
au FileType python inoremap <buffer> $i import
au FileType python inoremap <buffer> $p print
au FileType python inoremap <buffer> $f #--- PH ----------------------------------------------<esc>FP2xi
au FileType python map <buffer> <leader>1 /class
au FileType python map <buffer> <leader>2 /def
au FileType python map <buffer> <leader>C ?class
au FileType python map <buffer> <leader>D ?def
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Python settings
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
au BufNewFile,BufRead *.py set expandtab
au BufNewFile,BufRead *.py set nosmartindent
let g:pyindent_open_paren = '&sw'
let g:pyindent_nested_paren = '&sw'
let g:pyindent_continue = '&sw'
""""""""""""""""""""""""""""""
" => JavaScript section
"""""""""""""""""""""""""""""""
au FileType javascript call JavaScriptFold()
au FileType javascript setl fen
au FileType javascript setl nocindent
au FileType javascript imap <c-t> AJS.log();<esc>hi
au FileType javascript imap <c-a> alert();<esc>hi
au FileType javascript inoremap <buffer> $r return
au FileType javascript inoremap <buffer> $f //--- PH ----------------------------------------------<esc>FP2xi
" Linebreak on 500 characters
"set lbr
"set tw=500
set tw=0
set noai " Disable Auto indent
"set ai " Auto indent
"set si " Smart indent
"set wrap " Wrap lines
""""""""""""""""""""""""""""""
" => Vim grep
""""""""""""""""""""""""""""""
let Grep_Skip_Dirs = 'RCS CVS SCCS .svn generated'
set grepprg=/bin/grep\ -nH
" }
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Vim Key (re)Mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Key (re)Mappings {
" The default leader is '\', but many people prefer ',' as it's in a standard
" location. To override this behavior and set it back to '\' (or any other
" character) add the following to your .vimrc.before.local file:
" let g:kd_leader='\'
if !exists('g:kd_leader')
let mapleader = ','
let g:mapleader = ","
else
let mapleader=g:kd_leader
endif
if !exists('g:kd_localleader')
let maplocalleader = '_'
else
let maplocalleader=g:kd_localleader
endif
" The default mappings for editing and applying the kd configuration
" are <leader>ev and <leader>sv respectively. Change them to your preference
" by adding the following to your .vimrc.before.local file:
" let g:kd_edit_config_mapping='<leader>ec'
" let g:kd_apply_config_mapping='<leader>sc'
if !exists('g:kd_edit_config_mapping')
let s:kd_edit_config_mapping = '<leader>ev'
else
let s:kd_edit_config_mapping = g:kd_edit_config_mapping
endif
if !exists('g:kd_apply_config_mapping')
let s:kd_apply_config_mapping = '<leader>sv'
else
let s:kd_apply_config_mapping = g:kd_apply_config_mapping
endif
" Reload vimrc without restart editor ( Breaks toolbar)
" map <leader>se :source ~/.vimrc<CR>
" Easier moving in tabs and windows
" The lines conflict with the default digraph mapping of <C-K>
" If you prefer that functionality, add the following to your
" .vimrc.before.local file:
" let g:kd_no_easyWindows = 1
if !exists('g:kd_no_easyWindows')
map <C-J> <C-W>j<C-W>_
map <C-K> <C-W>k<C-W>_
map <C-L> <C-W>l<C-W>_
map <C-H> <C-W>h<C-W>_
endif
" Wrapped lines goes down/up to next row, rather than next line in file.
noremap j gj
noremap k gk
" End/Start of line motion keys act relative to row/wrap width in the
" presence of `:set wrap`, and relative to line for `:set nowrap`.
" Default vim behaviour is to act relative to text line in both cases
" If you prefer the default behaviour, add the following to your
" .vimrc.before.local file:
" let g:kd_no_wrapRelMotion = 1
if !exists('g:kd_no_wrapRelMotion')
" Same for 0, home, end, etc
function! WrapRelativeMotion(key, ...)
let vis_sel=""
if a:0
let vis_sel="gv"
endif
if &wrap
execute "normal!" vis_sel . "g" . a:key
else
execute "normal!" vis_sel . a:key
endif
endfunction
" Map g* keys in Normal, Operator-pending, and Visual+select
noremap $ :call WrapRelativeMotion("$")<CR>
noremap <End> :call WrapRelativeMotion("$")<CR>
noremap 0 :call WrapRelativeMotion("0")<CR>
noremap <Home> :call WrapRelativeMotion("0")<CR>
noremap ^ :call WrapRelativeMotion("^")<CR>
" Overwrite the operator pending $/<End> mappings from above
" to force inclusive motion with :execute normal!
onoremap $ v:call WrapRelativeMotion("$")<CR>
onoremap <End> v:call WrapRelativeMotion("$")<CR>
" Overwrite the Visual+select mode mappings from above
" to ensure the correct vis_sel flag is passed to function
vnoremap $ :<C-U>call WrapRelativeMotion("$", 1)<CR>
vnoremap <End> :<C-U>call WrapRelativeMotion("$", 1)<CR>
vnoremap 0 :<C-U>call WrapRelativeMotion("0", 1)<CR>
vnoremap <Home> :<C-U>call WrapRelativeMotion("0", 1)<CR>
vnoremap ^ :<C-U>call WrapRelativeMotion("^", 1)<CR>
endif
" The following two lines conflict with moving to top and
" bottom of the screen
" If you prefer that functionality, add the following to your
" .vimrc.before.local file:
" let g:kd_no_fastTabs = 1
if !exists('g:kd_no_fastTabs')
map <S-H> gT
map <S-L> gt
endif
" Stupid shift key fixes
if !exists('g:kd_no_keyfixes')
if has("user_commands")
command! -bang -nargs=* -complete=file E e<bang> <args>
command! -bang -nargs=* -complete=file W w<bang> <args>
command! -bang -nargs=* -complete=file Wq wq<bang> <args>
command! -bang -nargs=* -complete=file WQ wq<bang> <args>
command! -bang Wa wa<bang>
command! -bang WA wa<bang>
command! -bang Q q<bang>
command! -bang QA qa<bang>
command! -bang Qa qa<bang>
endif
cmap Tabe tabe
endif
" Yank from the cursor to the end of the line, to be consistent with C and D.
nnoremap Y y$
" Code folding options
nmap <leader>f0 :set foldlevel=0<CR>
nmap <leader>f1 :set foldlevel=1<CR>
nmap <leader>f2 :set foldlevel=2<CR>
nmap <leader>f3 :set foldlevel=3<CR>