Skip to content

Commit

Permalink
making rest of icons configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Badragan committed May 6, 2024
1 parent 12fabf1 commit 483a186
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
10 changes: 10 additions & 0 deletions lua/grug-far/opts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ function M.with_defaults(options)
replaceInput = '',
filesFilterInput = '',
flagsInput = '󰮚 ',

-- bit of a stretch of the icon concept, but it makes it configurable
resultsSeparatorLine = '',

resultsStatusReady = '󱩾 ',
resultsStatusError = '',
resultsStatusSuccess = '󰗡 ',
resultsStatusProgressSeq = {
'󱑋 ', '󱑌 ', '󱑍 ', '󱑎 ', '󱑏 ', '󱑐 ', '󱑑 ', '󱑒 ', '󱑓 ', '󱑔 ', '󱑕 ', '󱑖 '
}
}
}, options)
end
Expand Down
31 changes: 19 additions & 12 deletions lua/grug-far/render/resultsHeader.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
local progress_icons = {
'󱑖 ', '󱑋 ', '󱑌 ', '󱑍 ', '󱑎 ', '󱑏 ', '󱑐 ', '󱑑 ', '󱑒 ', '󱑓 ', '󱑔 ', '󱑕 '
}
local opts = require('grug-far/opts')

-- TODO (sbadragan): make configurable
local function getStatusText(s)
local function getStatusText(context)
local s = context.state.status
if s.status == 'error' then
return ''
return opts.getIcon('resultsStatusError', context)
elseif s.status == 'success' then
return ''
return opts.getIcon('resultsStatusSuccess', context)
elseif s.status == 'progress' then
return progress_icons[(s.count % #progress_icons) + 1]
local progress_icons = opts.getIcon('resultsStatusProgressSeq', context)
if progress_icons then
return progress_icons[(s.count % #progress_icons) + 1]
else
return ''
end
end

return ''
return opts.getIcon('resultsStatusReady', context)
end

local DEFAULT_SEPARATOR = '-----------------------------------------------------'
local function getSeparator(context)
local separatorLine = opts.getIcon('resultsSeparatorLine', context) or DEFAULT_SEPARATOR
return ' ' .. (getStatusText(context) or '') .. ' ' .. separatorLine
end

local function renderResultsHeader(buf, context, headerRow)
Expand All @@ -24,10 +33,8 @@ local function renderResultsHeader(buf, context, headerRow)
id = context.extmarkIds.results_header,
end_row = headerRow,
end_col = 0,
-- TODO (sbadragan): make all these highlights configurable
virt_lines = {
{ { " 󱎸 ─────────────────────────────────────────────────────────────────────────────── "
.. getStatusText(context.state.status), context.options.highlights.resultsHeader } },
{ { getSeparator(context), context.options.highlights.resultsHeader } },
},
virt_lines_leftcol = true,
virt_lines_above = true,
Expand Down

0 comments on commit 483a186

Please sign in to comment.