Skip to content

Commit

Permalink
Merge pull request nvim-lua#3 from bassamsdata/main
Browse files Browse the repository at this point in the history
Adding search count to lualine
  • Loading branch information
jmbuhr authored Jan 14, 2023
2 parents 608ddd4 + 804650f commit 84eb437
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lua/plugins/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ return {
},
config = function()
local git_blame = require('gitblame')
vim.o.shortmess = vim.o.shortmess .. "S" -- this is for the search_count function so lua can know this is `lua expression`
--function for optimizing the search count
local function search_count()
if vim.api.nvim_get_vvar("hlsearch") == 1 then
local res = vim.fn.searchcount({ maxcount = 999, timeout = 500 })

if res.total > 0 then
return string.format("%d/%d", res.current, res.total)
end
end

return ""
end
require('lualine').setup {
options = {
section_separators = '',
Expand All @@ -77,7 +90,8 @@ return {
sections = {
lualine_c = {
{ git_blame.get_current_blame_text, cond = git_blame.is_blame_text_available }
}
},
lualine_b = {'branch', { search_count, type = "lua_expr" } }
},
extensions = { 'nvim-tree' },
}
Expand Down

0 comments on commit 84eb437

Please sign in to comment.