Merge pull request #51 from jorgemanrubia/fix-nvim-transparency-highlights
Fix nvim transparency to preserve foreground colors
This commit is contained in:
1 file changed
+57
-45
@@ -1,47 +1,59 @@
|
|||||||
-- transparent background
|
-- Make highlight groups transparent while preserving their other attributes
|
||||||
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
|
local function make_transparent(name)
|
||||||
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
|
local ok, hl = pcall(vim.api.nvim_get_hl, 0, { name = name, link = false })
|
||||||
vim.api.nvim_set_hl(0, "FloatBorder", { bg = "none" })
|
if ok then
|
||||||
vim.api.nvim_set_hl(0, "Pmenu", { bg = "none" })
|
hl.bg = nil
|
||||||
vim.api.nvim_set_hl(0, "Terminal", { bg = "none" })
|
vim.api.nvim_set_hl(0, name, hl)
|
||||||
vim.api.nvim_set_hl(0, "EndOfBuffer", { bg = "none" })
|
end
|
||||||
vim.api.nvim_set_hl(0, "FoldColumn", { bg = "none" })
|
end
|
||||||
vim.api.nvim_set_hl(0, "Folded", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "SignColumn", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NormalNC", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "LineNr", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "CursorLineNr", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "WhichKeyFloat", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "TelescopeBorder", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "TelescopeNormal", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "TelescopePromptBorder", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "TelescopePromptTitle", { bg = "none" })
|
|
||||||
|
|
||||||
-- transparent background for neotree
|
local groups = {
|
||||||
vim.api.nvim_set_hl(0, "NeoTreeNormal", { bg = "none" })
|
-- transparent background
|
||||||
vim.api.nvim_set_hl(0, "NeoTreeNormalNC", { bg = "none" })
|
"Normal",
|
||||||
vim.api.nvim_set_hl(0, "NeoTreeVertSplit", { bg = "none" })
|
"NormalFloat",
|
||||||
vim.api.nvim_set_hl(0, "NeoTreeWinSeparator", { bg = "none" })
|
"FloatBorder",
|
||||||
vim.api.nvim_set_hl(0, "NeoTreeEndOfBuffer", { bg = "none" })
|
"Pmenu",
|
||||||
|
"Terminal",
|
||||||
|
"EndOfBuffer",
|
||||||
|
"FoldColumn",
|
||||||
|
"Folded",
|
||||||
|
"SignColumn",
|
||||||
|
"LineNr",
|
||||||
|
"CursorLineNr",
|
||||||
|
"NormalNC",
|
||||||
|
"WhichKeyFloat",
|
||||||
|
"TelescopeBorder",
|
||||||
|
"TelescopeNormal",
|
||||||
|
"TelescopePromptBorder",
|
||||||
|
"TelescopePromptTitle",
|
||||||
|
-- neotree
|
||||||
|
"NeoTreeNormal",
|
||||||
|
"NeoTreeNormalNC",
|
||||||
|
"NeoTreeVertSplit",
|
||||||
|
"NeoTreeWinSeparator",
|
||||||
|
"NeoTreeEndOfBuffer",
|
||||||
|
-- nvim-tree
|
||||||
|
"NvimTreeNormal",
|
||||||
|
"NvimTreeVertSplit",
|
||||||
|
"NvimTreeEndOfBuffer",
|
||||||
|
-- notify
|
||||||
|
"NotifyINFOBody",
|
||||||
|
"NotifyERRORBody",
|
||||||
|
"NotifyWARNBody",
|
||||||
|
"NotifyTRACEBody",
|
||||||
|
"NotifyDEBUGBody",
|
||||||
|
"NotifyINFOTitle",
|
||||||
|
"NotifyERRORTitle",
|
||||||
|
"NotifyWARNTitle",
|
||||||
|
"NotifyTRACETitle",
|
||||||
|
"NotifyDEBUGTitle",
|
||||||
|
"NotifyINFOBorder",
|
||||||
|
"NotifyERRORBorder",
|
||||||
|
"NotifyWARNBorder",
|
||||||
|
"NotifyTRACEBorder",
|
||||||
|
"NotifyDEBUGBorder",
|
||||||
|
}
|
||||||
|
|
||||||
-- transparent background for nvim-tree
|
for _, name in ipairs(groups) do
|
||||||
vim.api.nvim_set_hl(0, "NvimTreeNormal", { bg = "none" })
|
make_transparent(name)
|
||||||
vim.api.nvim_set_hl(0, "NvimTreeVertSplit", { bg = "none" })
|
end
|
||||||
vim.api.nvim_set_hl(0, "NvimTreeEndOfBuffer", { bg = "none" })
|
|
||||||
|
|
||||||
-- transparent notify background
|
|
||||||
vim.api.nvim_set_hl(0, "NotifyINFOBody", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NotifyERRORBody", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NotifyWARNBody", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NotifyTRACEBody", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NotifyDEBUGBody", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NotifyINFOTitle", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NotifyERRORTitle", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NotifyWARNTitle", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NotifyTRACETitle", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NotifyDEBUGTitle", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NotifyINFOBorder", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NotifyERRORBorder", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NotifyWARNBorder", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NotifyTRACEBorder", { bg = "none" })
|
|
||||||
vim.api.nvim_set_hl(0, "NotifyDEBUGBorder", { bg = "none" })
|
|
||||||
Reference in new issue
Block a user