sainnhe / sonokai

High Contrast & Vivid Color Scheme based on Monokai Pro
MIT License
1.68k stars 120 forks source link

Can't have transparent background Everywhere #79

Closed RichestHumanAlive closed 1 year ago

RichestHumanAlive commented 1 year ago

Edit : I finally found that I just had to define the following highlight commands:

vim.cmd("hi NormalFloat ctermbg=NONE guibg=NONE")
vim.cmd("hi FloatTitle ctermbg=NONE guibg=NONE")
vim.cmd("hi FloatBorder ctermbg=NONE guibg=NONE")

And here is the result for Mason.nvim for example :

Went from : image

to: image

Should add this for LSP Diagnostics

vim.cmd("hi DiagnosticFloatingHint  ctermbg=NONE guibg=NONE guifg=#42E66C")
vim.cmd("hi DiagnosticFloatingInfo ctermbg=NONE guibg=NONE guifg=#0876c5")
vim.cmd("hi DiagnosticFloatingWarn ctermbg=NONE guibg=NONE guifg=#E8AB53")
vim.cmd("hi DiagnosticFloatingError ctermbg=NONE guibg=NONE guifg=#ff5189")

Freely choosing foreground colors (guifg)

output:

image


I have done the following steps before reporting this issue:

Operating system/version

Windows 11 Pro Insider Preview 22H2 - OS build 25252.1000

Terminal emulator/version

Powershell 7.3.0-rc.1

$TERM environment variable

NULL

Tmux version

No response

Feature matrix

diffview: require("diffview.health").check()

Checking plugin dependencies

Checking external dependencies

gitsigns: require("gitsigns.health").check()

lsp: health#lsp#check

server status

server configuration: omnisharp-lsp

Performance

mason: require("mason.health").check()

mason.nvim report

`

`

nvim: health#nvim#check

Configuration

Performance

Remote Plugins

nvim-treesitter: require("nvim-treesitter.health").check()

Installation

OS Info:

{ machine = "x86_64", release = "10.0.25252", sysname = "Windows_NT", version = "Windows 10 Pro" }

Parser/Features H L F I J

The following errors have been detected:

provider: health#provider#check

Clipboard (optional)

Python 3 provider (optional)

Python virtualenv

Ruby provider (optional)

Node.js provider (optional)

Perl provider (optional)

telescope: require("telescope.health").check()

Checking for required plugins

Checking external dependencies

===== Installed extensions =====

Telescope Extension: projections

vim.lsp: require("vim.lsp.health").check()

vim.treesitter: require("vim.treesitter.health").check()

Minimal vimrc that can reproduce this bug.

call Plug#begin()
    Plug 'sainnhe/sonokai'
call plug#end()

let g:sonokai_style = 'atlantis'
let g:sonokai_better_performance = 1
let g:sonokai_show_eob = 1 
let g:sonokai_diagnostic_text_highlight = 0
let g:sonokai_diagnostic_line_highlight = 0
let g:sonokai_diagnostic_virtual_text = 'grey' 
set background=dark
let g:sonokai_transparent_background=2
colorscheme sonokai

Steps to reproduce this bug using minimal vimrc

  1. Launch nvim

  2. Show Lsp Diagnostic popup using

:lua vim.lsp.diagnostic.show_line_diagnostics()

output: image

  1. Run command

    :LspInfo

    output: image

  2. Run command

    :Mason

output: image

Expected behavior

I was expecting transparent backgrounds for for lsp diagnostics popup, lspinfo window and Mason window as for the main windows.

For example, something like this for lsp diagnostics:

image

Actual behavior

Opaque background.


I am pretty new to the vim ecosystem and maybe the solution to my issue is somewhere else but please be lenient and let me know.

Sonokai is an Awesome 💯 !

sainnhe commented 1 year ago

I thought setting NormalFloat (which is the default highlight group of floating window) to be transparent, but the problem is that not all floating window have a border, instead the designs in most of them are using a brighter background to distinguish between normal background colors, so I gave up this idea.

Another thing that needs to be considered is that vim actually shouldn't make everything transparent, some elements should use a different background color (e.g. the status line). If you want to make your vim fully transparent, you should consider switching to a terminal emulator that supports blurred background (e.g. konsole). This will fully blur every elements in vim, which will look much better.

RichestHumanAlive commented 1 year ago

Thank you for your answer and tips 🙂. I understand a little better how the Vim UI works.

Indeed, I use Windows Terminal which supports blurred background and that's why, for better appearance, I disabled as many backgrounds as possible using:

let g:sonokai_transparent_background=2

Also, what I like about the transparency of Vim is that it is pseudo-transparent actually, inside the Vim UI and you can't see through a floating window even if it's "transparent". Floating transparent windows actually just takes the lowest background of the UI at that specific area. With borders it's even better like here:

Even if there is text behind the floating window, the text will not appear and will be covered by pseudo-transparent background. Unless I misunderstood something.

This is precisely want I need to achieve for all my floating windows.

Should look at how to customize the background for each plugin that uses floating windows or is there a way to overwrite the default appearance of all floating windows of Vim?

Thanks in advance for your time 🙂.

Edit : I finally found that I just had to define the following highlight commands:

vim.cmd("hi NormalFloat ctermbg=NONE guibg=NONE")
vim.cmd("hi FloatTitle ctermbg=NONE guibg=NONE")
vim.cmd("hi FloatBorder ctermbg=NONE guibg=NONE")

And here is the result for Mason.nvim for example :

Went from : image

to: image

Should add this for LSP Diagnostics

vim.cmd("hi DiagnosticFloatingHint  ctermbg=NONE guibg=NONE guifg=#42E66C")
vim.cmd("hi DiagnosticFloatingInfo ctermbg=NONE guibg=NONE guifg=#0876c5")
vim.cmd("hi DiagnosticFloatingWarn ctermbg=NONE guibg=NONE guifg=#E8AB53")
vim.cmd("hi DiagnosticFloatingError ctermbg=NONE guibg=NONE guifg=#ff5189")

Freely choosing foreground colors (guifg)

output:

image

Thank you for your attention.

dmytrodubinin commented 1 year ago

Any solutions for Linux? I have the same problem on Arch Linux with Alacritty. The solution above didn't help.