feat: added searchcount component (#869)
* feat: added searchcount component * feat: added timeout and maxcount to vim.fn.searchcount * docs: added searchcount to README * style: sorted list of components
This commit is contained in:
parent
dcd194f700
commit
1a6ab5f2f4
|
@ -251,6 +251,7 @@ sections = {lualine_a = {'mode'}}
|
|||
- `location` (location in file in line:column format)
|
||||
- `mode` (vim mode)
|
||||
- `progress` (%progress in file)
|
||||
- `searchcount` (number of search matches when hlsearch is active)
|
||||
- `tabs` (shows currently available tabs)
|
||||
- `windows` (shows currently available windows)
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
local function searchcount()
|
||||
if vim.v.hlsearch == 0 then
|
||||
return ""
|
||||
end
|
||||
|
||||
local result = vim.fn.searchcount({ maxcount = 999, timeout = 500 })
|
||||
local denominator = math.min(result.total, result.maxcount)
|
||||
return string.format("[%d/%d]", result.current, denominator)
|
||||
end
|
||||
|
||||
return searchcount
|
Loading…
Reference in New Issue