vim icon indicating copy to clipboard operation
vim copied to clipboard

theme is transparent in kitty

Open sujitbalasubramanian opened this issue 2 years ago • 8 comments

Theme background was transparent in kitty, but not on alacritty

I switched from alacritty to kitty please help me with the issue

Screenshot

kitty: 2022-04-02-072718_444x326_scrot Alacritty: 2022-04-02-071205_427x356_scrot

Machine Info

  • Vim type (neovim):
  • Vim version: nvim=0.6
  • OS::Arch
  • Terminal/Terminal Emulator/VTE: Kitty
  • TERM environment variable:xterm-kitty

Additional Info

I have already added set termguicolors

sujitbalasubramanian avatar Apr 02 '22 01:04 sujitbalasubramanian

In kitty the background color is made transparent if it is the same as the terminals background color. In alacritty, the background color is made transparent only if there is no background color set. In typical vim color themes, the normal background is set explicitly to a color instead of remaining unset (which is bad for performance, but that's another issue). So since the normal background is set, alacritty wont make it transparent, but kitty will, assuming the color is the same as the terminal's background color.

kovidgoyal avatar Apr 02 '22 03:04 kovidgoyal

is there is any way to make the theme solid

sujitbalasubramanian avatar Apr 02 '22 04:04 sujitbalasubramanian

Change the background color of either the theme or kitty by 1 so they dont match.

kovidgoyal avatar Apr 02 '22 05:04 kovidgoyal

How to change the vim background color to solid and keep kitty transparent

sujitbalasubramanian avatar Apr 02 '22 05:04 sujitbalasubramanian

Surely kitty is configurable to not do any transparency? That seems like a terminal issue.

Have a look at :help dracula-customization if you need to tweak things.

benknoble avatar Apr 02 '22 12:04 benknoble

Sorry I'm not able to change the background. Can you help me how to change background of vim with dracula-customization

sujitbalasubramanian avatar Apr 02 '22 13:04 sujitbalasubramanian

Based on https://sw.kovidgoyal.net/kitty/conf/#color-scheme and https://sw.kovidgoyal.net/kitty/faq/#using-a-color-theme-with-a-background-color-does-not-work-well-in-vim as well as the help page I mentioned, you can do

augroup whatever_you_want
  autocmd!
  autocmd ColorScheme dracula let &t_ut = ''
augroup END

or you could try disabling the background fill colors as mentioned in the same page (:let g:dracula_term = 0).

benknoble avatar Apr 03 '22 13:04 benknoble

both solution not work's for me my init.vim

syntax on
set mouse=a
set clipboard+=unnamedplus
set number
set relativenumber
set tabstop=4  softtabstop=4
set shiftwidth=4
set smartindent
set smartcase
set expandtab
set undodir=~/.cache/nvim/undodir/
set undofile 
set backup
set backupdir=~/.cache/nvim/backup//
set backupcopy=yes
"set nobackup
"set dir=~/.vim/swp/
set noswapfile
set incsearch
set hlsearch
set inccommand=nosplit
set cursorline
set splitright splitbelow
set termguicolors
set laststatus=2
set showtabline=2
"set colorcolumn=80
filetype plugin on
set nocompatible
set encoding=utf-8
set ignorecase

"theme configuration
set background=dark
let g:dracula_term = 0
colorscheme dracula

"copy and paste
inoremap <C-v> <Esc>"+p<Esc>ha
vnoremap <C-c> "+y<CR>
vnoremap <C-x> "+x

"netrw configuration :Explorer
let g:netrw_banner=0
let g:netrw_liststyle=3 
let g:netrw_winsize=20
let g:netrw_browse_split=4

"cursor configuration
let &t_SI.="\e[5 q"
let &t_SR.="\e[4 q"
let &t_EI.="\e[1 q"
let &t_ut=''

source ~/.config/nvim/plug-config/plugin.vim

sujitbalasubramanian avatar Apr 03 '22 14:04 sujitbalasubramanian

@sujitbalasubramanian Are you still having this issue? I assume that you have set the background opacity in Kitty to a value less than 1.0 because you are asking for the background color to be solid only when in Vim. I assume you are also using the Dracula theme for Kitty so that the background color in Vim is the same as that of Kitty and you end up with transparency, as explained above.

I think @benknoble meant to suggest let g:dracula_colorterm = 0, not let g:dracula_term = 0. g:dracula_colorterm is the name of the variable that controls whether the background color is set.

If let g:dracula_colorterm = 0 fixes your issue, great! But, as @kovidgoyal pointed out, an unset background color can be bad for performance. Instead, you can ignore let g:dracula_colorterm = 0 and also try their suggestion of just changing the background color in Vim slightly. When you run :verbose hi Normal, you will see something like:

Normal         xxx ctermfg=253 ctermbg=236 guifg=#F8F8F2 guibg=#282A36                                      
        Last set from ~/dotfiles/vim/plugins/dracula/colors/dracula.vim line 143                            

#282A36 is the Dracula background color. The suggestion is simply to change that value by 1. For example, by running :hi Normal guibg=#282A37. If running :hi Normal guibg=#282A37 fixes your issue, you'll need to add it to your vim configuration to make the change permanent. You can use the autocommand method also suggested above:

augroup CustomizeDracula
  autocmd!
  autocmd ColorScheme dracula highlight Normal guibg=#282A37
augroup END

You will need to define the autocmd above before the colorscheme dracula line, and remember to delete let g:dracula_colorterm = 0.

adriantrunzo avatar Feb 23 '23 04:02 adriantrunzo

Thanks for your help @adriantrunzo. It works fine.

sujitbalasubramanian avatar Feb 23 '23 05:02 sujitbalasubramanian