refactor(highlights): set_highlight over highlight
This commit is contained in:
parent
3be2d316fc
commit
df13f58678
8 changed files with 116 additions and 74 deletions
|
@ -173,7 +173,6 @@ return packer.startup(function()
|
|||
event = 'BufWinEnter',
|
||||
config = function()
|
||||
require('cosmic.plugins.terminal')
|
||||
require('cosmic.plugins.terminal.mappings')
|
||||
end,
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'terminal'),
|
||||
})
|
||||
|
|
|
@ -5,7 +5,7 @@ local condition = require('galaxyline.condition')
|
|||
local fileinfo = require('galaxyline.providers.fileinfo')
|
||||
local utils = require('cosmic.utils')
|
||||
local colors = require('cosmic.theme.colors')
|
||||
local highlight = require('cosmic.theme.utils').highlight
|
||||
local set_highlight = require('cosmic.theme.utils').set_highlight
|
||||
local icons = require('cosmic.theme.icons')
|
||||
local config = require('cosmic.config')
|
||||
local get_highlight = require('cosmic.theme.utils').get_highlight
|
||||
|
@ -150,22 +150,51 @@ gls.left = {
|
|||
end
|
||||
|
||||
local label, mode_color, mode_nested = unpack(m)
|
||||
highlight('GalaxyViMode', mode_color, mode_nested)
|
||||
highlight('GalaxyViModeInv', mode_nested, mode_color)
|
||||
highlight('GalaxyViModeNested', mode_nested, 'StatusLine')
|
||||
highlight('GalaxyViModeNestedInv', 'StatusLine', mode_nested)
|
||||
highlight('GalaxyPercentBracket', 'StatusLine', mode_color)
|
||||
highlight('GalaxyText', 'StatusLine', mode_color)
|
||||
|
||||
highlight('GalaxyGitLCBracket', mode_nested, mode_color)
|
||||
set_highlight('GalaxyViMode', {
|
||||
guibg = mode_color,
|
||||
guifg = mode_nested,
|
||||
})
|
||||
set_highlight('GalaxyViModeInv', {
|
||||
guibg = mode_nested,
|
||||
guifg = mode_color,
|
||||
})
|
||||
set_highlight('GalaxyViModeNested', {
|
||||
guibg = mode_nested,
|
||||
guifg = 'StatusLine',
|
||||
})
|
||||
set_highlight('GalaxyViModeNestedInv', {
|
||||
guibg = 'StatusLine',
|
||||
guifg = mode_nested,
|
||||
})
|
||||
set_highlight('GalaxyPercentBracket', {
|
||||
guibg = 'StatusLine',
|
||||
guifg = mode_color,
|
||||
})
|
||||
set_highlight('GalaxyText', {
|
||||
guibg = 'StatusLine',
|
||||
guifg = mode_color,
|
||||
})
|
||||
set_highlight('GalaxyGitLCBracket', {
|
||||
guibg = mode_nested,
|
||||
guifg = mode_color,
|
||||
})
|
||||
|
||||
if condition.buffer_not_empty() then
|
||||
highlight('GalaxyViModeBracket', mode_nested, mode_color)
|
||||
set_highlight('GalaxyViModeBracket', {
|
||||
guibg = mode_nested,
|
||||
guifg = mode_color,
|
||||
})
|
||||
else
|
||||
if condition.check_git_workspace() then
|
||||
highlight('GalaxyGitLCBracket', 'StatusLine', mode_color)
|
||||
set_highlight('GalaxyGitLCBracket', {
|
||||
guibg = 'StatusLine',
|
||||
guifg = mode_color,
|
||||
})
|
||||
end
|
||||
highlight('GalaxyViModeBracket', 'StatusLine', mode_color)
|
||||
set_highlight('GalaxyViModeBracket', {
|
||||
guibg = 'StatusLine',
|
||||
guifg = mode_color,
|
||||
})
|
||||
end
|
||||
return ' ' .. label .. ' '
|
||||
end,
|
||||
|
|
43
lua/cosmic/plugins/notify/highlights.lua
Normal file
43
lua/cosmic/plugins/notify/highlights.lua
Normal file
|
@ -0,0 +1,43 @@
|
|||
local _, colors = pcall(require, 'cosmic.theme.colors')
|
||||
if not colors then
|
||||
return
|
||||
end
|
||||
|
||||
local set_highlight = require('cosmic.theme.utils').set_highlight
|
||||
-- notification highlights
|
||||
set_highlight('NotifyINFOBorder', {
|
||||
guifg = colors.hint,
|
||||
})
|
||||
set_highlight('NotifyINFOTitle', {
|
||||
guifg = colors.hint,
|
||||
})
|
||||
set_highlight('NotifyINFOIcon', {
|
||||
guifg = colors.hint,
|
||||
})
|
||||
set_highlight('NotifyWARNBorder', {
|
||||
guifg = colors.warn,
|
||||
})
|
||||
set_highlight('NotifyWARNTitle', {
|
||||
guifg = colors.warn,
|
||||
})
|
||||
set_highlight('NotifyWARNIcon', {
|
||||
guifg = colors.warn,
|
||||
})
|
||||
set_highlight('NotifyERRORBorder', {
|
||||
guifg = colors.error,
|
||||
})
|
||||
set_highlight('NotifyERRORTitle', {
|
||||
guifg = colors.error,
|
||||
})
|
||||
set_highlight('NotifyERRORIcon', {
|
||||
guifg = colors.error,
|
||||
})
|
||||
set_highlight('NotifyTRACEBorder', {
|
||||
guifg = colors.trace,
|
||||
})
|
||||
set_highlight('NotifyTRACETitle', {
|
||||
guifg = colors.trace,
|
||||
})
|
||||
set_highlight('NotifyTRACEIcon', {
|
||||
guifg = colors.trace,
|
||||
})
|
|
@ -15,3 +15,5 @@ require('notify').setup(utils.merge({
|
|||
}, config.notify or {}))
|
||||
|
||||
vim.notify = require('notify')
|
||||
|
||||
require('cosmic.plugins.notify.highlights')
|
||||
|
|
8
lua/cosmic/plugins/terminal/highlights.lua
Normal file
8
lua/cosmic/plugins/terminal/highlights.lua
Normal file
|
@ -0,0 +1,8 @@
|
|||
local set_highlight = require('cosmic.theme.utils').set_highlight
|
||||
|
||||
-- terminal highlights
|
||||
set_highlight('FloatBorder', {
|
||||
guibg = 'None',
|
||||
})
|
||||
|
||||
vim.cmd('hi! link FloatermBorder FloatBorder')
|
|
@ -6,3 +6,6 @@ g.floaterm_height = 0.8
|
|||
g.floaterm_title = '[' .. title .. ']:($1/$2)'
|
||||
g.floaterm_borderchars = '─│─│╭╮╯╰'
|
||||
g.floaterm_opener = 'vsplit'
|
||||
|
||||
require('cosmic.plugins.terminal.mappings')
|
||||
require('cosmic.plugins.terminal.highlights')
|
||||
|
|
|
@ -2,61 +2,31 @@ local _, colors = pcall(require, 'cosmic.theme.colors')
|
|||
if not colors then
|
||||
return
|
||||
end
|
||||
local highlight = require('cosmic.theme.utils').highlight
|
||||
|
||||
local get_highlight = require('cosmic.theme.utils').get_highlight
|
||||
local set_highlight = require('cosmic.theme.utils').set_highlight
|
||||
local utils = require('cosmic.utils')
|
||||
|
||||
local statusline_colors = get_highlight('StatusLine')
|
||||
local error_colors = get_highlight('DiagnosticError')
|
||||
set_highlight(
|
||||
'DiagnosticErrorInv',
|
||||
utils.merge(error_colors, {
|
||||
local warning_colors = get_highlight('DiagnosticWarn')
|
||||
local hint_colors = get_highlight('DiagnosticHint')
|
||||
local info_colors = get_highlight('DiagnosticInfo')
|
||||
|
||||
set_highlight('DiagnosticErrorInv', {
|
||||
guibg = error_colors.guifg,
|
||||
guifg = statusline_colors.guibg,
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
local warning_colors = get_highlight('DiagnosticWarn')
|
||||
set_highlight(
|
||||
'DiagnosticWarnInv',
|
||||
utils.merge(warning_colors, {
|
||||
set_highlight('DiagnosticWarnInv', {
|
||||
guibg = warning_colors.guifg,
|
||||
guifg = statusline_colors.guibg,
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
local hint_colors = get_highlight('DiagnosticHint')
|
||||
set_highlight(
|
||||
'DiagnosticHintInv',
|
||||
utils.merge(hint_colors, {
|
||||
set_highlight('DiagnosticHintInv', {
|
||||
guibg = hint_colors.guifg,
|
||||
guifg = statusline_colors.guibg,
|
||||
})
|
||||
)
|
||||
})
|
||||
|
||||
local info_colors = get_highlight('DiagnosticInfo')
|
||||
set_highlight(
|
||||
'DiagnosticInfoInv',
|
||||
utils.merge(info_colors, {
|
||||
set_highlight('DiagnosticInfoInv', {
|
||||
guibg = info_colors.guifg,
|
||||
guifg = statusline_colors.guibg,
|
||||
})
|
||||
)
|
||||
|
||||
-- notification highlights
|
||||
highlight('NotifyINFOBorder', nil, colors.hint)
|
||||
highlight('NotifyINFOTitle', nil, colors.hint)
|
||||
highlight('NotifyINFOIcon', nil, colors.hint)
|
||||
highlight('NotifyWARNBorder', nil, colors.warn)
|
||||
highlight('NotifyWARNTitle', nil, colors.warn)
|
||||
highlight('NotifyWARNIcon', nil, colors.warn)
|
||||
highlight('NotifyERRORBorder', nil, colors.error)
|
||||
highlight('NotifyERRORTitle', nil, colors.error)
|
||||
highlight('NotifyERRORIcon', nil, colors.error)
|
||||
highlight('NotifyTRACEBorder', nil, colors.trace)
|
||||
highlight('NotifyTRACETitle', nil, colors.trace)
|
||||
highlight('NotifyTRACEIcon', nil, colors.trace)
|
||||
|
||||
vim.cmd('hi FloatBorder guibg=None')
|
||||
vim.cmd('hi! link FloatermBorder FloatBorder')
|
||||
})
|
||||
|
|
|
@ -1,17 +1,5 @@
|
|||
local M = {}
|
||||
|
||||
M.highlight = function(group, bg, fg, gui)
|
||||
if gui ~= nil and gui ~= '' then
|
||||
vim.api.nvim_command(('hi %s guibg=%s guifg=%s gui=%s'):format(group, bg, fg, gui))
|
||||
elseif bg == nil then
|
||||
vim.api.nvim_command(('hi %s guifg=%s'):format(group, fg))
|
||||
elseif fg == nil then
|
||||
vim.api.nvim_command(('hi %s guibg=%s'):format(group, bg))
|
||||
else
|
||||
vim.api.nvim_command(('hi %s guibg=%s guifg=%s'):format(group, bg, fg))
|
||||
end
|
||||
end
|
||||
|
||||
M.set_highlight = function(hi, colors)
|
||||
local hi_str = ''
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue