utilyre / barbecue.nvim

Visual Studio Code inspired breadcrumbs plugin for the Neovim editor
MIT License
776 stars 31 forks source link

[FEAT]: Show diagnostics option #110

Open adonespitogo opened 3 months ago

adonespitogo commented 3 months ago

Requirements

Problem

I'm using winbar to work with multiple windows. I want to able to see if a certain file has errors at a glance.

Solution Suggestion

Since we have a show_modified option, I think it's also good to have show_diagnostics option.

Workaround

Using the custom_section to show a text or symbol when there are diagnostics error:

-- winbar plugin
return {
    "utilyre/barbecue.nvim",
    name = "barbecue",
    version = "*",
    dependencies = {
        "SmiteshP/nvim-navic",
        "nvim-tree/nvim-web-devicons", -- optional dependency
    },
    config = function()
        local function has_diagnostics(buf)
            local severties = { "error", "warning" }
            for _, sev in ipairs(severties) do
                local n = #vim.diagnostic.get(buf, { severity = vim.diagnostic.severity[string.upper(sev)] })
                if n > 0 then
                    return true
                end
            end
            return false
        end

        require("barbecue").setup({
            custom_section = function(bfnr, _)
                local custom = ""
                if has_diagnostics(bfnr) then
                    custom = " " .. custom
                end
                return custom
            end,
        })
    end,
}