Merge pull request #129 from shadmansaleh/fix_bug_component_highlights_not_blending_with_bg

fix bug component highlights not blending with bg
This commit is contained in:
Hubert Pelczarski 2021-03-14 16:01:27 +01:00 committed by GitHub
commit d5150f481e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 38 deletions

2
.gitignore vendored
View File

@ -39,3 +39,5 @@ luac.out
*.x86_64 *.x86_64
*.hex *.hex
# ctags
tags

View File

@ -1,44 +1,41 @@
-- Copyright (c) 2020-2021 hoob3rt -- Copyright (c) 2020-2021 hoob3rt
-- MIT license, see LICENSE for more details. -- MIT license, see LICENSE for more details.
local mode_map = {
['n'] = 'NORMAL',
['no'] = 'O-PENDING',
['nov'] = 'O-PENDING',
['noV'] = 'O-PENDING',
['no'] = 'O-PENDING',
['niI'] = 'NORMAL',
['niR'] = 'NORMAL',
['niV'] = 'NORMAL',
['v'] = 'VISUAL',
['V'] = 'V-LINE',
[''] = 'V-BLOCK',
['s'] = 'SELECT',
['S'] = 'S-LINE',
[''] = 'S-BLOCK',
['i'] = 'INSERT',
['ic'] = 'INSERT',
['ix'] = 'INSERT',
['R'] = 'REPLACE',
['Rc'] = 'REPLACE',
['Rv'] = 'V-REPLACE',
['Rx'] = 'REPLACE',
['c'] = 'COMMAND',
['cv'] = 'EX',
['ce'] = 'EX',
['r'] = 'REPLACE',
['rm'] = 'MORE',
['r?'] = 'CONFIRM',
['!'] = 'SHELL',
['t'] = 'TERMINAL',
}
local function mode() local function mode()
local mode_map = { local mode_code = vim.api.nvim_get_mode().mode
['n'] = 'NORMAL', if mode_map[mode_code] == nil then return mode_code end
['no'] = 'O-PENDING', return mode_map[mode_code]
['nov'] = 'O-PENDING',
['noV'] = 'O-PENDING',
['no'] = 'O-PENDING',
['niI'] = 'NORMAL',
['niR'] = 'NORMAL',
['niV'] = 'NORMAL',
['v'] = 'VISUAL',
['V'] = 'V-LINE',
[''] = 'V-BLOCK',
['s'] = 'SELECT',
['S'] = 'S-LINE',
[''] = 'S-BLOCK',
['i'] = 'INSERT',
['ic'] = 'INSERT',
['ix'] = 'INSERT',
['R'] = 'REPLACE',
['Rc'] = 'REPLACE',
['Rv'] = 'V-REPLACE',
['Rx'] = 'REPLACE',
['c'] = 'COMMAND',
['cv'] = 'EX',
['ce'] = 'EX',
['r'] = 'REPLACE',
['rm'] = 'MORE',
['r?'] = 'CONFIRM',
['!'] = 'SHELL',
['t'] = 'TERMINAL',
}
local function get_mode()
local mode_code = vim.api.nvim_get_mode().mode
if mode_map[mode_code] == nil then return mode_code end
return mode_map[mode_code]
end
return get_mode()
end end
return mode return mode

View File

@ -89,7 +89,7 @@ function M.create_component_highlight_group(color , highlight_tag, options)
local fg = (color.fg or default_color_table.fg) local fg = (color.fg or default_color_table.fg)
-- Check if it's same as normal mode if it is no need to create aditional highlight -- Check if it's same as normal mode if it is no need to create aditional highlight
if mode ~= 'normal' then if mode ~= 'normal' then
if bg ~= normal_hl.bg and fg ~= normal_hl.fg then if bg ~= normal_hl.bg or fg ~= normal_hl.fg then
highlight(table.concat(highlight_group_name, '_'), fg, bg, color.gui) highlight(table.concat(highlight_group_name, '_'), fg, bg, color.gui)
end end
else else