darkrc/vim/plugin/colors.vim

37 lines
1.1 KiB
VimL
Raw Normal View History

let g:only_generic_hl=1
function! s:term_bg_color()
let l:num_color=synIDattr(hlID("normal"), "bg")
2021-12-21 14:45:37 +00:00
if $TERM=="xterm-kitty" || $KITTY_LISTEN_ON != ""
if l:num_color!=""
2023-05-08 13:51:51 +00:00
if match(l:num_color, "^\\d\\{3}$")==0
let l:color=system("kitty @ --to $KITTY_LISTEN_ON get-colors | grep 'color".l:num_color."'")
let l:color=l:color[match(l:color, "#"):]
elseif match(l:num_color, "^#\\x\\{6}$")==0
let l:color=l:num_color
end
2023-05-09 11:34:04 +00:00
call jobstart('kitty @ --to $KITTY_LISTEN_ON set-colors background="'.l:color.'"')
call jobstart("cat ".$HOME."/darkrc/kitty_".&bg.".conf | grep cursor | sed -e 's/ /=/' | xargs -L 1 kitty @ --to $KITTY_LISTEN_ON set-colors")
end
end
endfun
2021-12-21 14:45:37 +00:00
augroup termcolors
au ColorScheme * call <SID>term_bg_color()
augroup END
function! s:term_bg_color_reset()
if $TERM=="xterm-kitty" || $KITTY_LISTEN_ON != ""
if filereadable($HOME."/.dark")
let l:file = $HOME."/darkrc/kitty_dark.conf"
else
let l:file = $HOME."/darkrc/kitty_light.conf"
end
call system("kitty @ --to ".$KITTY_LISTEN_ON." set-colors ".l:file)
end
endfun
augroup termcolors
au VimLeavePre * call <SID>term_bg_color_reset()
augroup END