-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
1513 lines (1163 loc) · 43.4 KB
/
Copy pathvimrc
File metadata and controls
1513 lines (1163 loc) · 43.4 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:set ft=vim et sw=4:
set nocompatible " don't be compatible with vi
" -----------------------------------------------------------------------------
" Plugins
" -----------------------------------------------------------------------------
" assumes you have vim-plug installed
call plug#begin('~/.vim/plugged')
" Themes
Plug 'ayu-theme/ayu-vim'
Plug 'bluz71/vim-moonfly-colors', { 'as': 'moonfly' }
Plug 'bluz71/vim-nightfly-colors', { 'as': 'nightfly' }
Plug 'camgunz/amber'
Plug 'catppuccin/vim', { 'as': 'catppuccin' }
Plug 'chriskempson/base16-vim'
Plug 'colepeters/spacemacs-theme.vim'
Plug 'connorholyday/vim-snazzy'
Plug 'doums/darcula'
Plug 'dracula/vim', { 'as': 'dracula' }
Plug 'drsooch/gruber-darker-vim'
Plug 'flazz/vim-colorschemes'
Plug 'ghifarit53/tokyonight-vim'
Plug 'gruvbox-community/gruvbox'
Plug 'joshdick/onedark.vim'
Plug 'junegunn/seoul256.vim'
Plug 'madyanov/gruber.vim'
Plug 'patstockwell/vim-monokai-tasty'
Plug 'phanviet/vim-monokai-pro'
Plug 'rakr/vim-one'
Plug 'rose-pine/vim', { 'as' : 'rosepine' }
Plug 'sainnhe/edge'
Plug 'sainnhe/everforest'
Plug 'sainnhe/gruvbox-material'
Plug 'sainnhe/sonokai'
Plug 'jadomag/curtailed'
Plug 'devsjc/vim-jb'
"indent guides
Plug 'nathanaelkane/vim-indent-guides'
" modeline
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
" lightline
"Plug 'itchyny/lightline.vim'
" Navigate and manipulate files in a tree view.
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" fuzzy searching
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'stsewd/fzf-checkout.vim'
Plug 'jiangmiao/auto-pairs'
" vim for writers
Plug 'reedes/vim-pencil'
" Distraction free writing
Plug 'junegunn/goyo.vim'
"Dim paragraphs above and below active paragraph
Plug 'junegunn/limelight.vim'
"Plug 'ctrlpvim/ctrlp.vim'
Plug 'ntpeters/vim-better-whitespace'
Plug 'vim-perl/vim-perl', { 'for': 'perl', 'do': 'make clean carp dancer highlight-all-pragmas moose test-more try-tiny' }
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-unimpaired'
Plug 'preservim/tagbar'
Plug 'eggbean/resize-font.gvim'
" Show git file changes in the gutter
Plug 'airblade/vim-gitgutter'
"Plug 'mhinz/vim-signify'
" Git wrapper plugin
Plug 'tpope/vim-fugitive'
" Languages and file types
Plug 'vim-python/python-syntax'
Plug 'godlygeek/tabular'
Plug 'preservim/vim-markdown'
"Plug 'tpope/vim-markdown'
Plug 'PotatoesMaster/i3-vim-syntax'
Plug 'Glench/Vim-Jinja2-Syntax'
Plug 'ekalinin/dockerfile.vim'
Plug 'stephpy/vim-yaml'
Plug 'pangloss/vim-javascript'
Plug 'jceb/vim-orgmode'
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
" treesitter support for go syntax highlighting
Plug 'charlespascoe/vim-go-syntax'
" Markdown preview
Plug 'iamcco/markdown-preview.nvim'
Plug 'voldikss/vim-floaterm'
" let vim and tmux work well together
Plug 'tmux-plugins/vim-tmux'
Plug 'christoomey/vim-tmux-navigator'
" Automatically show vim's complete menu while typing.
"Plug 'vim-scripts/AutoComplPop'
" Coc.vim completion
" Use release branch (recommended)
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" Automatically executes filetype plugin indent on and syntax enable"
call plug#end()
" vim-plug automatically executes
if has('syntax') && !exists('g:syntax_on')
syntax enable
endif
" Enable type file detection. Vim will be able to try to detect the type of file in use.
filetype on
" Enable plugins and load plugin for the detected file type.
filetype plugin on
" Load an indent file for the detected file type.
filetype indent on
" Force some filetypes to be a certain type
au bufnewfile,bufRead *.pod set ft=perl
au bufnewfile,bufRead *.sub set ft=perl
function! AdjustFontSize(amount)
let s:font_size = s:font_size + a:amount
:execute "GuiFont! Consolas:h" . s:font_size
endfunction
if has("gui_running")
set guifont=JetBrainsMonoNerdFont\ 12
noremap <C-ScrollWheelUp> :call AdjustFontSize(1)<CR>
noremap <C-ScrollWheelDown> :call AdjustFontSize(-1)<CR>
endif
" -----------------------------------------------------------------------------
" Color settings
" -----------------------------------------------------------------------------
" Enable 24-bit true colors if your terminal supports it.
"if has('termguicolors')
" set termguicolors
"endif
set termguicolors
" https://github.com/vim/vim/issues/993#issuecomment-255651605
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" for 256 colors
set t_Co=256
" Enable syntax highlighting.
syntax enable
" Set the color scheme to dark.
set background=dark
"colorscheme onedark
let g:one_allow_italics = 1 " I love italic for comments
"colorscheme one
"colorscheme snazzy
"colorscheme gruvbox
"colorscheme nightfly
let g:moonflyItalics = v:true
let g:moonflyCursorColor = v:true
let g:moonflyTransparent = v:false
let g:moonflyUndercurls = v:true
let g:moonflyUnderlineMatchParen = v:true
let g:moonflyVirtualTextColor = v:true
let g:moonflyWinSeparator = 2
colorscheme moonfly
" has dark and light versions
"colorscheme curtailed
"colorscheme darcula
"colorscheme catppuccin_latte " light
" dark versions
"colorscheme catppuccin_frappe
"colorscheme catppuccin_macchiato
"colorscheme catppuccin_mocha " darkest
let g:gruvbox_material_ui_contrast='high'
let g:gruvbox_material_background='hard'
"let g:gruvbox_material_foreground='material' " can be material, mix, original
"let g:gruvbox_material_foreground='material' " can be material, mix, original
"let g:gruvbox_material_foreground='mix' " can be material, mix, original
let g:gruvbox_material_foreground='original' " can be material, mix, original
let g:gruvbox_material_disable_italic_comment=0
let g:gruvbox_material_enable_italic=1
let g:grubbox_materal_better_performance=1
let g:gruvbox_material_cursor='orange'
let g:gruvbox_material_transparent_background=0
"let g:gruvbox_material_menu_selection_background='grey'
"let g:gruvbox_material_menu_selection_background='blue'
let g:gruvbox_material_menu_selection_background='orange'
let g:gruvbox_material_sign_column_background='none'
"let g:gruvbox_material_visual='reverse'
let g:gruvbox_material_visual='blue background'
"let g:gruvbox_material_statusline_style='default'
"let g:gruvbox_material_statusline_style='mix'
let g:gruvbox_material_statusline_style='original'
"colorscheme gruvbox-material
"let g:lightline = {'colorscheme' : 'gruvbox_material'}
"let g:disable_bg = 1
"let g:disable_float_bg = 1
"colorscheme rosepine
"colorscheme rosepine_moon " difference is the background
"set background=light
"colorscheme rosepine_dawn
" transparent background
" amber
"colorscheme amber
" ayu
"let ayucolor="light" " for light version of theme
"let ayucolor="mirage" " for mirage version of theme
let ayucolor="dark" " for dark version of theme
"colorscheme ayu
" gruber
"colorscheme GruberDarker
" slightly better version
"colorscheme gruber
" edge_style vailable values: default, aura, neon
let g:edge_style = 'neon'
let g:edge_better_performance = 1
" edge_dim_foreground values 0(default), 1 gray foreground
"let g:edge_dim_foreground = 1
"colorscheme edge
" everforest_background values: 'hard', 'medium'(default), 'soft'
let g:everforest_background = 'hard'
" For better performance
let g:everforest_better_performance = 1
"colorscheme everforest
let g:vim_monokai_tasty_italic = 1 " allow italics, set this before the colorscheme
let g:vim_monokai_tasty_machine_tint = 1 " use `mahcine` colour variant
let g:vim_monokai_tasty_highlight_active_window = 1 " make the active window stand out
"colorscheme vim-monokai-tasty
" sonokai_style values: default, atlantis, andromeda, shusia, maia, espresso
let g:sonokai_style = 'espresso'
let g:sonokai_better_performance = 1
let g:sonokai_enable_italic=1
let g:sonokai_transparent_background=0
"colorscheme sonokai
" tokyonight_style values: night, storm
let g:tokyonight_style = 'night'
let g:tokyonight_enable_italic = 1
"colorscheme tokyonight
"let g:solorized_termcolors=256
"colorscheme solarized
"colorscheme wombat
"colorscheme wombat256
let g:dracula_italic = 1
"colorscheme dracula
"colorscheme wilight256
" seoul256 (dark):
" Range: 233 (darkest) ~ 239 (lightest)
" Default: 237
"let g:seoul256_background = 233
"colorscheme seoul256
" Specific colorscheme settings (must come after setting your colorscheme).
" if (g:colors_name == 'gruvbox')
" if (&background == 'dark')
" hi Visual cterm=NONE ctermfg=NONE ctermbg=237 guibg=#3a3a3a
" else
" hi Visual cterm=NONE ctermfg=NONE ctermbg=228 guibg=#f2e5bc
" hi CursorLine cterm=NONE ctermfg=NONE ctermbg=228 guibg=#f2e5bc
" hi ColorColumn cterm=NONE ctermfg=NONE ctermbg=228 guibg=#f2e5bc
" endif
" endif
" -----------------------------------------------------------------------------
" Highlight Overrides
" -----------------------------------------------------------------------------
":hi clear FoldColumn
hi clear VertSplit
" This leaves a nice underline
":hi clear CursorLine
":hi CursorLine cterm=underline ctermfg=NONE gui=underline guifg=NONE
hi clear SignColumn
" Spelling mistakes will be colored up red.
hi SpellBad cterm=underline ctermfg=203 guifg=#ff5f5f
hi SpellLocal cterm=underline ctermfg=203 guifg=#ff5f5f
hi SpellRare cterm=underline ctermfg=203 guifg=#ff5f5f
hi SpellCap cterm=underline ctermfg=203 guifg=#ff5f5f
" make all comments italic
hi Comment cterm=italic gui=italic
" vim hardcodes background color erase even if the terminfo file does
" not contain bce (not to mention that libvte based terminals
" incorrectly contain bce in their terminfo files). This causes
" incorrect background rendering when using a color theme with a
" background color.
"let &t_ut=''
"if (&term =~ '^xterm' && &t_Co == 256)
" set t_ut= | set ttyscroll=1
"endif
"set t_ut= | set ttyscroll=1
hi clear Cursor
"highlight Cursor guifg=white guibg=black
"highlight iCursor guifg=white guibg=steelblue
" -----------------------------------------------------------------------------
" Status line
" -----------------------------------------------------------------------------
" " Heavily inspired by: https://github.com/junegunn/dotfiles/blob/master/vimrc
" function! s:statusline_expr()
" let mod = "%{&modified ? '[+] ' : !&modifiable ? '[x] ' : ''}"
" let ro = "%{&readonly ? '[RO] ' : ''}"
" let ft = "%{len(&filetype) ? '['.&filetype.'] ' : ''}"
" let fug = "%{exists('g:loaded_fugitive') ? fugitive#statusline() : ''}"
" let sep = ' %= '
" let pos = ' %-12(%l : %c%V%) '
" let pct = ' %P'
" return '[%n] %f %<'.mod.ro.ft.fug.sep.pos.'%*'.pct
" endfunctiot
" let &statusline = s:statusline_expr()
" ----------------------------------------------------------------------------
" Basic Settings
" ----------------------------------------------------------------------------
let $RTP=split(&runtimepath, ',')[0]
let $RC="$HOME/.vimrc"
set encoding=utf-8
" shorten updatetime for faster experience, default is 4000 ms (too long)
set updatetime=50
set redrawtime=4000 "Allow more time for loading syntax on large files, default=2000
"set min/max highlighted lines, from cursor position, helps with slow machines
"syntax sync minlines=200
"syntax sync maxlines=500
set exrc
" don't bell or blink
set noerrorbells visualbell t_vb=
set belloff=all
if (has("autocmd") && has("gui_running"))
autocmd GUIEnter * set vb t_vb=
endif
" Sets cursor styles
" Block in normal, line in insert, underline in replace
"set guicursor=
"set guicursor=n-v-c-sm:block,i-ci-ve:ver25-Cursor,r-cr-o:hor20
"set guicursor=n-v-c-sm:block,i-ci-ve:ver25-Cursor,r-cr-o:hor20
" set guicursor=
" Use a line cursor within insert mode and a block cursor everywhere else.
" Reference chart of values:
" Ps = 0 -> blinking block.
" Ps = 1 -> blinking block (default).
" Ps = 2 -> solid block.
" Ps = 3 -> blinking underline.
" Ps = 4 -> solid underline.
" Ps = 5 -> blinking bar (xterm).
" Ps = 6 -> solid vertical bar (xterm).
"let &t_SI.= "\e[6 q" "SI = INSERT mode
"let &t_SR.= "\e[4 q" "SR = REPLACE mode
"let &t_EI.= "\e[2 q" "EI = NORMAL mode
"For VTE compatible terminals (urxvt, st, xterm, gnome-terminal 3.x, Konsole KDE5 and others), wsltty and Windows Terminal
"let &t_SI = "\<Esc>[6 q"
"let &t_SR = "\<Esc>[4 q"
"let &t_EI = "\<Esc>[2 q"
let &t_SI.= "\e[6 q" "SI = INSERT mode
let &t_SR.= "\e[4 q" "SR = REPLACE mode
"let &t_EI.= "\e[2 q" "EI = NORMAL mode
let &t_EI.= "\e[1 q" "EI = NORMAL mode
" konsole on KDE
"let &t_SI = "\<Esc>]50;CursorShape=6\x7"
"let &t_SR = "\<Esc>]50;CursorShape=4\x7"
"let &t_EI = "\<Esc>]50;CursorShape=2\x7"
" - entered insert mode
" let &t_SI = "^[[5 q^[]12;Magenta\007" " blinking bar (Ss) in magenta (Cs)
" - entered replace mode
" let &t_SR = "^[[0 q^[]12;Red\007" " blinking block (Ss) in red (Cs)
" - leaving insert/replace mode
" let &t_EI = "^[[2 q^[]112\007" " terminal power-on style (Se) and colour (Cr)
" reset the cursor on start (for older versions of vim, usually not required)
" augroup myCmds
" au!
" autocmd VimEnter * silent !echo -ne "\e[2 q"
" augroup END
" line numbers
"set relativenumber " Display relative line numbers
set number " Display line numbers
set numberwidth=1 " using only 1 column while possible
" Toggle relative line numbers and regular line numbers.
nmap <F6> :set invrelativenumber<CR>
set nowrap " do not wrap long lines
" tabs or spaces?
set tabstop=4 " <tab> inserts 4
set softtabstop=4 " <BS> over an autoindent deletes both spaces
set shiftwidth=4 " indent level is 4
set expandtab " use spaces, not tables for autoindent/tab key
set autoindent
set smartindent
set smarttab
" to convert tabs to spaces
" set exandtab
" :retab!
" to convert spaces to tabs
" set noexpandtab
" :retab!
" Saving options in session and view files causes more problems than it
" solves, so disable it
set sessionoptions-=options
set viewoptions-=options
"if !empty(&viminfo)
" set viminfo^=!
"endif
" display whitespace
" to enable use :set list
" displays tabs, line-ends and displays when a line runs off-screen
set listchars=tab:>-,eol:$,trail:-,precedes:<,extends:>,nbsp:+
"from vim-sensible
"set listchars=tab:>\ ,eol:$,trail:-,precedes:<,extends:>,nbsp:+
" Toggle visually showing all whitespace characters.
noremap <F7> :set list!<CR>
inoremap <F7> <C-o>:set list!<CR>
cnoremap <F7> <C-c>:set list!<CR>
set formatoptions+=j " Delete comment character when joining commented lines
" disable comment continuation
set formatoptions-=r formatoptions-=c formatoptions-=o
" to always set these options we use autocmd
autocmd FileType * set formatoptions-=c formatoptions-=r formatoptions-=o formatoptions+=j
" Replace the check for a tags file in the parent directory of the current
" file with a check in every ancester directory
if has('path_extra')
setglobal tags-=./tags tags-=./tags; tags^=./tags;
endif
" correctly highlight $() and other modern affordances in filetype=sh.
if !exists('g:is_posix') && !exists('g:is_bash') && !exists('g:is_kornshell') && !exists('g:is_dash')
let g:is_posix=1
endif
" I hate folding
set foldmethod=manual
set foldlevel=99
set foldlevelstart=99
set nofoldenable " disable folding
" searching
set incsearch
set showmatch
"set nohlsearch " don't leave highlighted search
set hlsearch " highlight search matches
set ignorecase
set smartcase
set gdefault " when substituting :s/// g is always on
set wrapscan " wrap around when searching
set matchpairs+=<:> " Use % to jump between pairs
set virtualedit=block
set backspace=indent,eol,start " allow backspacing over autoindent,EOL,BOL
" sets the cwd to whatever file is in view, allows for better omni completion
"set autochdir
set complete+=kspell
"set completeopt=menuone,longest
set completeopt=menuone,noinsert,noselect
"set complete-=i
"wildmenu
set wildmenu " Menu completion in command mode on <Tab>
set wildmode=full " <Tab> cycles between all matching choices
" Make wildmenu behave like similar to Bash completion.
"set wildmode=list:longest
"set wildchar=<Tab> wildmenu wildmode=full
"set wildcharm=<C-z>
"nnoremap <F5> :b <C-z>
" ignore python crud
set wildignore+=**/virtualenv_run/**,*.pyc,*.pyo,__pychache__
" There are certain files that we would never want to edit with Vim.
" Wildmenu will ignore files with these extensions.
set wildignore+=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx
" provides tab-completion for all file-related tasks
" this appends to the default path
"set path+=**
set path=.,** " search local and sub-dirs
set rtp+=~/.local/bin
"include project directories
"set path+=~/projects/**
set ruler
" moving around
set scrolloff=8 " start scrolling when 8 lines away from bottom
set sidescrolloff=5 " start scrolling to right when 5 characters away
set display+=lastline
set nostartofline
" for faster scrolling
set ttyfast
set ttimeoutlen=1
" Messages, info, status
set title " show title in console title bar
set cursorline " have line indicating the cursor position
"set cursorcolumn " highlight cursor line underneath the cursor vertically
"set colorcolumn=80 " show column line
"set signcolumn=auto
set signcolumn=number
set ruler " show the cursor position
set showcmd
"set showmode " show mode (insert,replace, etc..)
set laststatus=2 " always show statusline even if only 1 window
"set cmdheight=2
set modelines=2
set modeline " allow vim options to be embedded in files
setglobal modeline
set shortmess+=c
set textwidth=0
set mouse=a " allow mouse clicks to change cursor position
"set ttymouse=xterm2 " make vim play nice within tmux
set ttymouse=sgr
set term=xterm
set go=a
set icon
"set clipboard=unnamedplus
" set hidden hides buffers instead of closing them
set hidden
" backups
set nobackup " turn off backups
set nowritebackup
set noswapfile " turn off swap files
" set directory=/tmp " set swap files to be in /tmp
set directory=/tmp//,.
" undo
set undofile
set undodir=~/.vim/undodir
set history=9000 " Set the commands to save in history default is 20
"set paste
set pastetoggle=<F4>
set noautowrite " don't write unless i request it
set noautowriteall " never
set autoread " autommatically reread changed files
set ffs=unix,dos,mac " try recognizing dos, unix & mac line endings
" allways diff v
" disable italicsertically
set diffopt+=vertical
" disable leader timeout
set notimeout
set ttimeout
set spelllang=en_us
if executable('rg')
let g:rg_derive_root='true'
endif
" I can't live without this!
set comments=n:# " python/perl/bash comments
nmap # !!perl -pe'm{^\# ?}?s{^\#}{}:m{\S}?s{^}{\#}:1'<CR><LF>j
" -----------------------------------------------------------------------------
" some useful key bindings
" -----------------------------------------------------------------------------
" set leader key to spacebar
let mapleader=" "
let maplocalleader=" "
" remap C-c to <esc>
nmap <c-c> <esc>
imap <c-c> <esc>
vmap <c-c> <esc>
omap <c-c> <esc>
" Seamlessly treat visual lines as actual lines when moving around.
noremap j gj
noremap k gk
noremap <Down> gj
noremap <Up> gk
inoremap <Down> <C-o>gj
inoremap <Up> <C-o>gk
" to quickly exit insert mode without pressing escape or Ctrl-C/Ctrl-[
"inoremap jj <esc>
"inoremap jk <esc>
"inoremap hj <esc>
" make shift Y tank till end of line, similar to shift D and shift C
nnoremap Y y$
" yank to x11 clipboard
nnoremap <leader>y "*y"
" Keep cursor at the bottom of the visual selection after you yank it.
"vmap y ygv<Esc>
" paste from x11 clipboard
nnoremap <leader>p "*p"
" repaste selected text
nnoremap gp `[v`]
" keeping it centered while searching, zz centre, zv openfold
nnoremap n nzzzv
nnoremap N Nzzzv
" keeps line concatination centered
nnoremap J mzJ`z
"nnoremap <C-j> :cnext<cr>zzzv
" undo break points
inoremap , ,<c-g>u
inoremap . .<c-g>u
inoremap ! !<c-g>u
inoremap ? ?<c-g>u
inoremap ; ;<c-g>u
inoremap : :<c-g>u
inoremap [ [<c-g>u
inoremap } }<c-g>u
inoremap { {<c-g>u
inoremap " "<c-g>u
inoremap ' '<c-g>u
" Jumplist mutations
nnoremap <expr> k (v:count > 5 ? "m'" . v:count : "") . 'k'
nnoremap <expr> j (v:count > 5 ? "m'" . v:count : "") . 'j'
nnoremap <silent> <C-m> <C-i>
" moving text 1 line up or down with ALT j/k in normal,insert and visual modes
" vnoremap k :m '<-2<cr>gv=gv
" vnoremap k :m '>+1<cr>gv=gv
" inoremap k <esc>:m .-2<cr>==gi
" inoremap k <esc>:m .+1<cr>==gi
"nnoremap k :m .-2<cr>==
"nnoremap j :m .+1<cr>==
" add quotes around visual selection
vnoremap " <esc>`>a"<esc>`<i"<esc>
"edit command
cnoremap %% <c-r>=fnameescape(expand('%:h')).'/'<cr>
map <leader>ew :e %%
map <leader>es :sp %%
map <leader>ev :vsp %%
map <leader>et :tabe %%
" better tabbing
vnoremap < <gv
vnoremap > >gv
" better page up/down
" nnoremap <c-n> <c-d>
" nnoremap <c-p> <c-u>
" moves half a screen up/down and stays centered
nnoremap <c-d> <c-d>zz
nnoremap <c-u> <c-u>zz
" fix home/end keys in all modes
nmap OH <home>
cmap OH <home>
imap OH <home>
" move cursor one more char to right in normal mode
nmap OF <end>l
cmap OF <end>
imap OF <end>
" allow '-' to open the parent directory in netrw
nnoremap <silent> - :e %:h<cr>
" fix wierd delete key bug in insert mode
imap [3~ <del>
" Use Shift H and Shift L to move to beginning and end of line
noremap <s-h> 0
nnoremap <s-l> $
" bottom terminal
map <leader>t :bot terminal ++rows=20 ++close<cr>
" open terminal in new tab
map <leader>T :tab term ++close<cr>
" Clear search highlights.
map <Leader><Space> :let @/=''<CR>
" Prevent x and the delete key from overriding what's in the clipboard.
noremap x "_x
noremap X "_x
noremap <Del> "_x
" Prevent selecting and pasting from overwriting what you originally copied.
xnoremap p pgvy
" increment/decrement
nnoremap + <C-a>
nnoremap - <C-x>
" Select all
nmap <C-a> gg<S-v>G
" move cursor to empty space at end of line
set virtualedit+=onemore
nnoremap $ $l
" commented out interferes with Coc mappings
" Edit Vim config file in a new tab.
"noremap <Leader>ev :tabnew $MYVIMRC<CR>
" Source Vim config file.
"noremap <Leader>sv :source $MYVIMRC<CR>
" map abreviations YOU'RE WELCOME!
" -----------------------------------------------------------------------------
" abbreviations
" -----------------------------------------------------------------------------
cabbrev WQ wq
cabbrev Wq wq
cabbrev W w
cabbrev Q q
cabbrev Vimrc e $MYVIMRC<cr>
" -----------------------------------------------------------------------------
" splits and tabs
" -----------------------------------------------------------------------------
"set noequalalways " all windows not same size after split or close
set splitbelow " split new horizontal window below
set splitright " split new textplorer vertically
set tabpagemax=50
":sp for horizontal split
":vsp for vertical split
nnoremap <leader><bar> :vsplit<cr>
nnoremap <leader>- :split<cr>
" allow gf to edit non-existant files
map gf :edit <cfile><cr>
nnoremap <leader>gf :edit cfile<cr>
" gf edit fiel under cursor in same window
" <c-w>f - edit file under cursor in horiz split
" <c-w>vgf - edit file under cursor in vert split
" try mapping to <c-w><c-F>
" edit file under cursor in vert split window
"<c-w>gf - edit file under cursor in new tab
"Ctrl-^ or <c-6> opens previous file
nnoremap <c-w><c-F> <c-w>vgf
" remap window management keys to CTRL + hjkl
nnoremap <c-h> <c-w>h
nnoremap <c-j> <c-w>j
nnoremap <c-k> <c-w>k
nnoremap <c-l> <c-w>l
" remap window managment keys to CTRL + arrowkeys
nnoremap <C-Left> <c-w>h
nnoremap <C-Down> <c-w>j
nnoremap <C-Up> <c-w>k
nnoremap <C-Right> <c-w>l
" cycle through splits with shift <Tab>
"noremap <S-Tab> <c-w>w
" note: alternative below is to just use your mouse
" adjust split sizes more friendly (resizes +/- 3)
nnoremap <silent> <leader>h :vertical resize -3<CR>
nnoremap <silent> <leader>l :vertical resize +3<CR>
nnoremap <silent> <leader>j :resize +3<CR>
nnoremap <silent> <leader>k :resize -3<CR>
" <c-w>o focuses on just one window
" <c-w>| expands split horizontally
" <c-w>_ expands split verically
" <c-w>= equalizes splits
map <leader>= <c-w>=
"map <leader><bar> <c-w>| " I use this for vsplit
map <leader>_ <c-w>_
" removes pipes | that act as seperators on splits
" since i have linenumbers on it acts like a seperator
"set fillchars="vert:,fold:-,eob:~"
" to change character from pipes to something else
"set fillchars+=vert:\
:hi clear VertSplit
" rotate splits from vertical to horizontal or horizontal to vertical
"map <leader>th <c-w>t<c-w>H
"map <leader>tk <c-w>t<c-w>K
" switch between tabes with ALT-1, ALT-2, ALT-3,....ALT-0
" map 1 :tabnext 1
" map 2 :tabnext 2
" map 3 :tabnext 3
" map 4 :tabnext 4
" map 5 :tabnext 5
" map 6 :tabnext 6
" map 7 :tabnext 7
" map 8 :tabnext 8
" map 9 :tabnext 9
" map 0 :tabnext 10
"NOTE: ^[ is Ctrl-v ESC and ^M is Ctrl-v Ctrl-m
" Tab management
nmap <silent> <c-t>n :tabnew<cr>
nmap <silent> <c-t>h :tabprev<cr>
nmap <silent> <c-t>l :tabnext<cr>
nmap <silent> <c-t>c :tabclose<cr>
nmap <silent> <c-t>d :tabe %<cr>
" cycle through tabs with shift TAB
"nmap <S-Tab> :tabnext<cr>
" cycle through tabs with Ctrl-TAB
nmap <silent> <C-Tab> :tabnext<cr>
" Buffer Management
nnoremap <F9> :buffers<cr>:buffer<space>
" cycle through buffers C-Up/Down like vscode
nmap <C-PageUp> :bp<cr>
nmap <C-PageDown> :bn<cr>
"list buffers
nmap <silent> <leader>fb :buffers<cr>
nmap <silent> <leader>fm :marks<cr>
" Toggle quickfix window.
function! QuickFix_toggle()
for i in range(1, winnr('$'))
let bnum = winbufnr(i)
if getbufvar(bnum, '&buftype') == 'quickfix'
cclose
return
endif
endfor
copen
endfunction
nnoremap <silent> <Leader>c :call QuickFix_toggle()<CR>
" Navigate the complete menu items like CTRL+n / CTRL+p would.
inoremap <expr> <Down> pumvisible() ? "<C-n>" :"<Down>"
inoremap <expr> <Up> pumvisible() ? "<C-p>" : "<Up>"
" Select the complete menu item like CTRL+y would.
inoremap <expr> <Right> pumvisible() ? "<C-y>" : "<Right>"
inoremap <expr> <TAB> pumvisible() ? "<C-y>" : "<TAB>"
" Cancel the complete menu item like CTRL+e would.
inoremap <expr> <Left> pumvisible() ? "<C-e>" : "<Left>"
" -----------------------------------------------------------------------------
" Basic autocommands
" -----------------------------------------------------------------------------
" Auto-resize splits when vim gets resized
autocmd VimResized * wincmd =
" Update a buffer's contents on focus if it changed outside of Vim.
au FocusGained,BufEnter * :checktime
" Ensure tabs don't get converted to spaces in Makefiles.
autocmd FileType make setlocal noexpandtab
" Only show the cursor line in the active buffer.
augroup CursorLine
au!
au VimEnter,WinEnter,BufWinEnter * setlocal cursorline
au WinLeave * setlocal nocursorline
augroup END
" Unset paste on InsertLeave.
autocmd InsertLeave * silent! set nopaste
" activate cursorline when in insert mode