Skip to content

Commit 941f4bf

Browse files
committed
feat(statusline): Added Macro preview module
1 parent 1db856c commit 941f4bf

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

lua/bars/components/statusline.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,26 @@ slC.ruler = function (_, window, main_config)
470470
---|fE
471471
end
472472

473+
--- Macro recording & executing.
474+
---@param config statusline.components.macro
475+
---@return string
476+
slC.macro = function (_, _, config)
477+
---|fS
478+
479+
local rec = vim.fn.reg_recording();
480+
local exe = vim.fn.reg_executing();
481+
482+
if rec ~= "" then
483+
return string.format("%s%s%s", utils.set_hl(config.record_hl), config.record_icon or "", rec);
484+
elseif exe ~= "" then
485+
return string.format("%s%s%s", utils.set_hl(config.exec_hl), config.exec_icon or "", exe);
486+
else
487+
return "";
488+
end
489+
490+
---|fE
491+
end
492+
473493
--- Custom section.
474494
---@param config statusline.components.custom
475495
---@return string

lua/bars/statusline.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@ statusline.config = {
192192
info_hl = "DiagnosticInfo"
193193

194194
},
195+
{
196+
kind = "macro",
197+
198+
record_icon = "󰦚 ",
199+
exec_icon = "󰥠 "
200+
},
195201
{ kind = "empty", hl = "Normal" },
196202
{
197203
kind = "branch",

lua/definitions/statusline.lua

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
---| statusline.components.branch
4141
---| statusline.components.bufname
4242
---| statusline.components.custom
43+
---| statusline.components.macro
4344

4445
-----------------------------------------------------------------------------
4546

@@ -406,6 +407,7 @@
406407
--- Primary highlight group.
407408
---@field hl? string
408409

410+
-----------------------------------------------------------------------------
409411

410412
--- Custom statusline component.
411413
---@class statusline.components.custom
@@ -419,3 +421,25 @@
419421
--- Text to show for this component.
420422
---@field value fun(buffer: integer, window: integer): string
421423

424+
-----------------------------------------------------------------------------
425+
426+
---@class statusline.components.macro
427+
---
428+
--- Optional condition for this component.
429+
---@field condition? boolean | fun(buffer: integer, window: integer): boolean
430+
---
431+
--- What kind of component is this?
432+
---@field kind "macro"
433+
---
434+
--- Icon to show Macros being recorded.
435+
---@field record_icon string
436+
---
437+
--- Highlight group for record icon.
438+
---@field record_hl? string
439+
---
440+
--- Icon to show Macros being executed.
441+
---@field exec_icon string
442+
---
443+
--- Highlight group for exec icon.
444+
---@field exec_hl? string
445+

0 commit comments

Comments
 (0)