dotfiles/config/nvim/lua/lualine/components/fschauen/searchcount.lua

27 lines
614 B
Lua

local M = require("lualine.component"):extend()
function M:init(options)
M.super.init(
self,
vim.tbl_extend("keep", options or {}, {
maxcount = 999,
timeout = 250,
})
)
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