-
Notifications
You must be signed in to change notification settings - Fork 1
/
.vimrc
685 lines (553 loc) · 22.5 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
" == INDEX == (use '*' to navigate)
"
" 1.- GENERAL_SETTINGS
" 1.1.- AUTO_COMMANDS
" 2.- LEADER_KEY
" 3.- PLUGIN_SETUP
" 3.1 AIRLINE
" 3.2 INDENT_GUIDES
" 3.3 GITGUTTER
" 3.4 LINTING
" 3.5 GOLANG
" 3.6 FZF
" 3.7 BUFEXPLORER
" 3.8 SPLIT_JOIN
" 3.9 TAG_ALONG
" 3.10 VIM_WIKI
" 3.11 LSP
" 4.- FILES_FINDING
" 5.- TAG_NAVIGATION
" 6.- AUTOCOMPLETION
" 7.- COLORS
" 8.- TEXT_SELECTION
" MISCELANEA
"==============================================================GENERAL_SETTINGS
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ignorecase " Do case insensitive matching
set smartcase " Do smart case matching
set incsearch " Incremental search
set hlsearch " Highlight search matches
set autowrite " Automatically save before commands like :next and :make
set hidden " Hide buffers when they are abandoned
set ttyfast
set mouse=a " Enable mouse usage (all modes)
set ruler " show a ruler at the bottom of the page
"set rulerformat=%55(%{strftime('%a\ %e\/%b\ %H:%M\ %p')}\ %5l,%-6(%c%V%)\ %P%)
set number
" set norelativenumber
set scrolloff=8 " start scrollin X lines before cursor hits screen border
set nowrap
set hidden
set vb t_vb=
set ts=2 sts=2 sw=2 expandtab
set backspace=indent,eol,start "" allow backspacing over everything in insert mode
set whichwrap+=<,>,h,l
set dir=~/tmp/ " swap file outside of project grepers reach
set cmdheight=2
if has("gui_macvim")
set macthinstrokes
endif
" disable annoying ruby tooltips from vim-ruby
if !has('nvim')
set balloonexpr=
set noballooneval
endif
" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if &t_Co > 2 || has("gui_running")
syntax on
endif
" Disable useless GUI Toolbar
if has("gui_running")
" set guioptions-=T
" set guioptions-=m
set guioptions=aiA
endif
" ----------------------------------------------------------------AUTO_COMMANDS
if has("autocmd")
augroup OINAK_AUTO
" Unload before loading them again ](better performance upon vimrc reload)
autocmd!
" Uncomment the following to have Vim jump to the last position when
" reopening a file
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
filetype plugin indent on
" Source the vimrc file after saving it
autocmd bufwritepost .vimrc source $MYVIMRC
autocmd FocusLost * silent! wa
" Dark red background for trailing whitespace
highlight ExtraWhitespace guibg=#331111 ctermbg=52
au ColorScheme * highlight ExtraWhitespace guibg=#330000 ctermbg=52
au BufEnter * match ExtraWhitespace /\s\+$/
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
au InsertLeave * match ExtraWhiteSpace /\s\+$/
" Color column 80 (compatible) Better after theme loading
if exists('+colorcolumn')
set colorcolumn=80
" if exists("*matchadd")
" augroup colorColumn
" au!
" au VimEnter,WinEnter * call matchadd('ColorColumn', '\%81v.\+', 100)
" augroup END
" endif
highlight ColorColumn guibg=#331111 cterm=NONE ctermbg=234
else
au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
endif
" Refresh ctags when saveing a ruby file
au FileType {rb} au BufWritePost <buffer> silent! Ctags
au! FileType css,scss setl iskeyword+=-
augroup END
endif
"--------------------------------------------------------------------------TERM
if &term =~ '^xterm'
" insert mode: solid vertical bar
let &t_SI .= "\<Esc>[6 q"
" replace mode: solid underscore
let &t_SI .= "\<Esc>[4 q"
" normal mode ([E]lse): solid block
let &t_EI .= "\<Esc>[2 q"
" 1 or 0 -> blinking block
" 2 -> solid block
" 3 -> blinking underscore
" 4 -> solid underscore
" 5 -> blinking vertical bar
" 6 -> solid vertical bar
endif
" Must be one of: xterm, xterm2, netterm, dec, jsbterm, pterm
if !has('nvim')
set ttymouse=xterm2 "Enable mouse in terminal
endif
" ================================================================== LEADER_KEY
" Required by many others:
" let mapleader=","
let mapleader=" "
" Edit .vimrc configuration file
noremap <Leader>r :e $MYVIMRC<CR>
" ================================================================ PLUGIN_SETUP
" Specify a directory for plugins
" - For Neovim: stdpath('data') . '/plugged'
" - Avoid using standard Vim directory names like 'plugin'
call plug#begin('~/.vim/plugged')
" Snippets - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Plug 'SirVer/ultisnips' " conflitcs with pyhton2/3 installed
" Plug 'honza/vim-snippets'
" Plug 'vim-scripts/AutoComplPop'
" Plug 'ervandew/supertab' " Completion operated by Tab
" GIT - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plug 'tpope/vim-fugitive' " Git integration
Plug 'airblade/vim-gitgutter' " Git markings on the gutter
" SOURCE CODE MANIPULATION - - - - - - - - - - - - - - - - - - - - - - - - - -
Plug 'dense-analysis/ale' " Asynchronous linter integration
Plug 'kana/vim-textobj-user' " requirement of vim-textobj-ruby
Plug 'rhysd/vim-textobj-ruby' " make vim understand ruby blocks as motions
Plug 'AndrewRadev/splitjoin.vim' " Split/Join ruby hashes, arglists, etc
Plug 'AndrewRadev/switch.vim' " Automate common substitutions
Plug 'AndrewRadev/tagalong.vim' " Change closing html-ish tags automatically
Plug 'tpope/vim-commentary' " Commenting shortcuts gc
Plug 'tpope/vim-surround' " change surrounding text object
Plug 'editorconfig/editorconfig-vim' " Editorconfig support
" Languages
Plug 'vim-ruby/vim-ruby' " Ruby support
runtime macros/matchit.vim " support to make '%' recognise do-end, etc
Plug 'tpope/vim-rails' " Rails support
Plug 'tpope/vim-bundler'
Plug 'othree/html5.vim'
Plug 'burnettk/vim-angular'
Plug 'leafgarland/typescript-vim'
Plug 'maxmellon/vim-jsx-pretty'
Plug 'fatih/vim-go'
Plug 'preservim/tagbar'
" FILE/DIRECTORY OPERATIONS - - - - - - - - - - - - - - - - - - - - - - - - -
" Plug 'jlanzarotta/bufexplorer' " Buffer explorer
" Plug 'kien/ctrlp.vim' " fuzzy file finder
" BufferExplorer and ctrlp functions covered by FZF
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " FZF Binary
Plug 'junegunn/fzf.vim' " FZF Vim integration
Plug 'tpope/vim-vinegar' " Use - to navigate folder of current file
" Unicode selector with fzf
" needs: `ln -s ~/.vim/plugged/unicodemoji/plugin/unicodemoji ~/bin/`
Plug 'yazgoo/unicodemoji'
" VIUSAL AIDS - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
" Plug 'bling/vim-airline' " Airline ruler enhancements
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'Yggdroot/indentLine'
Plug 'bignimbus/you-are-here.vim' " name and navigate window splits
"" COLORSCHEME PLUGINS - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Plug 'altercation/vim-colors-solarized'
Plug 'gmist/vim-palette'
Plug 'nanotech/jellybeans.vim'
let g:jellybeans_overrides = {
\ 'background': { 'guibg': '000000' },
\}
" WIP (stuff in test)
Plug 'vim-test/vim-test' " run tests from vim
Plug 'vimwiki/vimwiki'
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh',
\ }
" Display markers on margin
Plug 'kshenoy/vim-signature'
" Autocomplete within commandline with ctrl-N
Plug 'j5shi/CommandlineComplete.vim'
" Use release branch (recommend)
Plug 'neoclide/coc.nvim', {'branch': 'release'}
" make test commands execute using dispatch.vim
let test#strategy = "vimterminal"
" Initialize plugin system
call plug#end()
" (disable) help banner on Netrw file explorer
let netrw_banner=0
" Per default, netrw leaves unmodified buffers open. This autocommand
" deletes netrw's buffer once it's hidden (using ':q', for example)
autocmd FileType netrw setl bufhidden=wipe
let g:netrw_fastbrowse = 0
let g:rubycomplete_rails = 1
let g:rubycomplete_buffer_loading = 1
let g:rubycomplete_classes_in_global = 1
"-----------------------------------------------------------------------AIRLINE
let g:airline#extensions#tabline#enabled = 1
let g:airline_powerline_fonts = 0
"------------------------------------------------------------------------------
"------------------------------------------------------------------INDENT_LINES
let g:indentLine_char = '│'
let g:indentLine_fileTypeExclude = ['json','markdown']
"-----------------------------------------------------------------INDENT_GUIDES
" Add a map of your choice. I prefer to use
" <leader>here. My leader key is set to the
" backslash (\), so by typing \here in normal
" mode, I activate you-are-here.vim. When I
" am ready to close the popups, I use the same
" mapping.
nnoremap <silent> <leader>here :call you_are_here#Toggle()<CR>
" Optional:
" If you want to add a different (shorter?) map
" to close the popups, that option is available.
" I personally prefer to use <ESC> but that's a bit
" intrusive so I don't endorse it :)
" nnoremap <silent> <leader>Here :call you_are_here#Close()<CR>
" Most users wouldn't need to manually refresh you-are-here
" while it's open, but it's possible:
nnoremap <silent> <leader>upd :call you_are_here#Update()<CR>
let g:youarehere_padding=[0,1,0,0]
" <F1> " Invisible characters and colors
nmap <F1> :call you_are_here#Toggle()<CR>
vmap <F1> <ESC>:call you_are_here#Toggle()<CR>
imap <F1> <C-\><C-O>:call you_are_here#Toggle()<CR>
"---------------------------------------------------------------------GITGUTTER
" Config for https://github.com/airblade/vim-gitgutter
highlight SignColumn guifg=#ffffff guibg=#000000 ctermbg=16 ctermfg=100
highlight GitGutterAdd guifg=#66aa66 guibg=#000000 ctermfg=71 ctermbg=16
highlight GitGutterChange guifg=#6666aa guibg=#000000 ctermfg=100 ctermbg=16
highlight GitGutterDelete guifg=#aa6666 guibg=#000000 ctermfg=52 ctermbg=16
let g:gitgutter_enabled = 1
let g:gitgutter_signs = 1
let g:gitgutter_realtime = 1
let g:gitgutter_eager = 1
" let g:gitgutter_sign_column_always = 1
if exists('&signcolumn') " Vim 7.4.2201
set signcolumn=yes
else
let g:gitgutter_sign_column_always = 1
endif
" ----------------------------------------------------------------------LINTING
nmap <F9> :TagbarToggle<CR>
"" ALE Options
let g:ale_linters = {
\ 'ruby': ['ruby','rubocop','brakeman','rails_best_practices', 'solargraph'],
\}
let g:ale_lint_on_save = 1
let g:ale_ruby_rubocop_executable = 'bundle'
" let g:ale_ruby_rubocop_options = '--auto-correct-all'
" let g:ale_ruby_rubocop_auto_correct_all = 1
let g:ale_fixers = {
\ 'css': ['prettier'],
\ 'javascript': ['prettier', 'eslint'],
\ 'typescript': ['prettier', 'eslint'],
\ 'ruby': ['rubocop'],
\}
" function! RubocopAutocorrect()
" execute "!rubocop -a " . bufname("%")
" call SyntasticCheck()
" endfunction
" map <Leader>cop :c ALEFix rubocop<cr>
map <Leader>fix :ALEFix<cr>
function! EslintAutocorrect()
execute "!eslint --fix " . bufname("%")
" call SyntasticCheck()
endfunction
map <Leader>esl :call EslintAutocorrect()<cr>
"------------------------------------------------------------------------GOLANG
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
" Enable goimports to automatically insert import paths instead of gofmt:
let g:go_fmt_command = "goimports"
au FileType go nmap <leader>gr <Plug>(go-run)
au FileType go nmap <leader>gb <Plug>(go-build)
au FileType go nmap <leader>gt <Plug>(go-test)
" au FileType go nmap <leader>gcov <Plug>(go-coverage)
"---------------------------------------------------------------------------FZF
" --color fg:-1,bg:-1,hl:230,fg+:3,bg+:233,hl+:229
" --color info:150,prompt:110,spinner:150,pointer:167,marker:174
" Tell Ag not to color results
" let g:ackprg = 'ag --nogroup --nocolor --column'
" Default options are --nogroup --column --color
" let g:fzf_colors =
" \ { 'fg': ['fg', 'Normal'],
" \ 'bg': ['bg', 'Normal'],
" \ 'hl': ['fg', 'Comment'],
" \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
" \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
" \ 'hl+': ['fg', 'Statement'],
" \ 'info': ['fg', 'PreProc'],
" \ 'border': ['fg', 'Ignore'],
" \ 'prompt': ['fg', 'Conditional'],
" \ 'pointer': ['fg', 'Exception'],
" \ 'marker': ['fg', 'Keyword'],
" \ 'spinner': ['fg', 'Label'],
" \ 'header': ['fg', 'Comment'] }
" command! -bang -nargs=* Ag call fzf#vim#ag(<q-args>, '--color-path "0;36" --color-match "0;33"', fzf#vim#with_preview(), <bang>0)
" Vim allows us to change the program used by :grep. We can tell Vim to use ripgrep instead of grep by adding this inside our vimrc:
set grepprg=rg\ --vimgrep\ --smart-case\ --follow
" Search and repace in multiple files:
" :grep "pizza"
" :cfdo %s/pizza/donut/g | update
" search and replace in select multiple files instead of all files using buffers. Here we can choose which files we want to perform select and replace.
" Clear our buffers (:Buffers) first. Our buffers list should contain only the needed files. We can clear it with %bd | e# | bd# (or restart Vim).
" Run :Files.
" Select all files you want to perform search and replace on. To select multiple files, use Tab / Shift+Tab. This is only possible if we have -m in FZF_DEFAULT_OPTS.
" Run :bufdo %s/pizza/donut/g | update.
" Change between last two files
nnoremap <leader><leader> <c-^>
noremap <Leader>b :Buffers!<CR>
noremap <Leader>f :Files!<CR>
noremap <Leader>g :GFiles!<CR>
noremap <C-p> :Files!<CR>
inoremap <C-p> :Files!<CR>
command! -bang -nargs=* Rg call fzf#vim#grep("rg --column --line-number --no-heading --color=always --smart-case ".shellescape(<q-args>), 1, {'options': '--delimiter : --nth 4..'}, <bang>0)
" With the above, every time we invoke Rg, FZF + ripgrep will not consider filename as a match in Vim.
noremap <C-f> :Rg!<CR>
inoremap <C-f> :Rg!<CR>
" Lines in loaded buffers
noremap <Leader>zl :Lines<CR>
" Lines in the current buffer
noremap <Leader>zbl :BLines<CR>
" Tags in the project (ctags -R)
noremap <Leader>zt :Tags<CR>
" Tags in the current buffer
noremap <Leader>zbt :BTags<CR>
" Tags in the project for the word under cursor
noremap <Leader>t :exe "Tags! ". expand("<cword>")<CR>
noremap <Leader>a :exe "Ag! ". expand("<cword>")<CR>
"" Unicode emojis
nmap <leader>u :Unicodemoji<CR>
nmap <leader>U :UnicodemojiCode<CR>
" -------------------------------------------------------------------BUFEXPLORER
" I am testing to replace this with fzf :Buffers command, thus the uppercase
" noremap <Leader>B :BufExplorer<CR>
" -------------------------------------------------------------------SPLIT_JOIN
let g:splitjoin_split_mapping = ''
let g:splitjoin_join_mapping = ''
nmap sj :SplitjoinJoin<cr>
nmap ss :SplitjoinSplit<cr>
" ---------------------------------------------------------------------TAGALONG
" let g:tagalong_filetypes = ['html', 'xml', 'jsx', 'eruby', 'ejs', 'eco',
" 'php', 'htmldjango', 'javascriptreact', 'typescriptreact']
" let g:tagalong_additional_filetypes = ['custom', 'another']
" ---------------------------------------------------------------------VIM_WIKI
let g:vimwiki_list = [{
\ 'path': '~/vimwiki/',
\ 'syntax': 'markdown',
\ 'ext': '.md',
\ 'template_path': '~/vimwiki/templates/',
\ 'template_default': 'default',
\ 'path_html': '~/vimwiki/site_html/',
\ 'custom_wiki2html': 'vimwiki_markdown',
\ 'html_filename_parameterization': 1,
\ }]
le g:vimwiki_list =[{'auto_diary_index': 1}]
let g:markdown_fenced_languages = ['html', 'ruby', 'vim', 'javascript']
aug MDau
au!
autocmd FileType markdown set conceallevel=0
autocmd FileType vimwiki set conceallevel=0
aug END
"---------------------------------------------------------------------------LSP
" Required for operations modifying multiple buffers like rename.
set hidden
let g:LanguageClient_serverCommands = {
\ 'ruby': ['~/.rbenv/shims/solargraph', 'stdio'],
\ }
let g:LanguageClient_autoStop = 0
nnoremap <F5> :call LanguageClient_contextMenu()<CR>
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
augroup LSP
autocmd FileType ruby setlocal omnifunc=LanguageClient#complete
augroup END
" =============================================================== FILES_FINDING
set path+=** " Search down into subfolders
set wildignore+=*/.bundle/* " exclude Bundler (ruby dependencies)
set wildignore+=*/node_modules/* " exclude node_modules (npm dependencies)
set wildignore+=*/.git/* " exclude git database
set wildmenu " Display all matching entries when we tab complete
nmap <F7> <Esc>:bp<CR>
nmap <F8> <Esc>:bn<CR>
" ===============================================================TAG_NAVIGATION
let g:rails_ctags_arguments = '-f .tags --languages=ruby --exclude=.git --exclude=log --exclude=tmp --exclude=.bundle . $(bundle list --paths |grep -e "returnly\|properties\|image_server") &'
set tags=.tags
" au FileType {rb} au BufWritePost <buffer> silent! Ctags
" au FileType {rb} au BufWritePost <buffer> silent! Ctags
" au! FileType css,scss setl iskeyword+=-
" <F3> " Goto definition (ctags)
imap <F3> <ESC>g]
nmap <F3> <ESC>g]
nmap gt <ESC>g]
nmap rt :Ctags<CR><CR>
vmap <F3> v_g]
imap <F2> <ESC>g<C-]>
nmap <F2> <ESC>g<C-]>
" ============================================================== AUTOCOMPLETION
runtime config/completion.vim
" =======================================================================COLORS
syntax enable
" Toggleable current line/column highlight
highlight CursorLine cterm=NONE ctermbg=234 ctermfg=NONE guibg=#222222 guifg=NONE
highlight CursorColumn cterm=NONE ctermbg=234 ctermfg=NONE guibg=#222222 guifg=NONE
nnoremap <c-f12> :set cursorline! cursorcolumn!<CR>
nnoremap <leader>+ :set cursorline! cursorcolumn!<CR>
" Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:▹\ ,eol:⁋
" hi Search guibg=#66aadd guifg=Black cterm=none gui=none
" hi IncSearch guibg=#66dddd guifg=Black cterm=none gui=none
" <F12> " Invisible characters and colors
nmap <F12> :set list!<CR>
vmap <F12> <ESC>:set list!<CR>gv
imap <F12> <ESC>:set list!<CR>i
hi NonText guifg=#bbbbbb
" For Neovim > 0.1.5 and Vim > patch 7.4.1799 - https://github.com/vim/vim/commit/61be73bb0f965a895bfb064ea3e55476ac175162
" Based on Vim patch 7.4.1770 (`guicolors` option) - https://github.com/vim/vim/commit/8a633e3427b47286869aa4b96f2bfc1fe65b25cd
" https://github.com/neovim/neovim/wiki/Following-HEAD#20160511
if (has('termguicolors'))
set termguicolors
endif
let g:solarized_contrast="high" "default value is normal
let g:solarized_visibility="high" "default value is normal
" let g:solarized_hitrail=1 "default value is 0
" hi CursorLine cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
let g:gruvbox_contrast_dark = 'hard'
let g:gruvbox_contrast_light = 'hard'
set background=dark
" colorscheme gruvbox
" colorscheme oinak
let g:nord_uniform_diff_background = 1
" colorscheme nord
function! ColorschemeLight()
command! -bang -nargs=* Ag call fzf#vim#ag(<q-args>, '--color-path "0;35" --color-match "30;43"', fzf#vim#with_preview(), <bang>0)
colorscheme thegoodluck
" set cursorline! cursorcolumn!
let $BAT_THEME = 'GitHub' " make bat (used for fzf previews) readable
let g:airline_theme='light'
endfunction
function! ColorschemeDark()
command! -bang -nargs=* Ag call fzf#vim#ag(<q-args>, '--color-path "0;36" --color-match "0;33"', fzf#vim#with_preview(), <bang>0)
colorscheme jellybeans
" set nocursorline nocursorcolumn
let $BAT_THEME = 'gruvbox' " make bat (used for fzf previews) readable
let g:airline_theme='jellybeans'
" needed here to override theme value
hi ColorColumn guibg=#331111 cterm=NONE ctermbg=234
hi Search guibg=#66aadd guifg=Black cterm=none gui=none
hi IncSearch guibg=#66dddd guifg=Black cterm=none gui=none
endfunction
nmap <Leader>cd :call ColorschemeDark()<CR>
nmap <Leader>cl :call ColorschemeLight()<CR>
" ============================================================== TEXT_SELECTION
function! CmdLine(str)
call feedkeys(":" . a:str)
endfunction
function! VisualSelection(direction, extra_filter) range
let l:saved_reg = @"
execute "normal! vgvy"
let l:pattern = escape(@", "\\/.*'$^~[]")
let l:pattern = substitute(l:pattern, "\n$", "", "")
if a:direction == 'gv'
call CmdLine("Ack '" . l:pattern . "' " )
elseif a:direction == 'replace'
call CmdLine("%s" . '/'. l:pattern . '/')
endif
let @/ = l:pattern
let @" = l:saved_reg
endfunction
" Visual mode pressing * or # searches for the current selection
" Super useful! From an idea by Michael Naumann
vnoremap <silent> * :<C-u>call VisualSelection('', '')<CR>/<C-R>=@/<CR><CR>
vnoremap <silent> # :<C-u>call VisualSelection('', '')<CR>?<C-R>=@/<CR><CR>
"" Region indent/outdent
vmap < <gv
vmap > >gv
vmap <S-Tab> <gv
vmap <Tab> >gv
"" Bubbling Text
" Bubble single lines
nmap <C-Up> ddkP
nmap <C-Down> ddp
nmap <C-k> ddkP
nmap <C-j> ddp
" Bubble multiple lines
vmap <C-Up> xkP`[V`]=gv
vmap <C-Down> xp`[V`]=gv
vmap <C-k> xkP`[V`]=gv
vmap <C-j> xp`[V`]=gv
" Ctrl-C, Ctrl-V option for copy/paste
vmap <C-c> "+yi
vmap <C-x> "+c
vmap <C-v> c<ESC>"+p
imap <C-v> <ESC>"+pa
" Shift arrows to select
imap <S-Down> <ESC>lvj
vmap <S-Down> j
nmap <S-Down> vj
imap <S-Up> <ESC>vk
vmap <S-Up> k
nmap <S-Up> vk
imap <S-Right> <ESC>vl
vmap <S-Right> l
nmap <S-Right> vl
imap <S-Left> <ESC>vh
vmap <S-Left> h
nmap <S-Left> vh
" reselect pasted text
nnoremap gp `[v`]
" ================================================================== MISCELANEA
" automatically close the quick fix window when leaving a file
aug QFClose
au!
au WinEnter * if winnr('$') == 1 && getbufvar(winbufnr(winnr()), "&buftype") == "quickfix"|q|endif
aug END
" Avoid accidentally enter Ex mode
nnoremap Q <nop>
" change the direction of new splits
set splitbelow
set splitright
" hi Search guibg=#66aadd guifg=Black cterm=none gui=none
" hi IncSearch guibg=#66dddd guifg=Black cterm=none gui=none
"------------------------------------------------------------------------------
ab coaby co-authored-by: <@returnly.com>
ab cobyro co-authored-by: ro-fdm <[email protected]>
ab cobyal co-authored-by: alegoiko <[email protected]>
ab cobybe co-authored-by: bertocq <[email protected]>
ab cobyam co-authored-by: alegoiko <[email protected]>
call ColorschemeDark()