22 lines
615 B
Lua
22 lines
615 B
Lua
local M = require("lualine.component"):extend()
|
|
|
|
function M:init(opts)
|
|
local default_opts = { maxcount = 999, timeout = 250 }
|
|
M.super.init(self, vim.tbl_extend("keep", opts or {}, default_opts))
|
|
end
|
|
|
|
function M:update_status()
|
|
if vim.v.hlsearch == 0 then return "" end
|
|
|
|
local count = vim.fn.searchcount {
|
|
maxcount = self.options.maxcount,
|
|
timeout = self.options.timeout,
|
|
}
|
|
if next(count) == nil then return "" end
|
|
|
|
local denominator = count.total > count.maxcount and ""
|
|
or string.format("%d", count.total)
|
|
return string.format(" %d/%s", count.current, denominator)
|
|
end
|
|
|
|
return M
|