From 82f68c42df9d11e52edb52c86113d0eba5be798d Mon Sep 17 00:00:00 2001 From: shadmansaleh Date: Thu, 8 Apr 2021 08:43:06 +0600 Subject: [PATCH] Enhance: Cterm colors only loaded when termguicolors = false --- lua/lualine/highlight.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lua/lualine/highlight.lua b/lua/lualine/highlight.lua index 80f5290..9ae4982 100644 --- a/lua/lualine/highlight.lua +++ b/lua/lualine/highlight.lua @@ -5,16 +5,21 @@ local utils_colors = require 'lualine.utils.cterm_colors' local utils = require 'lualine.utils.utils' local section_highlight_map = {x = 'c', y = 'b', z = 'a'} local active_theme = nil +local cterm_colors = false function M.highlight(name, foreground, background, gui, reload) local command = {'highlight', name} if foreground and foreground ~= 'none' then - table.insert(command, 'ctermfg=' .. utils_colors.get_cterm_color(foreground)) table.insert(command, 'guifg=' .. foreground) + if cterm_colors then + table.insert(command, 'ctermfg=' .. utils_colors.get_cterm_color(foreground)) + end end if background and background ~= 'none' then - table.insert(command, 'ctermbg=' .. utils_colors.get_cterm_color(background)) table.insert(command, 'guibg=' .. background) + if cterm_colors then + table.insert(command, 'ctermbg=' .. utils_colors.get_cterm_color(background)) + end end if gui then table.insert(command, 'cterm=' .. gui) @@ -29,6 +34,7 @@ end function M.create_highlight_groups(theme) utils.clear_highlights() active_theme = theme + cterm_colors = not vim.o.termguicolors for mode, sections in pairs(theme) do for section, colorscheme in pairs(sections) do local highlight_group_name = {'lualine', section, mode}