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 fileinfo = require('galaxyline.providers.fileinfo')
|
||||||
local utils = require('cosmic.utils')
|
local utils = require('cosmic.utils')
|
||||||
local colors = require('cosmic.theme.colors')
|
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 icons = require('cosmic.theme.icons')
|
||||||
local config = require('cosmic.config')
|
local config = require('cosmic.config')
|
||||||
|
|
||||||
|
@ -291,9 +291,10 @@ gls.left = {
|
||||||
}
|
}
|
||||||
|
|
||||||
gls.right = {
|
gls.right = {
|
||||||
|
-- Error
|
||||||
{
|
{
|
||||||
DiagnosticErrorLeftBracket = {
|
DiagnosticErrorLeftBracket = {
|
||||||
provider = BracketProvider(icons.arrow_left, diag.get_diagnostic_error),
|
provider = BracketProvider(icons.rounded_left_filled, diag.get_diagnostic_error),
|
||||||
highlight = 'DiagnosticError',
|
highlight = 'DiagnosticError',
|
||||||
condition = condition.buffer_not_empty,
|
condition = condition.buffer_not_empty,
|
||||||
},
|
},
|
||||||
|
@ -301,41 +302,65 @@ gls.right = {
|
||||||
{
|
{
|
||||||
DiagnosticError = {
|
DiagnosticError = {
|
||||||
provider = diag.get_diagnostic_error,
|
provider = diag.get_diagnostic_error,
|
||||||
highlight = 'DiagnosticError',
|
highlight = 'DiagnosticErrorInv',
|
||||||
icon = ' ' .. icons.error .. ' ',
|
icon = ' ' .. icons.error .. ' ',
|
||||||
condition = condition.buffer_not_empty,
|
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 = {
|
DiagnosticWarnLeftBracket = {
|
||||||
provider = BracketProvider(icons.arrow_left, diag.get_diagnostic_warn),
|
provider = BracketProvider(icons.rounded_left_filled, diag.get_diagnostic_warn),
|
||||||
highlight = 'DiagnosticWarning',
|
highlight = 'DiagnosticWarn',
|
||||||
condition = condition.buffer_not_empty,
|
condition = condition.buffer_not_empty,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DiagnosticWarn = {
|
DiagnosticWarn = {
|
||||||
provider = diag.get_diagnostic_warn,
|
provider = diag.get_diagnostic_warn,
|
||||||
highlight = 'DiagnosticWarning',
|
highlight = 'DiagnosticWarnInv',
|
||||||
icon = ' ' .. icons.warn .. ' ',
|
icon = ' ' .. icons.warn .. ' ',
|
||||||
condition = condition.buffer_not_empty,
|
condition = condition.buffer_not_empty,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DiagnosticInfoLeftBracket = {
|
DiagnosticWarnRightBracket = {
|
||||||
provider = BracketProvider(icons.arrow_left, diag.get_diagnostic_info),
|
provider = BracketProvider(icons.rounded_right_filled .. ' ', diag.get_diagnostic_warn),
|
||||||
highlight = 'DiagnosticInfo',
|
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,
|
condition = condition.buffer_not_empty,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
DiagnosticInfo = {
|
DiagnosticHint = {
|
||||||
provider = diag.get_diagnostic_info,
|
provider = diag.get_diagnostic_hint,
|
||||||
icon = ' ' .. icons.info .. ' ',
|
icon = ' ' .. icons.hint .. ' ',
|
||||||
highlight = 'DiagnosticInfo',
|
highlight = 'DiagnosticHintInv',
|
||||||
condition = condition.buffer_not_empty,
|
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 = {
|
GitBranchRightBracket = {
|
||||||
provider = BracketProvider(icons.arrow_left_filled, true),
|
provider = BracketProvider(icons.arrow_left_filled, true),
|
||||||
|
@ -351,6 +376,7 @@ gls.right = {
|
||||||
highlight = 'GalaxyViModeInv',
|
highlight = 'GalaxyViModeInv',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
-- Editor info
|
||||||
{
|
{
|
||||||
LineColumn = {
|
LineColumn = {
|
||||||
provider = {
|
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
|
if not colors then
|
||||||
return
|
return
|
||||||
end
|
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?
|
-- @TODO: can i get rid of this?
|
||||||
highlight('StatusLine', colors.statusline_bg, colors.statusline_bg)
|
highlight('StatusLine', colors.statusline_bg, colors.statusline_bg)
|
||||||
|
|
||||||
-- @TODO: is all this work worth it?
|
local error_colors = get_highlight('DiagnosticError')
|
||||||
--[[ -- diagnostic virtual text highlights
|
set_highlight(
|
||||||
highlight('DiagnosticVirtualTextError', 'None', colors.error)
|
'DiagnosticErrorInv',
|
||||||
highlight('DiagnosticVirtualTextWarn', 'None', colors.warn)
|
vim.tbl_extend('force', error_colors, {
|
||||||
highlight('DiagnosticVirtualTextInfo', 'None', colors.info)
|
guibg = error_colors.guifg,
|
||||||
highlight('DiagnosticVirtualTextHint', 'None', colors.hint)
|
guifg = colors.statusline_bg,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
-- diagnostics highlight
|
local warning_colors = get_highlight('DiagnosticWarn')
|
||||||
highlight('DiagnosticError', 'None', colors.error)
|
set_highlight(
|
||||||
highlight('DiagnosticWarn', 'None', colors.warn)
|
'DiagnosticWarnInv',
|
||||||
highlight('DiagnosticInfo', 'None', colors.info)
|
vim.tbl_extend('force', warning_colors, {
|
||||||
highlight('DiagnosticHint', 'None', colors.hint)
|
guibg = warning_colors.guifg,
|
||||||
|
guifg = colors.statusline_bg,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
highlight('Error', 'None', colors.error)
|
local hint_colors = get_highlight('DiagnosticHint')
|
||||||
highlight('ErrorMsg', 'None', colors.error)
|
set_highlight(
|
||||||
highlight('WarningMsg', 'None', colors.warn)
|
'DiagnosticHintInv',
|
||||||
|
vim.tbl_extend('force', hint_colors, {
|
||||||
|
guibg = hint_colors.guifg,
|
||||||
|
guifg = colors.statusline_bg,
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
-- legacy diagnostics highlight
|
local info_colors = get_highlight('DiagnosticInfo')
|
||||||
highlight('LspDiagnosticsError', 'None', colors.error)
|
set_highlight(
|
||||||
highlight('LspDiagnosticsWarning', 'None', colors.warn)
|
'DiagnosticInfoInv',
|
||||||
highlight('LspDiagnosticsInformation', 'None', colors.info)
|
vim.tbl_extend('force', info_colors, {
|
||||||
highlight('LspDiagnosticsHint', 'None', colors.hint)
|
guibg = info_colors.guifg,
|
||||||
|
guifg = colors.statusline_bg,
|
||||||
highlight('LspDiagnosticsSignError', 'None', colors.error)
|
})
|
||||||
highlight('LspDiagnosticsSignWarning', 'None', colors.warn)
|
)
|
||||||
highlight('LspDiagnosticsSignInformation', 'None', colors.info)
|
|
||||||
highlight('LspDiagnosticsSignHint', 'None', colors.hint) ]]
|
|
||||||
|
|
||||||
-- notification highlights
|
-- notification highlights
|
||||||
highlight('NotifyINFOBorder', nil, colors.hint)
|
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