lualine.nvim/lua/lualine/components/searchcount.lua

28 lines
686 B
Lua
Raw Normal View History

local M = require('lualine.component'):extend()
local default_options = {
maxcount = 999,
timeout = 500,
}
-- Initializer
function M:init(options)
-- Run super()
M.super.init(self, options)
-- Apply default options
self.options = vim.tbl_extend('keep', self.options or {}, default_options)
end
-- Function that runs every time statusline is updated
function M:update_status()
if vim.v.hlsearch == 0 then
2022-10-19 09:07:21 +00:00
return ''
end
local result = vim.fn.searchcount { maxcount = self.options.maxcount, timeout = self.options.timeout }
local denominator = math.min(result.total, result.maxcount)
2022-10-19 09:07:21 +00:00
return string.format('[%d/%d]', result.current, denominator)
end
return M