From ab7c8af4c99170942dbf78dc19b75748c4e2ac5e Mon Sep 17 00:00:00 2001 From: AbhirupPanda Date: Sun, 6 Feb 2022 23:07:19 +0530 Subject: [PATCH] transparentbg plugin and whichkey update --- .DS_Store | Bin 0 -> 6148 bytes lua/.DS_Store | Bin 0 -> 6148 bytes lua/user/.DS_Store | Bin 0 -> 8196 bytes lua/user/transparent.lua | 125 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 125 insertions(+) create mode 100644 .DS_Store create mode 100644 lua/.DS_Store create mode 100644 lua/user/.DS_Store create mode 100644 lua/user/transparent.lua diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..0e6c131dba511b3d1d05620b24a4d45d7694b839 GIT binary patch literal 6148 zcmeHK%Wl&^6ur|JY_~$n0t6c*OKhVMSo9$_ZkjAAK^HZG1)yN#sI_oCRpO9E6vzMXLL4E++sY=e#16Q zj}H_)$6+o%CAmz{<_WD?1*`)9w*vg_I@F~T%BXC7zxx>L{!*qE;jVaeN;66t?286_ z^EW%g>;*}h(6}BWzBgh#WKnP?h|TegxXvfe=tnK1mvl%6G^8VnXxLzLM%US`+vXIH z8#x$OGM}ECz3ehM&$DUS>-`iPE$7Z%*Y({k_d|3l=TRA#vuQt`yyMnuDf47ikCQjq zcs^?1KafQkXT^A;0Byld%5(z2Tz{9I39h@&kFe!iNgf8US;AR6?sBy+ajSR9|V0sJGJjd_(u6@tPX h$Ew0d@gul0j0Ic)h6XE*=z-ZE0VRVitOEa3fh%`-pL+lR literal 0 HcmV?d00001 diff --git a/lua/.DS_Store b/lua/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3ea9e694e3e3811208e8944fb464bba40dacfc3d GIT binary patch literal 6148 zcmeHK%}T>S5Z-O0X(&PtiXH=Ai&hU+@e*S_cr~I2mD-q~!I+i&*h4AgsxRc5_&PeX zyD4b(B#4w5nEfWRGaKgHu$y6wajy)w7_%8;El|XU1;aOj^Qbe@(4HnB$2E=^m;F0{xs7)zvXE(9Fv=hGKEDQ!Nt_qm?i+73jfF+iw9K}7 z<==^sUkr;f_lDU8KAj4Y1hqX3&f;h^u$K=-S`6bf%49+uMi6p&9;cxgd7@0iT;}>} z!m?V{z+N4XcecA7r?)rhILh4Z_9hdnwX(jse=@jF9#ZkFnCI|WN?Foa!wVSGa-RGw zO+<1fN+%xs8YFZF}Us=xJrk4SI1WhRXXGH&9IJsGuIso*Nq2vWH{rl zLK=wyV&F3a*!zLlc>f>$-2clU8i)a6U_Ke(M&IvyP@BG6XR5@z)&ac+MZvgA;WPyd ic@;w}Ud3ymQo!$^0qAP16oLnYegq^9G!O%S%D@Mva8%I% literal 0 HcmV?d00001 diff --git a/lua/user/.DS_Store b/lua/user/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..3cf6a03f77458e7d1871b1e76ee097812bfad637 GIT binary patch literal 8196 zcmeHM!A{#i5S;}is0^Ve#HEsdph*1#7tsUf-YcAt(zGVFf@#%D=k1C96D*V;`56AtS>X1c{otGXi&cnq8%Pv$XPOSr% ztGc+tOB;;=V_=;D*6y!Rw^!20m$-hfC*!If<1P=>Z}gMD+A!ls@$zjW~z3 z8Dp${sIgUukKRqd&J^f`EsZcnXG>4Y;40{U+rrW9*@}k+mCX&a1Ut#XBtX-;o~A zu=~~HVJ_d5i??860q+v|QXXPthCDaQUY+J$8R(-L^^;jkW=k1ZMJ-_OE4-V)=J0-G zj{o#xYoTAEb2rl4O|iwu5p2}hPgjcOuPl(WL8}^Jj6GBydAgA^>@RYo`(d5IM?`w*Zs L*kBAiDFgoif1Fh- literal 0 HcmV?d00001 diff --git a/lua/user/transparent.lua b/lua/user/transparent.lua new file mode 100644 index 0000000..ae5faf2 --- /dev/null +++ b/lua/user/transparent.lua @@ -0,0 +1,125 @@ +local M = {} + +local config = { + enable = false, + groups = { + "Normal", + "Comment", + "Constant", + "Special", + "Identifier", + "Statement", + "PreProc", + "Type", + "Underlined", + "Todo", + "String", + "Function", + "Conditional", + "Repeat", + "Operator", + "Structure", + "LineNr", + "NonText", + "SignColumn", + "CursorLineNr", + "EndOfBuffer", + }, + extra_groups = {}, + exclude = {}, +} + +local clear_group_bg = function(group, highlights) + if group then + if vim.tbl_contains(config.exclude, group) or vim.fn.highlight_exists(group) == 0 then + return + end + if not highlights then + highlights = vim.api.nvim_exec("highlight " .. group, true) + end + else + if highlights then + grou = vim.split(highlights, " ")[1] + else + return + end + end + + if vim.tbl_contains(config.exclude, group) then + return + end + + if highlights:match("links to") then + return + end + + local term = highlights:match([[term=([%w#]+)]]) or "NONE" + local ctermfg = highlights:match([[ctermfg=([%w#]+)]]) or "NONE" + local gui = highlights:match([[gui=([%w#]+)]]) or "NONE" + local guifg = highlights:match([[guifg=([%w#]+)]]) or "NONE" + vim.cmd( + string.format( + "hi %s term=%s ctermfg=%s ctermbg=NONE gui=%s guifg=%s guibg=NONE", + group, + term, + ctermfg, + gui, + guifg + ) + ) +end + +local function _clear_bg() + for _, group in ipairs(config.groups) do + clear_group_bg(group) + end + + if type(config.extra_groups) == "string" then + if config.extra_groups == "all" then + local hls = vim.split(vim.api.nvim_exec("highlight", true), "\n") + for _, hl in ipairs(hls) do + clear_group_bg(nil, hl) + end + else + clear_group_bg(config.extra_groups) + end + else + for _, group in ipairs(config.extra_groups) do + clear_group_bg(group) + end + end +end + +function M.clear_bg() + if vim.g.transparent_enabled ~= true then + return + end + -- ? some plugins calculate colors from basic highlights + -- : clear immediately + _clear_bg() + -- ? some plugins use autocommands to redefine highlights + -- : clear again after a while + vim.defer_fn(_clear_bg, 500) +end + +function M.toggle_transparent(option) + if option == nil then + vim.g.transparent_enabled = not vim.g.transparent_enabled + else + vim.g.transparent_enabled = option + end + if vim.g.colors_name then + vim.cmd("colorscheme " .. vim.g.colors_name) + else + vim.cmd("doautocmd ColorScheme") + end +end + +function M.setup(user_config) + config = vim.tbl_extend("force", config, user_config) + if vim.g.transparent_enabled == nil then + vim.g.transparent_enabled = config.enable + end +end + +return Mp