b0o / incline.nvim

🎈 Floating statuslines for Neovim, winbar alternative
MIT License
759 stars 14 forks source link

Make updating event configurable #62

Open xzbdmw opened 5 months ago

xzbdmw commented 5 months ago

If I loop a table in render function, each time debounce time hit, render function will rerun, which is a waste of cpu, and I'd like to make render function only run when I enter nomal mode, is it possible? For example, I'd like to only show the severiest diagnostic, so I'm looping a table, as soon as I found one, break the loop. But the debounce time makes the behaviour unable to determine, because maybe when it loops to info, gets a n>0, breaks the loop, so that possible error is ignored

                                local function get_diagnostic_label()
                    local icons = {
                        Error = "",
                        Warn = "",
                        Info = "",
                        Hint = "",
                    }

                    local label = {}
                    for severity, _ in pairs(icons) do
                        local n = #vim.diagnostic.get(
                            props.buf,
                            { severity = vim.diagnostic.severity[string.upper(severity)] }
                        )
                        if n > 0 then
                            label = {
                                { "   " }, -- 前缀图标
                                {
                                    n,
                                    group = "DiagnosticSign" .. severity,
                                },
                            }
                            break
                        end
                    end
                    return label
                end
b0o commented 5 months ago

Thanks for your request. I plan on adding this in the future. Let's keep this issue open.