Skip to content

Commit

Permalink
refactor: remove support 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
zztrieuzz committed Oct 6, 2022
1 parent b7eb9fb commit 9967837
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 30 deletions.
2 changes: 1 addition & 1 deletion lua/windline/cterm_utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ end

local function rgb2cterm(hex_color)
if type(hex_color) == "number" then
return
return hex_color
end
local r = tonumber(hex_color:sub(2, 3), 16)
local g = tonumber(hex_color:sub(4, 5), 16)
Expand Down
37 changes: 8 additions & 29 deletions lua/windline/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,36 +70,15 @@ local api = vim.api
local rgb2cterm = not vim.go.termguicolors
and require('windline.cterm_utils').rgb2cterm

if vim.version().minor >= 7 then
M.highlight = function(group, color)
if rgb2cterm then
color.ctermfg = color.fg and rgb2cterm(color.fg)
color.ctermbg = color.bg and rgb2cterm(color.bg)
end
api.nvim_set_hl(0, group, color)
end
else
M.highlight = function(group, color)
local c = {
guifg = color.fg,
guibg = color.bg,
gui = color.bold and 'bold',
}
if rgb2cterm then
c.ctermfg = color.fg and rgb2cterm(color.fg)
c.ctermbg = color.bg and rgb2cterm(color.bg)
end
local options = {}
for k, v in pairs(c) do
table.insert(options, string.format('%s=%s', k, v))
end
vim.api.nvim_command(
string.format([[highlight %s %s]], group, table.concat(options, ' '))
)
M.highlight = function(group, color)
if rgb2cterm then
color.ctermfg = color.fg and rgb2cterm(color.fg)
color.ctermbg = color.bg and rgb2cterm(color.bg)
end
api.nvim_set_hl(0, group, color)
end

M.get_color = function (colors, name)
M.get_color = function(colors, name)
local c = colors[name]
if c == nil then
print('WL' .. (name or '') .. ' color is not defined ')
Expand All @@ -126,8 +105,8 @@ M.hl = function(tbl, colors, is_runtime)
return name
end
colors = colors or WindLine.state.colors
local fg = M.get_color(colors,tbl[1])
local bg = M.get_color(colors,tbl[2])
local fg = M.get_color(colors, tbl[1])
local bg = M.get_color(colors, tbl[2])

local style = {
bg = bg,
Expand Down

0 comments on commit 9967837

Please sign in to comment.