Skip to content

Commit

Permalink
Added Diagnostic* hl when in fg mode
Browse files Browse the repository at this point in the history
Fixed bug for switch cmd when fg in user config
  • Loading branch information
sschleemilch committed Sep 15, 2024
1 parent 23c041d commit f8df6d0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lua/slimline/components/diagnostics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ local M = {}

local last_diagnostic_component = ''

local function capitalize(str)
return string.upper(string.sub(str, 1, 1)) .. string.lower(string.sub(str, 2))
end

--- @param sep {left: string, right: string}
--- @param direction string
--- |'"right"'
Expand Down Expand Up @@ -37,7 +41,10 @@ function M.render(sep, direction)
if count == 0 then
return nil
end

if config.style == 'fg' then
local hl = 'Diagnostic' .. capitalize(severity)
return string.format('%%#%s#%s%%#%s#%d', hl, config.icons.diagnostics[severity], highlights.hls.base, count)
end
return string.format('%s%d', config.icons.diagnostics[severity], count)
end)
:totable()
Expand All @@ -46,8 +53,10 @@ function M.render(sep, direction)
if last_diagnostic_component == '' then
return ''
end
last_diagnostic_component =
highlights.hl_component({ primary = last_diagnostic_component }, highlights.hls.component, sep, direction)
if config.style ~= 'fg' then
last_diagnostic_component =
highlights.hl_component({ primary = last_diagnostic_component }, highlights.hls.component, sep, direction)
end
return last_diagnostic_component
end

Expand Down
6 changes: 6 additions & 0 deletions lua/slimline/usercommands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ local subcommand_tbl = {
if args[1] == 'style' then
local sl = require('slimline')
local cfg = sl.config
if seps.left == nil then
seps.left = cfg.sep.left
end
if seps.right == nil then
seps.right = cfg.sep.right
end
if cfg.style == 'bg' then
cfg.style = 'fg'
seps.left = cfg.sep.left
Expand Down

0 comments on commit f8df6d0

Please sign in to comment.