Skip to content

Commit

Permalink
feat(cookbook): add SearchCount and MacroRec
Browse files Browse the repository at this point in the history
  • Loading branch information
rebelot committed Mar 7, 2023
1 parent c109ac0 commit 673226c
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -1197,6 +1197,42 @@ local Spell = {
}
```

### No `'cmdheight'`? No problem! SearchCount and MacroRec

```lua
local SearchCount = {
condition = function()
return vim.v.hlsearch ~= 0 and vim.o.cmdheight == 0
end,
init = function(self)
local ok, search = pcall(vim.fn.searchcount)
if ok and search.total then
self.search = search
end
end,
provider = function(self)
local search = self.search
return string.format("[%d/%d]", search.current, math.min(search.total, search.maxcount))
end,
}
```

```lua
local MacroRec = {
condition = function()
return vim.fn.reg_recording() ~= "" and vim.o.cmdheight == 0
end,
provider = "",
hl = { fg = "orange", bold = true },
utils.surround({ "[", "]" }, nil, {
provider = function()
return vim.fn.reg_recording()
end,
hl = { fg = "green", bold = true },
}),
}
```

## Flexible Components

Yes, Heirline has flexible components! And, like any other component, they
Expand Down

0 comments on commit 673226c

Please sign in to comment.