Add kitty color (re-)setting for vim colorschemes

This commit is contained in:
Talia 2020-08-17 15:54:59 +02:00
parent 1f8b05f935
commit 8335890ee5

View file

@ -1,6 +1,25 @@
" For my patched version of the papercolor theme
let g:only_generic_hl=1
function! s:kitty_bg_color()
if $TERM=="xterm-kitty"
let l:num_color=synIDattr(hlID("normal"), "bg")
if l:num_color!=""
let l:color=system("kitty @ get-colors | grep color".l:num_color)
let l:color=l:color[match(l:color, "#"):]
echom system("kitty @ set-colors background=".l:color)
end
end
endfun
if $TERM=="xterm-kitty"
augroup kitty
let s:kitty_bg=system("kitty @ get-colors | grep ^background")
let g:kitty_bg=s:kitty_bg[match(s:kitty_bg, "#"):]
au VimLeavePre * echom system("kitty @ set-colors background=".g:kitty_bg)
augroup END
end
com! Dark silent! let g:colors_name_bak = g:colors_name
\ | let g:ayucolor="dark"
\ | let g:arcadia_Daybreak=0
@ -9,6 +28,7 @@ com! Dark silent! let g:colors_name_bak = g:colors_name
\ | set bg=dark
\ | silent! exec "colorscheme ".g:colors_name_bak
\ | silent! delc PaperColor
\ | silent! call <SID>kitty_bg_color()
com! Light silent! let g:colors_name_bak = g:colors_name
\ | let g:ayucolor="light"
\ | let g:arcadia_Daybreak=1
@ -17,16 +37,17 @@ com! Light silent! let g:colors_name_bak = g:colors_name
\ | set bg=light
\ | silent! exec "colorscheme ".g:colors_name_bak
\ | silent! delc PaperColor
\ | silent! call <SID>kitty_bg_color()
" Commands for some colorschemes I often use
com! Ayu colorscheme ayu
com! Arcadia colorscheme arcadia
com! Alduin colorscheme alduin
com! Moria colorscheme moria
com! Molokai colorscheme molokai
com! Iceberg colorscheme iceberg
com! Papercolor colorscheme PaperColor | delc PaperColor
com! Firewatch colorscheme two-firewatch
com! Arcadia colorscheme arcadia | call <SID>kitty_bg_color()
com! Alduin colorscheme alduin | call <SID>kitty_bg_color()
com! Moria colorscheme moria | call <SID>kitty_bg_color()
com! Molokai colorscheme molokai | call <SID>kitty_bg_color()
com! Iceberg colorscheme iceberg | call <SID>kitty_bg_color()
com! Papercolor colorscheme PaperColor | delc PaperColor | call <SID>kitty_bg_color()
com! Firewatch colorscheme two-firewatch | call <SID>kitty_bg_color()
if $TERM=="xterm-kitty"
Arcadia