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:
BlakeJC94 2022-10-19 20:06:45 +11:00 committed by GitHub
parent dcd194f700
commit 1a6ab5f2f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -251,6 +251,7 @@ sections = {lualine_a = {'mode'}}
- `location` (location in file in line:column format) - `location` (location in file in line:column format)
- `mode` (vim mode) - `mode` (vim mode)
- `progress` (%progress in file) - `progress` (%progress in file)
- `searchcount` (number of search matches when hlsearch is active)
- `tabs` (shows currently available tabs) - `tabs` (shows currently available tabs)
- `windows` (shows currently available windows) - `windows` (shows currently available windows)

View File

@ -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