Closed dsully closed 10 months ago
How are you configuring the Git Branch for your statusbar? 🤔
You shouldn't create new item inside the content
function.
If content
is a function it will be called each time statusbar is evaluated.
Try doing something like this instead.
local git_status = require("nougat.nut.git.branch").create({
config = { provider = "gitsigns" },
hl = { bg = colors.bg0, fg = colors.white.base },
prefix = " ",
sep_left = sep.left_lower_triangle_solid(true),
suffix = " ",
})
statusline:add_item({
content = {
white_left_lower_triangle,
git_status,
},
hidden = function()
return not vim.g.gitsigns_head
end,
})
Thanks - that fixed the issue. Can you see if there is any more that should be changed?
https://github.com/dsully/nvim/blob/main/lua/plugins/nougat.lua
It seems that dynamic items like navic
should continue to be in content = function()
wrapper, correct?
You can check the usage patterns in here: https://github.com/MunifTanjim/nougat.nvim/tree/main/examples
It seems that dynamic items like navic should continue to be in content = function() wrapper, correct?
Yes, you can set content
to a function when you need it. But do not create a new item inside content
function. From the content function you can return:
From the above example (https://github.com/MunifTanjim/nougat.nvim/issues/45#issuecomment-1810054847), both of these will do the same thing:
statusline:add_item({
content = {
white_left_lower_triangle,
git_status,
},
)}
statusline:add_item({
content = function()
return {
white_left_lower_triangle,
git_status,
}
end,
)}
But with the first one is faster than the second one.
This started happening with change https://github.com/MunifTanjim/nougat.nvim/commit/dba049fe50b2b3b07f446e66e6159b663650ee63 or more likely https://github.com/MunifTanjim/nougat.nvim/commit/45cc6e6ac8fb562ce3304c68041d655d9a4930c3 which started using the cache.