feat(statusline): restore proper lsp look and feel & new get_highlight
This commit is contained in:
parent
1978317431
commit
d3c2a3b39a
4 changed files with 110 additions and 47 deletions
|
@ -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.highlight')
|
||||
local highlight = require('cosmic.theme.utils').highlight
|
||||
local icons = require('cosmic.theme.icons')
|
||||
local config = require('cosmic.config')
|
||||
|
||||
|
@ -291,9 +291,10 @@ gls.left = {
|
|||
}
|
||||
|
||||
gls.right = {
|
||||
-- Error
|
||||
{
|
||||
DiagnosticErrorLeftBracket = {
|
||||
provider = BracketProvider(icons.arrow_left, diag.get_diagnostic_error),
|
||||
provider = BracketProvider(icons.rounded_left_filled, diag.get_diagnostic_error),
|
||||
highlight = 'DiagnosticError',
|
||||
condition = condition.buffer_not_empty,
|
||||
},
|
||||
|
@ -301,41 +302,65 @@ gls.right = {
|
|||
{
|
||||
DiagnosticError = {
|
||||
provider = diag.get_diagnostic_error,
|
||||
highlight = 'DiagnosticError',
|
||||
highlight = 'DiagnosticErrorInv',
|
||||
icon = ' ' .. icons.error .. ' ',
|
||||
condition = condition.buffer_not_empty,
|
||||
},
|
||||
},
|
||||
{
|
||||
DiagnosticErrorRightBracket = {
|
||||
provider = BracketProvider(icons.rounded_right_filled .. ' ', diag.get_diagnostic_error),
|
||||
highlight = 'DiagnosticError',
|
||||
condition = condition.buffer_not_empty,
|
||||
},
|
||||
},
|
||||
-- Warning
|
||||
{
|
||||
DiagnosticWarnLeftBracket = {
|
||||
provider = BracketProvider(icons.arrow_left, diag.get_diagnostic_warn),
|
||||
highlight = 'DiagnosticWarning',
|
||||
provider = BracketProvider(icons.rounded_left_filled, diag.get_diagnostic_warn),
|
||||
highlight = 'DiagnosticWarn',
|
||||
condition = condition.buffer_not_empty,
|
||||
},
|
||||
},
|
||||
{
|
||||
DiagnosticWarn = {
|
||||
provider = diag.get_diagnostic_warn,
|
||||
highlight = 'DiagnosticWarning',
|
||||
highlight = 'DiagnosticWarnInv',
|
||||
icon = ' ' .. icons.warn .. ' ',
|
||||
condition = condition.buffer_not_empty,
|
||||
},
|
||||
},
|
||||
{
|
||||
DiagnosticInfoLeftBracket = {
|
||||
provider = BracketProvider(icons.arrow_left, diag.get_diagnostic_info),
|
||||
highlight = 'DiagnosticInfo',
|
||||
DiagnosticWarnRightBracket = {
|
||||
provider = BracketProvider(icons.rounded_right_filled .. ' ', diag.get_diagnostic_warn),
|
||||
highlight = 'DiagnosticWarn',
|
||||
condition = condition.buffer_not_empty,
|
||||
},
|
||||
},
|
||||
-- Hint
|
||||
{
|
||||
DiagnosticHintLeftBracket = {
|
||||
provider = BracketProvider(icons.rounded_left_filled, diag.get_diagnostic_hint),
|
||||
highlight = 'DiagnosticHint',
|
||||
condition = condition.buffer_not_empty,
|
||||
},
|
||||
},
|
||||
{
|
||||
DiagnosticInfo = {
|
||||
provider = diag.get_diagnostic_info,
|
||||
icon = ' ' .. icons.info .. ' ',
|
||||
highlight = 'DiagnosticInfo',
|
||||
DiagnosticHint = {
|
||||
provider = diag.get_diagnostic_hint,
|
||||
icon = ' ' .. icons.hint .. ' ',
|
||||
highlight = 'DiagnosticHintInv',
|
||||
condition = condition.buffer_not_empty,
|
||||
},
|
||||
},
|
||||
{
|
||||
DiagnosticHintRightBracket = {
|
||||
provider = BracketProvider(icons.rounded_right_filled .. ' ', diag.get_diagnostic_hint),
|
||||
highlight = 'DiagnosticHint',
|
||||
condition = condition.buffer_not_empty,
|
||||
},
|
||||
},
|
||||
-- Git
|
||||
{
|
||||
GitBranchRightBracket = {
|
||||
provider = BracketProvider(icons.arrow_left_filled, true),
|
||||
|
@ -351,6 +376,7 @@ gls.right = {
|
|||
highlight = 'GalaxyViModeInv',
|
||||
},
|
||||
},
|
||||
-- Editor info
|
||||
{
|
||||
LineColumn = {
|
||||
provider = {
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
return 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))
|
||||
else
|
||||
vim.api.nvim_command(('hi %s guibg=%s guifg=%s'):format(group, bg, fg))
|
||||
end
|
||||
end
|
|
@ -2,38 +2,48 @@ local _, colors = pcall(require, 'cosmic.theme.colors')
|
|||
if not colors then
|
||||
return
|
||||
end
|
||||
local highlight = require('cosmic.theme.highlight')
|
||||
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
|
||||
|
||||
-- @TODO: can i get rid of this?
|
||||
highlight('StatusLine', colors.statusline_bg, colors.statusline_bg)
|
||||
|
||||
-- @TODO: is all this work worth it?
|
||||
--[[ -- diagnostic virtual text highlights
|
||||
highlight('DiagnosticVirtualTextError', 'None', colors.error)
|
||||
highlight('DiagnosticVirtualTextWarn', 'None', colors.warn)
|
||||
highlight('DiagnosticVirtualTextInfo', 'None', colors.info)
|
||||
highlight('DiagnosticVirtualTextHint', 'None', colors.hint)
|
||||
local error_colors = get_highlight('DiagnosticError')
|
||||
set_highlight(
|
||||
'DiagnosticErrorInv',
|
||||
vim.tbl_extend('force', error_colors, {
|
||||
guibg = error_colors.guifg,
|
||||
guifg = colors.statusline_bg,
|
||||
})
|
||||
)
|
||||
|
||||
-- diagnostics highlight
|
||||
highlight('DiagnosticError', 'None', colors.error)
|
||||
highlight('DiagnosticWarn', 'None', colors.warn)
|
||||
highlight('DiagnosticInfo', 'None', colors.info)
|
||||
highlight('DiagnosticHint', 'None', colors.hint)
|
||||
local warning_colors = get_highlight('DiagnosticWarn')
|
||||
set_highlight(
|
||||
'DiagnosticWarnInv',
|
||||
vim.tbl_extend('force', warning_colors, {
|
||||
guibg = warning_colors.guifg,
|
||||
guifg = colors.statusline_bg,
|
||||
})
|
||||
)
|
||||
|
||||
highlight('Error', 'None', colors.error)
|
||||
highlight('ErrorMsg', 'None', colors.error)
|
||||
highlight('WarningMsg', 'None', colors.warn)
|
||||
local hint_colors = get_highlight('DiagnosticHint')
|
||||
set_highlight(
|
||||
'DiagnosticHintInv',
|
||||
vim.tbl_extend('force', hint_colors, {
|
||||
guibg = hint_colors.guifg,
|
||||
guifg = colors.statusline_bg,
|
||||
})
|
||||
)
|
||||
|
||||
-- legacy diagnostics highlight
|
||||
highlight('LspDiagnosticsError', 'None', colors.error)
|
||||
highlight('LspDiagnosticsWarning', 'None', colors.warn)
|
||||
highlight('LspDiagnosticsInformation', 'None', colors.info)
|
||||
highlight('LspDiagnosticsHint', 'None', colors.hint)
|
||||
|
||||
highlight('LspDiagnosticsSignError', 'None', colors.error)
|
||||
highlight('LspDiagnosticsSignWarning', 'None', colors.warn)
|
||||
highlight('LspDiagnosticsSignInformation', 'None', colors.info)
|
||||
highlight('LspDiagnosticsSignHint', 'None', colors.hint) ]]
|
||||
local info_colors = get_highlight('DiagnosticInfo')
|
||||
set_highlight(
|
||||
'DiagnosticInfoInv',
|
||||
vim.tbl_extend('force', info_colors, {
|
||||
guibg = info_colors.guifg,
|
||||
guifg = colors.statusline_bg,
|
||||
})
|
||||
)
|
||||
|
||||
-- notification highlights
|
||||
highlight('NotifyINFOBorder', nil, colors.hint)
|
||||
|
|
36
lua/cosmic/theme/utils.lua
Normal file
36
lua/cosmic/theme/utils.lua
Normal file
|
@ -0,0 +1,36 @@
|
|||
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 = ''
|
||||
|
||||
for k, v in pairs(colors) do
|
||||
hi_str = hi_str .. k .. '=' .. v .. ' '
|
||||
end
|
||||
|
||||
vim.cmd(('hi %s %s'):format(hi, hi_str))
|
||||
end
|
||||
|
||||
M.get_highlight = function(hi)
|
||||
local hi_str = vim.api.nvim_command_output(('hi %s'):format(hi))
|
||||
|
||||
local colors = {}
|
||||
for key, val in string.gmatch(hi_str, '(%w+)=(%S+)') do
|
||||
colors[key] = val
|
||||
end
|
||||
|
||||
return colors
|
||||
end
|
||||
|
||||
return M
|
Loading…
Add table
Reference in a new issue