diff --git a/README.md b/README.md index a7505ad..b0e18ba 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/lua/lualine/components/searchcount.lua b/lua/lualine/components/searchcount.lua new file mode 100644 index 0000000..1b8fe2b --- /dev/null +++ b/lua/lualine/components/searchcount.lua @@ -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