forked from RyannDaGreat/rp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathryan_vimrc.py
More file actions
2211 lines (1832 loc) · 101 KB
/
ryan_vimrc.py
File metadata and controls
2211 lines (1832 loc) · 101 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 should boot super duper fast
" - vim should run super duper fast
" - should have many convenience shortcuts
" - ALL the important ones should be listed under SHORTCUTS, so we can swap out one plugin for another if we want to
" - the SHORTCUTS section is basically a specification
" - It's ok to have duplicate shortcuts, as long as they're for things you use very often and the shortcuts are on different parts of the keyboard.
" - Though redundant, duplicate shortcuts can make editing faster by letting you move your hands less on they keybord - opting for the closest shortcut to your fingers at a given time. Often I've found this is useful in practice, especially for exiting vim etc.
"SHORTCUTS
" ; is :
" gcc comments out lines
" K shows documentation for variable (python)
" \g goes to definition (python)
" \r renames a variable under cursor (python)
" \u finds all usages of variable under cursor (Python)
" F3 Toggles relative number
" F4 toggles the minimap
" F5 toggles NERDTree " F6 toggles indent guidelines " F7 toggles line wrapping
" F8 toggles a global vim session (saves the layout like tabs and splits etc)
" F8F8 just saves the current vim session globally, instead of loading
" \ff triggers a search for text inside files, like sublime's ctrl+shift+f
" \[space], while in Quickfix, previews a result
" gs is an interactive alternative to g< and g>. When in interactive argument swap mode try moving arguments with hjkl, g, G, r, s
" \ctrl+p will fuzzy-search most recent files
" tq closes the current tab
" td or ts duplicates (aka splits) the current tab
" tq is an alias for :quit
" <esc>q is also an alias for :quit
" ctrl+h, ctrl+j, ctrl+k, ctrl+l: This will drag the current line, character or selection's text up, down, left or right
" gc toggles comments. gcc toggles comment on line. gc4k toggles comments four lines up. gc in visual mode toggles comments in selection. Etc
" fh cycles between different syntax color schemes
" ctrl+wz toggles the zoom of a window, like in tmux
" alt+w is equivalent to control+w (alt+w is esc followed by w). This is useful when using vim in a web browser (where control+w would close the tab)
"Multicursor Plugin Stuff " ctrl+down, ctrl+up adds a second cursor above or below
" shift+right, shift+left selects one character to the right or the left
" control+leftclick places a new cursor where you clicked (multi-cursor plugin)
" \\\ will place a multicursor where your vim cursor is (move vim cursors with arrow keys, move multicursors with hjkl)
" While there are multiple cursors:
" M turns on multiline mode (by default, multiple cursor selection regions are limited to one line per cursor. This allows multi-line selections per cursor)
" \\a inserts spaces to 'align' all cursors to the same position. Similar to \ac followed by \al in rp's microcompletions
" \\n and \\N inserts a number on every cursor, so you can write 1,2,3,4,5 etc very fast. The only difference between \n and \N is the side of the cursor the numbers are placed.
" tab toggles multi-cursor's visal mode. toggles whether you're selecting text or just moving cursors
" [ and ] moves the terminal's cursor to the next or previous multicurors. Useful when your multi-cursors are beyond your current view, and you want to see all of them.
" Use the middle mouse button to make box selections
"Vim motions specific to python:
" * Allows for viM (select entire def) etc
" * https://github.com/jeetsukumaran/vim-pythonsense
" vaf selects a python function
" vif selects a python function's body
" vac selects a python class
" vic selects a python class's body
" ]m moves to the next python function
" [m moves to the previous python function
" * python.vim:
" ]k moves up to the previous line with the same indent
" ]j moves down to the next line with the same indent
" * https://github.com/michaeljsmith/vim-indent-object
" vii selects the inner body of the current code block (vim in indent)
" vai selects the entire code block
"Vanilla Tips/Tricks/Shortcuts I like to remember:
" :tab split Duplicates a tab
" \c when added to the end of a search query in vim, makes the query case-insensitive
" o when in visual mode, this will swap which side of the selection your cursor is on
" gv reselects your last visual-mode selection. Useful for repeating > and < from visual mode
" ^x^f when in insert mode, will autocomplete file paths (^x is for selecting a type of autocompletion, ^f is for files)
" ^v starts visual block mode. Then, use I to insert text.
" :only closes all other windows in the current tab
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Allow backspace to delete over everything in insert mode, solving the issue where
" backspace only deletes characters typed in the current insert mode session on macOS
set backspace=indent,eol,start
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim' " This is the program that downloads all of our plugins...
Plugin 'tpope/vim-obsession' " Automatically saves vim sessions, such as the pane and tab layouts etc before closing vim so you can restore your layouts
nnoremap <F8> :source ~/.Session.vim<CR>:Obsession ~/.Session.vim<CR>
nnoremap <F8><F8> :Obsession ~/.Session.vim<CR>
nnoremap td :tab split<cr>
nnoremap tn :tabnew<cr>
nnoremap ts :tab split<cr>
nnoremap tc :tab close<cr>
nnoremap \co gg"+yG<c-o>zz
nnoremap <esc>w <c-w>
Plugin 'machakann/vim-swap' "Allows us to swap the arguments of functions and definitions with g< and g> and gs. See https://github.com/machakann/vim-swap
" Failed attempt to get control+up and control+down to work in tmux
" noremap <esc>[1;5A <c-up>
" noremap <esc>[1;5B <c-down>
""Open jupyter notebooks in vim. Needs 'pip install jupytext'
"Plugin 'goerz/jupytext.vim'
"This is an alternative plugin for editing .ipynb files...
" Note: pip install notedown
" Plugin 'szymonmaszke/vimpyter'
" What does this do? Does it work? TODO find out
Plugin 'gmarik/sudo-gui.vim'
" In visual mode, allow < and > to indent multiple times without having to manually reselect the text
vnoremap < <gv
vnoremap > >gv
"Below is a lighter-weight alternative to csv.vim, that activates when opening a file that has .csv or .tsv syntax, but not the .csv or .tsv file extension
" NOTE: While csv.vim is installed, rainbow_csv will be invisible.
Plugin 'mechatroner/rainbow_csv' " Syntax highlighting for .csv and .tsv files. When displaying .tsv or .csv files, highlight each column in a different color
"https://github.com/mg979/vim-visual-multi
let g:VM_mouse_mappings = 1
Plugin 'mg979/vim-visual-multi' "Multiple cursors
" - select words with Ctrl-N (like Ctrl-d in Sublime Text/VS Code)
" - create cursors vertically with Ctrl-Down/Ctrl-Up
" - select one character at a time with Shift-Arrows
""ctrl+p will search for files
Plugin 'kien/ctrlp.vim'
let g:ctrlp_show_hidden = 1
"Fuzzy search recent files - lol its freaking useless, it doesnt sort based on match
"nnoremap <leader><C-p> :CtrlPMRU<CR>
" Better javascript syntax highlighting
Plugin 'pangloss/vim-javascript'
"fzf requires an external program to be installed
"Plugin 'junegunn/fzf.vim' "To quickly search for files..
""ctrl+p will search for files
"" nnoremap <C-p> :<C-u>FZF<CR>
"" Mapping selecting mappings
"nmap <leader><tab> <plug>(fzf-maps-n)
"xmap <leader><tab> <plug>(fzf-maps-x)
"omap <leader><tab> <plug>(fzf-maps-o)
"" Insert mode completion
"imap <c-x><c-k> <plug>(fzf-complete-word)
"imap <c-x><c-f> <plug>(fzf-complete-path)
"imap <c-x><c-l> <plug>(fzf-complete-line)
" let g:indentLine_color_gui = '#000000'
" let g:indentLine_setColors = 0
" I COULDN'T GET THIS TO WORK. I HAVE A NEW SOLUTION ON THE BOTTOM.
" Plugin 'gsiano/vmux-clipboard' " Allows us to synchronize yanks between separate VIM processes (useful in TMUX for example)
" let mapleader = ","
" map <silent> <leader>y :WriteToVmuxClipboard<cr>
" map <silent> <leader>p :ReadFromVmuxClipboard<cr>
" map <silent> y :WriteToVmuxClipboard<cr>
" map <silent> p :ReadFromVmuxClipboard<cr>
Plugin 'ronakg/quickr-preview.vim' " When in a Quickfix window (aka the search result preview window, like you'd see if using \u or \ff), let us use \[space] to preview a result in multiple lines
"Plugin 'severin-lemaignan/vim-minimap' " Adds a minimap to vim. Can be seen by pressing 'F4'
" Plugin 'wfxr/code-minimap'
" Plugin 'wfxr/minimap.vim'
"My own version of wfxr/minimap.vim - only needs RP to run
Plugin 'RyannDaGreat/minimap.vim'
:hi minimapRange ctermbg=black
:hi minimapCursor ctermbg=blue ctermfg=cyan
" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin on GitHub repo
Plugin 'nathanaelkane/vim-indent-guides'
" Plugin 'christoomey/vim-system-copy' "This doesn't seem to work...
Plugin 'scrooloose/nerdtree' "File explorer. Get it by pressing F5
Plugin 'jistr/vim-nerdtree-tabs' "Make NERDTree persist across different tabs
" Plugin 'tpope/vim-commentary' "Allows commenting out code with 'gcc' etc
Plugin 'tomtom/tcomment_vim' " JS in HTML isn't commented right with tpope's. This is hopefully more powerful. https://github.com/tpope/vim-commentary/issues/60
"Shortcut to comment out functions in python without commenting whitespace below them...
nmap gcd vifokgc
Plugin 'mhinz/vim-startify' "Shows the startup menu
" Plugin 'dkprice/vim-easygrep' "Currently disabled until I figure out a good way to use it
" plugin from http://vim-scripts.org/vim/scripts.html
" Plugin 'L9'
" Git plugin not hosted on GitHub
" Plugin 'git://git.wincent.com/command-t.git'
" git repos on your local machine (i.e. when working on your own plugin)
" Plugin 'file:///home/gmarik/path/to/plugin'
" The sparkup vim script is in a subdirectory of this repo called vim.
" Pass the path to set the runtimepath properly.
" Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
" Install L9 and avoid a Naming conflict if you've already installed a
" different version somewhere else.
" Plugin 'ascenator/L9', {'name': 'newL9'}
" https://github.com/mgedmin/taghelper.vim
Plugin 'mgedmin/taghelper.vim'
" set statusline=%<%f\ %h%m%r\ %1*%{taghelper#curtag()}%*%=%-14.(%l,%c%V%)\ %P
"
" set statusline=%<%f\ %h%m%r\ %{taghelper#curtag()}%*%=%-14.(%l,%c%V%)\ %P
" Only file NAME, not path:
" set statusline=%<%t\ %h%m%r\ %{taghelper#curtag()}%*%=%-14.(%l,%c%V%)\ %P
" Attempt to center the taghelper
set statusline=%<%t\ %h%m%r%=\ %{taghelper#curtag()}\ %=%-14.(%l,%c%V%)\ %P
"Shows the number of lines we're selecting in visual mode on the bottom right of the screen
"If we're selecting from a single row, shows the num charactes
"If we're selecting multiple lines, shows the number of lines
:set showcmd
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"
"
"
"
"
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set undofile "Persistent undo
set mouse=a
set nu
set paste
set cursorline
"Highlight all search results
set hlsearch
" noremap : ;
noremap ; :
" map [1;5A <C-Up>
" map [1;5B <C-Down>
" map [1;2D <S-Left>
" map [1;2C <S-Right>
" cmap [1;2D <S-Left>
" cmap [1;2C <S-Right>
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
" Better search highlight color: blue
"hi Search ctermfg=NONE ctermbg=blue
hi Search ctermfg=white ctermbg=blue
" Some styling; the vertical separators are ugly as hecklestein
nmap <C-C> cp
" NOTE: To see all available colors, use :help cterm-colors
set fillchars+=vert:\|
set fillchars+=vert:▎
"set fillchars+=vert:\
" set fillchars+=vert:⁞
hi VertSplit ctermbg=black ctermfg=darkgray
hi VertSplit ctermbg=darkcyan ctermfg=black
hi LineNr ctermfg=darkcyan
hi LineNr ctermfg=gray
hi LineNr ctermfg=darkgray
hi LineNr ctermbg=black
hi CursorLineNR cterm=bold ctermfg=lightcyan
" function ToggleWrap()
" if (&wrap == 1)
" set nowrap
" else
" set wrap
" endif
" endfunction
" map <F7> :call ToggleWrap()<CR>
" map! <F9> ^[:call ToggleWrap()<CR>
"let us toggle paste mode with the shortcut key:
" set pastetoggle=<F2>
set list "Initially, we're not in list mode, so we <F3
nmap <F9> : set list! <CR> : hi ryan_tabs ctermfg=DarkGray <CR> : match ryan_tabs /\t/ <CR>
" Let us see tabs and spaces when we're NOT in paste mode...
" The | at the end is so if this vimrc is formatted with stripping whitespace off all strings we still have spaces at the end of them. | in vim is like ; in python, making multiline commands in one line
let &showbreak='↪ '
let &listchars='tab:▸ '
"Initial highlighting for the ▸ and · displayed over whitespace
hi clear SpecialKey
hi SpecialKey ctermfg=darkgray
hi ryan_tabs ctermfg=darkgray
:match ryan_tabs /\t/
" Function to toggle space visualization in listchars
" https://chat.openai.com/share/f125f059-9cf1-4f42-a076-bbc69d4ba988
function! ToggleSpaceVisualization()
if &list && match(&listchars, 'space:·') >= 0
"Delete 'space:·' from listchars
:let &listchars = substitute(&listchars, ',space:·', '', '')
" Basically does this - :let &listchars = 'tab:▸ '
else
"Add 'space:·' to listchars
" Basically does this - :let &listchars = 'space:·,tab:▸ '
:let l:other_listchars = substitute(&listchars, 'space:[^,]*', '', '')
:let &listchars = l:other_listchars . (l:other_listchars[-1:] == ',' ? '' : ',') . 'space:·'
endif
endfunction
" Toggle relative line number
nmap <F3> : set invrelativenumber <CR>
" Toggle NERDTree
nmap <F5> : NERDTreeTabsToggle <CR>
" nmap <F5> : NERDTreeToggle <CR>
"Tons of vim color schemes
Plugin 'dracula/vim'
Plugin 'franbach/miramare'
Plugin 'ghifarit53/tokyonight-vim'
"Plugin 'sickill/vim-monokai'
"Plugin 'noah/vim256-color' " 256-color schemes for vim
Plugin 'RyannDaGreat/vim-wombat256mod'
Plugin 'kyoz/purify' ", { 'rtp': 'vim' }
"Plugin 'NLKNguyen/papercolor-theme'
Plugin 'boschni/vim-sublime256'
function! Fansi()
" Color schemes are disabled because it lags over SSH. Probably because it uses more bandwidth for 256 colors?
" See https://github.com/noah/vim256-color/tree/master/colors
" Use: Type ':color t\' and you'll see a list of themes to choose from
" NOTE: The default color theme is set torwards the bottom of the .vimrc file, in a function that's run after loading vim
" set termguicolors "For RLAB. I'm basically always using truecolor terminals nowadays...
" highlight Normal ctermfg=grey ctermbg=240
set t_Co=256 "Enable 256 colors in vim
if !exists("g:colors_name")
colorscheme wombat256mod
elseif g:colors_name=='wombat256mod'
colorscheme dracula
elseif g:colors_name=='dracula'
" colorscheme distinguished
" elseif g:colors_name=='distinguished'
" colorscheme hybrid
" elseif g:colors_name=='hybrid'
" colorscheme jellybeans
" elseif g:colors_name=='jellybeans'
" colorscheme darcula
" elseif g:colors_name=='Darcula'
colorscheme miramare
elseif g:colors_name=='miramare'
colorscheme sublime256
elseif g:colors_name=='sublime256'
"Sublime256 is a better version of this
" colorscheme monokai
" elseif g:colors_name=='monokai'
colorscheme tokyonight
elseif g:colors_name=='tokyonight'
"Kinda ugly lol
" colorscheme PaperColor
" elseif g:colors_name=='PaperColor'
" colorscheme flattown
" elseif g:colors_name=='flattown'
" colorscheme apprentice
" elseif g:colors_name=='apprentice'
" colorscheme badwolf
" elseif g:colors_name=='badwolf'
" colorscheme molokai
" elseif g:colors_name=='molokai'
" colorscheme vilight
" elseif g:colors_name=='vilight'
" colorscheme babymate256
" elseif g:colors_name=='babymate256'
" colorscheme codeschool
" elseif g:colors_name=='codeschool'
colorscheme wombat256mod_grb
elseif g:colors_name=='wombat256mod_grb'
colorscheme wombat256mod_rbg
elseif g:colors_name=='wombat256mod_rbg'
colorscheme wombat256mod_brg
elseif g:colors_name=='wombat256mod_brg'
colorscheme wombat256mod_bgr
elseif g:colors_name=='wombat256mod_bgr'
colorscheme wombat256mod_gbr
elseif g:colors_name=='wombat256mod_gbr'
" colorscheme default
"elseif g:colors_name=='default'
colorscheme wombat256mod
else
colorscheme wombat256mod
endif
call RyanHighlightDefaults()
"Display the color
echo g:colors_name
endfunction
function RyanHighlightDefaults()
" call SetDefaultTabbarTheme()
:hi TabLineFill ctermfg=255 ctermbg=238 cterm=NONE guifg=#eeeeee guibg=#444444
:hi XTFill ctermbg=233 cterm=bold guibg=#121212
:hi XTFill ctermbg=235
"SET BACKGROUND BRIGHTNESS:
" highlight Normal ctermbg=233
:highlight Normal ctermbg=234 guibg=#1c1c1c
:highlight Identifier ctermfg=170 guifg=#d75fd7
" highlight Structure ctermfg=221 "Like map, set, but not print
"Highlighting for the ▸ and · displayed over whitespace
:hi clear SpecialKey
:hi SpecialKey ctermfg=darkgray
:hi SpecialKey ctermfg=237
"highlight ryan_tabs ctermfg=236 ctermbg=234
"highlight ryan_spaces ctermfg=236 ctermbg=234
:highlight ryan_tabs ctermfg=238 guifg=#262626 ctermbg=none
:highlight ryan_spaces ctermfg=235 guifg=#262626 ctermbg=none
"UPDATE GITGUTTER COLORS: https://github.com/airblade/vim-gitgutter/issues/614
:highlight DiffAdd guifg=#000000 guibg=#f5deb3 ctermfg=16 ctermbg=223
:highlight DiffChange guifg=#000000 guibg=#87cefa ctermfg=16 ctermbg=117
:highlight DiffDelete guifg=#000000 guibg=#8a8a8a ctermfg=16 ctermbg=245
let g:gitgutter_override_sign_column_highlight = 0
:highlight GitGutterAdd guifg=#009900 ctermfg=2 cterm=bold ctermbg=232 guibg=#080808
:highlight GitGutterChange guifg=#bbbb00 ctermfg=3 cterm=bold ctermbg=232 guibg=#080808
:highlight GitGutterDelete guifg=#ff2222 ctermfg=9 cterm=bold ctermbg=232 guibg=#080808
:highlight GitGutterChangeDelete guifg=#ff8000 ctermfg=208 cterm=bold ctermbg=232 guibg=#080808
:highlight GutterMarks guifg=#F07fff ctermfg=2 cterm=bold ctermbg=232 guibg=#080808
:highlight PudbBreakpointSign ctermfg=red cterm=bold ctermbg=232 guibg=#080808
" call RyanGitGutterHighlights()
:highlight ALEErrorSign ctermfg=199 cterm=bold ctermbg=232 guifg=#ff0087 guibg=#080808
:highlight clear SignColumn
:highlight SignColumn ctermbg=232 guibg=#080808
:highlight LineNr ctermbg=232 ctermfg=240 guibg=#080808 guifg=#585858
" :highlight CursorLineNr ctermbg = 240
:highlight cursorline ctermbg=236 guibg=#303030
:highlight FoldColumn ctermbg=232 ctermfg=103 guibg=#080808 guifg=#8787af
:highlight Folded ctermbg=232 ctermfg=103 guibg=#080808 guifg=#8787af
" highlight FoldColumn ctermfg=60
" highlight Folded ctermfg=60
:highlight StatusLine term=bold,reverse ctermfg=230 ctermbg=238 gui=italic guifg=#ffffd7 guibg=#444444
:highlight StatusLineNC term=reverse ctermfg=241 ctermbg=238 guifg=#626262 guibg=#444444
:highlight StatusLineNC ctermbg=236 ctermfg=239 guibg=#303030 guifg=#4e4e4e cterm=underline
:hi VertSplit ctermbg=232 ctermfg=238 cterm=none guibg=#080808 guifg=#444444
"For ↪
:hi clear NonText
:hi NonText ctermfg=240
:hi minimapRange ctermbg=237
:hi minimapCursor ctermbg=61 ctermfg=228
" highlight Called ctermfg=228 guifg=#FF00FF
" " syntax match Called "\w*("
" syntax match Called "\w\+\ze("
:highlight SignColumn ctermbg=232 guibg=#080808
"For 'blueyed/vim-diminactive'
:hi ColorColumn ctermbg=233 guibg=#121212
let g:diminactive_use_colorcolumn = 1
let g:diminactive_use_syntax = 1
let g:diminactive_filetype_blacklist = ['startify']
let g:diminactive_buftype_blacklist = ['nofile', 'nowrite', 'acwrite', 'quickfix', 'help']
let g:diminactive_buftype_blacklist = []
let g:diminactive_filetype_blacklist = []
:silent! DimInactive
:silent! DimInactiveSyntaxOff
"Below the text, at the ~ ~ ~ ~'s
:hi EndOfBuffer ctermbg=0
:hi EndOfBuffer ctermbg=16 ctermfg=236
"MY MANUAL REGEX'S
:highlight Parenthesis ctermfg=176 guifg=#FF00FF
:syntax match Parenthesis "[()]"
:highlight Brackets ctermfg=176 guifg=#FF00FF
:syntax match Brackets "[\[\]{}()]"
:syntax match Statement "[-=+*/&@<>\|~%^]"
"FORMAT OPTIONS:
" cterm=bold
" cterm=underline
" cterm=italic
" cterm=reverse
" cterm=none
"Call this function to see what higlight group the cursor is on so you can highlight it manually
"Good for debugging: https://stackoverflow.com/questions/9464844/how-to-get-group-name-of-highlighting-under-cursor-in-vim
function! SynGroup()
let l:s = synID(line('.'), col('.'), 1)
echo synIDattr(l:s, 'name') . ' -> ' . synIDattr(synIDtrans(l:s), 'name')
endfun
" Indentline ▏characters are in the Conceal group
:hi clear Conceal
:hi Conceal ctermfg=237
:hi DiffAdd ctermfg=111 ctermbg=236 cterm=reverse
:hi DiffChange ctermfg=188 ctermbg=236 cterm=reverse
:hi DiffDelete ctermfg=222 ctermbg=236 cterm=reverse
:hi DiffText ctermfg=145 ctermbg=236 cterm=reverse
endfunction
" fh = Fansi Highlight
nnoremap fh :call<space>Fansi()<cr>:colorscheme<cr>
" Instead of having to type :q! have vim ask us 'Would you like to save? Yes or no'
set confirm
" Python JEDI plugin commands (from their git page)
" Look at the below to learn how to effectively use the JEDI plugin!
" \g goes to definition
" \r is to rename a variable
" \n shows all usages of a given variable
" control+space triggers intelligent autocompletion
" K shows documentation for a python function/class/module. Just like regular vim.
let g:jedi#goto_assignments_command = "<leader>g"
let g:jedi#documentation_command = "K"
let g:jedi#usages_command = "<leader>u"
let g:jedi#completions_command = "<C-Space>"
let g:jedi#rename_command = "<leader>rn"
" This is can be laggy and can pop up unexpectedly. Fuck it - I don't need them. Just use rp.
let g:jedi#completions_enabled = 0
"I'm not sure what the next 3 do, so for now I'll comment them out...
" let g:jedi#goto_stubs_command = "<leader>s"
" let g:jedi#goto_command = "<leader>d"
" let g:jedi#goto_definitions_command = ""
" Save us from some lag and don't automatically show python function signatures; leave that for when we're using rp
let g:jedi#show_call_signatures = 0
" Disable swap files. This might be controversial, but I think .swp files might be more of a pain in the butt than they're worth...vim just never crashes...
" set noswapfile
"Enable autocompletion menu while typing vim commands (after pressing :)
"To do this, press 'tab'. For example, try :w[tab] and :write will be an option
set wildmenu
" Plugin 'chrisbra/csv.vim' " Provides an excel-like column editor for .csv files
" Plugin 'klen/python-mode' " An impressively full-featured plugin that makes vim much more like a python ide. But it's a bit too bulky for my tastes...
" This plugin allows us to visually drag text selections up and down in visual mode
" https://github.com/matze/vim-move
Plugin 'matze/vim-move'
let g:move_key_modifier = 'C'
" Let the middle mouse button do box selections, like in sublime
" Fun fact: By default, you can do box selections with quadruple-clicks...
" Source: https://stackoverflow.com/questions/33731468/how-to-assign-visual-block-selection-to-mouses-middle-button-in-vim
noremap <MiddleMouse> <4-LeftMouse>
noremap <MiddleDrag> <LeftDrag>
" Increase vim's command history size. By default it only stores the 15 most recent commands.
" https://vi.stackexchange.com/questions/2920/how-to-further-increase-cmdline-history-size
set viminfo=!,'10000,<50,s10,h,:10000
" https://github.com/mduan/python.vim
" This is complementary to vim-pythonsense
" Adds shortcuts for jumping between python blocks etc
" Plugin 'mduan/python.vim'
Plugin 'RyannDaGreat/python.vim' "I removed all ] shortcuts from it as they interfere with my own shortcuts
" Graveyard of failed attempts at fuzzy autocompletion
" Plugin 'ycm-core/YouCompleteMe'
" Plugin 'maralla/completor.vim'
" https://github.com/junegunn/fzf.vim
" Plugin 'junegunn/fzf', { 'do': { -> fzf#install() } }
" Plugin 'junegunn/fzf.vim'
" " https://vim.fandom.com/wiki/Fuzzy_insert_mode_completion_(using_FZF)
" function! PInsert2(item)
" let @z=a:item
" norm "zp
" call feedkeys('a')
" endfunction
" function! CompleteInf()
" echo "CLBO"
" let nl=[]
" let l=complete_info()
" for k in l['items']
" call add(nl, k['word']. ' : ' .k['info'] . ' '. k['menu'] )
" endfor
" call fzf#vim#complete(fzf#wrap({ 'source': nl,'reducer': { lines -> split(lines[0], '\zs :')[0] },'sink':function('PInsert2')}))
" endfunction
" imap <c-e> <CMD>:call CompleteInf()<CR>
"MY FUNCTIONS:
function! ExtractVariable() range
"Written by Ryan Burgert, May 3 2024.
"This is for extracting a variable from the visual selection in python
"It doesn't need rope or any fancy library - its very simple!
"Written with aid of Claude Opus (and a LOT of manual intervention lol)
" Get the new variable name from the user
let var_name = input("Enter the new variable name: ")
" Save the current register contents
let saved_reg = getreg('"')
let saved_regtype = getregtype('"')
" Yank the selected text
normal! gvy
" Delete the selected text and replace it with the variable name
execute "normal! gv\"_c" . var_name
" Create a mark at the current position
normal! m9
" Get the current indentation
" Insert line above while preserving indentation
" This is correct regardless of whether O preserves idents or not
let indent = matchstr(getline('.'), '^\s*')
normal! O
normal! d0
execute "normal! i" . indent . var_name . " = "
" Paste the yanked text at the end of the line
normal! p
" Move back to the mark then delete it
normal! `9
delmark 9
" Put cursor after variable name
normal! $F=la
" Restore the original register contents
call setreg('"', saved_reg, saved_regtype)
endfunction
function! PropagateWhitespace()
" Ryan May 3 2024
" Great for when using indent guides!
" Modifies whole buffer right now
" https://chat.openai.com/share/f125f059-9cf1-4f42-a076-bbc69d4ba988
" Get the current position
let l:save_pos = getpos(".")
" Start from the bottom of the file or current visual selection
let l:start_line = line("v")
let l:end_line = line(".")
if l:start_line == l:end_line
let l:start_line = 1
let l:end_line = line("$")
endif
" Variable to keep the last non-empty line's indentation
let l:last_indent = ''
" Iterate over each line from bottom to top
for l:num in range(l:end_line, l:start_line, -1)
let l:line = getline(l:num)
if l:line =~ '^\s*$'
" Line is empty, replace its whitespace
call setline(l:num, l:last_indent)
else
" Line is not empty, update the last non-empty line's indentation
let l:last_indent = matchstr(l:line, '^\s*')
endif
endfor
" Restore the cursor position
call setpos('.', l:save_pos)
endfunction
function! StripWhitespace()
" Ryan May 3 2024
" Modifies whole buffer right now
" https://vi.stackexchange.com/questions/454/whats-the-simplest-way-to-strip-trailing-whitespace-from-all-lines-in-a-file
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
endfunction
" Zoom / Restore window.
" FROM https://stackoverflow.com/questions/13194428/is-better-way-to-zoom-windows-in-vim-than-zoomwin
function! s:ZoomToggle() abort
if exists('t:zoomed') && t:zoomed
execute t:zoom_winrestcmd
let t:zoomed = 0
else
let t:zoom_winrestcmd = winrestcmd()
resize
vertical resize
let t:zoomed = 1
endif
endfunction
command! ZoomToggle call s:ZoomToggle()
nnoremap <silent> <C-W>z :ZoomToggle<CR>
nnoremap <silent> <esc>wz :ZoomToggle<CR>
syntax on
set shortmess-=S "Show the count of the search like item 5/10 etc https://stackoverflow.com/questions/4668623/show-count-of-matches-in-vim
Plugin 'simeji/winresizer' "Use control+e to resize windows
" KEY MAPPINGS:
"Vimdiff mappings: d> and d<
"Get or put diff hunks with d< and d>
autocmd VimEnter * if &diff | execute 'nnoremap <silent> d> :if winnr() == 1 <Bar> diffput <Bar> else <Bar> diffget <Bar> endif<CR>' | endif
autocmd VimEnter * if &diff | execute 'nnoremap <silent> d< :if winnr() == 1 <Bar> diffget <Bar> else <Bar> diffput <Bar> endif<CR>' | endif
" Shifting lines https://chat.openai.com/share/05160497-c34c-426f-b9f6-8cf10aec09f5
" Normal Mode: Move current line down with Ctrl-j
nnoremap <C-j> :m .+1<CR>==
" Normal Mode: Move current line up with Ctrl-k
nnoremap <C-k> :m .-2<CR>==
" Visual Mode: Move selected lines down with Ctrl-j
vnoremap <C-j> :m '>+1<CR>gv=gv
" Visual Mode: Move selected lines up with Ctrl-k
vnoremap <C-k> :m '<-2<CR>gv=gv
"Shifting Tabs
" Use gr to go to the previous tab
nnoremap gr :tabprevious<CR>
" Use gt to go to the next tab
nnoremap gt :tabnext<CR>
" Move current tab one position to the left, with wrap-around
nnoremap gR :if tabpagenr() == 1<CR>:tabmove $<CR>:else<CR>:tabmove -1<CR>:endif<CR><CR>
" Move current tab one position to the right, with wrap-around
nnoremap gT :if tabpagenr() == tabpagenr('$')<CR>:tabmove 0<CR>:else<CR>:tabmove +1<CR>:endif<CR><CR>
"Buffer switching [b and ]b
" Use ]b to go to the next buffer
nnoremap ]b :bnext<CR>
" Use [b to go to the previous buffer
nnoremap [b :bprevious<CR>
"Minimap toggle and Statusbar toggle and tab bar toggle
" Toggle the tab bar between always displaying and displaying only when there are multiple tabs using F4+t
nnoremap <F4>t :if &showtabline == 2<CR>:set showtabline=1<CR>:else<CR>:set showtabline=2<CR>:endif<CR><CR>
nnoremap <leader>jt :if &showtabline == 2<CR>:set showtabline=1<CR>:else<CR>:set showtabline=2<CR>:endif<CR><CR>
" Toggle the status bar between always displaying and displaying only when there are multiple windows using F4+s
nnoremap <F4>s :if &laststatus == 2<CR>:set laststatus=1<CR>:else<CR>:set laststatus=2<CR>:endif<CR><CR>
nnoremap <leader>js :if &laststatus == 2<CR>:set laststatus=1<CR>:else<CR>:set laststatus=2<CR>:endif<CR><CR>
" Toggle Minimap
" Silent in case we trigger it inside the minimap. Don't care about that error.
nmap <F4> :silent! MinimapToggle <CR>
nmap <leader>jm :silent! MinimapToggle <CR>
" Toggle Gitgutter
nmap <F4>g : GitGutterToggle <CR>
nmap <leader>jg : GitGutterToggle <CR>
" Gitgutter Commit Selection
nnoremap <leader>jG :call<space>GitGutterSelectDiffBase()<CR>
"Doesn't work - idk why
" " NerdTree
" nnoremap <F4>b : NERDTreeTabsToggle <CR>
" nnoremap <leader>jb : NERDTreeTabsToggle <CR>
"Linting Toggle
map <leader>jl :ALEToggle<return>
" Lines Toggle
map <leader>jn :windo set nu!<return>
"Disable Q, which is annoying. Why not reload?
nnoremap Q :e<cr>
"Added Nov1 2023
"GIT STUFF:
"NERDTREE:
" A plugin that lets us see which files are modified in NERDTree
Plugin 'Xuyuanp/nerdtree-git-plugin'
let g:NERDTreeGitStatusIndicatorMapCustom = {
\ 'Modified' :'✹',
\ 'Staged' :'✚',
\ 'Untracked' :'✭',
\ 'Renamed' :'➜',
\ 'Unmerged' :'═',
\ 'Deleted' :'✖',
\ 'Dirty' :'✗',
\ 'Ignored' :'☒',
\ 'Clean' :'✔︎',
\ 'Unknown' :'?',
\ }
"GIT GUTTER: \jg, zg, [h, ]h, \hu, \hp
set updatetime=100 " This is the recommended update interval from airblade/gitgutter's github page. By default, it's 4 seconds.
nmap ]h <Plug>(GitGutterNextHunk)
nmap [h <Plug>(GitGutterPrevHunk)
omap ih <Plug>(GitGutterTextObjectInnerPending)
omap ah <Plug>(GitGutterTextObjectOuterPending)
xmap ih <Plug>(GitGutterTextObjectInnerVisual)
xmap ah <Plug>(GitGutterTextObjectOuterVisual)
nmap <leader>hu <Plug>(GitGutterUndoHunk)
nmap <leader>hp <Plug>(GitGutterPreviewHunk)
" Git Gutter"
set updatetime=250
let g:gitgutter_max_signs = 500
let g:gitgutter_map_keys = 0 " No mapping
let g:gitgutter_override_sign_column_highlight = 0 " Colors
let g:gitgutter_sign_allow_clobber = 0 " Let other plugins take priority over gutter
let g:gitgutter_sign_priority = -10
function RyanGitGutterHighlights()
highlight GitGutterDelete guifg=#ff2222 ctermfg=1
highlight GitGutterAdd guifg=#009900 ctermfg=2
highlight GitGutterChange guifg=#bbbb00 ctermfg=3
highlight GitGutterChangeDelete ctermfg=4
endfunction
" Initial theme: make background black to match gutter
highlight SignColumn ctermbg=black
highlight GitGutterDelete ctermbg=black
highlight GitGutterAdd ctermbg=black
highlight GitGutterChange ctermbg=black
highlight GitGutterChangeDelete ctermbg=black
call RyanGitGutterHighlights()
Plugin 'airblade/vim-gitgutter'
silent! call gitgutter#disable() " Disable it by default
"Folding with zg
function! EnableGitGutterAndFold() abort
GitGutterBufferEnable
call timer_start(250, {-> execute('GitGutterFold')})
endfunction
nnoremap zg :call EnableGitGutterAndFold()<cr>
"GITIGNORE SYTAX HIGHLIGHTING:
Plugin 'gisphm/vim-gitignore' " Highlight .gitignore files
"GIT BLAME: \gb \gB --> p
" Small shortcut to print blame info for current line
Plugin 'zivyangll/git-blame.vim'
nnoremap <Leader>gb :<C-u>call gitblame#echo()<CR>
Plugin 'tpope/vim-fugitive'
nnoremap <Leader>gB :Git blame<CR>
" In this mode, press 'p' to preview (don't use <CR>)
"PYTHON STUFF:
"IMPORT SORT: ^i
"DISABLED Because it slowed down startup (only a tiny bit - like .04 seconds)
" if has('python3')
" Plugin 'fisadev/vim-isort' " You need pip install isort for this to work. Activate with control+i in visual mode, or the :ISort command
" endif
"MACCHIATO: ⌥l
Plugin 'smbl64/vim-black-macchiato' "Autformat specific sections of python code using pip install black-macchiato
" autocmd FileType python xmap <buffer> <Esc>l <plug>(BlackMacchiatoSelection)
autocmd FileType python nmap <buffer> <Esc>l <plug>(BlackMacchiatoCurrentLine)
autocmd FileType python vnoremap <buffer> <Esc>l :BlackMacchiato<cr>
"RPY FILES:
autocmd BufRead,BufNewFile *.rpy set filetype=python "Treat .rpy files as python files
autocmd BufRead,BufNewFile *.rprc set filetype=python "Treat .rprc files as python files
autocmd BufRead,BufNewFile *ryan_vimrc.py set filetype=vim "Treat ryan_vimrc.py as a vimrc
"OUTLINER: \jo
" Add an outliner for python so we can quickly jump between functions and classes
" Works for several languages: python, latex, html, and more
" Plugin 'vim-voom/VOoM'
Plugin 'RyannDaGreat/VOoM' " Don't spam vim errors when invalid syntax, put the error in the outliner instead
let g:voom_syntax = 'python'
function! VoomWithSyntax()
"A list of all Voom-supported languages, and their filetype-to-voom-command translations
"If we can't find it, just default to python syntax and probably show an error lol
let syntax_map = {
\ 'python' : 'python',
\ 'tex': 'latex',
\ 'html' : 'html',
\ 'markdown' : 'markdown',
\ 'asciidoc' : 'asciidoc',
\ 'cwiki' : 'cwiki',
\ 'dokuwiki' : 'dokuwiki',
\ 'fmr' : 'fmr',
\ 'fmr1' : 'fmr1',
\ 'fmr2' : 'fmr2',
\ 'fmr3' : 'fmr3',
\ 'hashes' : 'hashes',
\ 'inverseAtx' : 'inverseAtx',
\ 'latexDtx' : 'latexDtx',
\ 'org' : 'org',
\ 'pandoc' : 'pandoc',
\ 'paragraphBlank' : 'paragraphBlank',
\ 'paragraphIndent' : 'paragraphIndent',
\ 'paragraphNoIndent' : 'paragraphNoIndent',
\ 'rest' : 'rest',
\ 'taskpaper' : 'taskpaper',
\ 'thevimoutliner' : 'thevimoutliner',
\ 'txt2tags' : 'txt2tags',
\ 'viki' : 'viki',
\ 'vimoutliner' : 'vimoutliner',
\ 'vimwiki' : 'vimwiki',
\ 'wiki' : 'wiki',
\ }
let g:voom_syntax = get(syntax_map, &filetype, 'python')