diff --git a/lua/windline/cterm_utils.lua b/lua/windline/cterm_utils.lua index c393c9f..d0c2b1a 100644 --- a/lua/windline/cterm_utils.lua +++ b/lua/windline/cterm_utils.lua @@ -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) diff --git a/lua/windline/utils.lua b/lua/windline/utils.lua index c721774..a2b2941 100644 --- a/lua/windline/utils.lua +++ b/lua/windline/utils.lua @@ -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 ') @@ -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,