utilyre/barbecue.nvim

github github
winbar
star 79
alert-circle 5
users 2
git-branch 7
CREATED

2022-07-14

UPDATED

2 days ago


https://user-images.githubusercontent.com/91974155/197051920-0e89203e-1f0c-4f3c-af72-e7d5e13340ad.mp4

✨ Features

  • 🖱️ Jump to any context by just clicking on it.
  • 🌲 Have a deeply nested file-tree/context? It's gonna get rid of the less useful parts smartly.
  • 📂 Easily tell where your file is located at by looking at your winbar.
  • 📜 Put whatever your heart desires in the custom section.

📬 Dependencies

📦 Installation

Install barbecue and its dependencies

use {
  "utilyre/barbecue.nvim",
  requires = {
    "neovim/nvim-lspconfig",
    "smiteshp/nvim-navic",
    "kyazdani42/nvim-web-devicons", -- optional
  },
  config = function()
    require("barbecue").setup()
  end,
}

🚀 Usage

Barbecue will work right after installation, but there are several things you should be aware of.

Commands

  • Hide/Show/Toggle winbar

    Barbecue {hide,show,toggle}
    

API

  • Hide/Show/Toggle winbar

    require("barbecue.ui").toggle([false|true])
    
  • Update winbar in a single window

    require("barbecue.ui").update([winnr])
    

Autocmd

In order to customize the autocmd behavior, you need to override barbecue augroup (or ideally set create_autocmd to false and completely handle it yourself) like so

vim.api.nvim_create_autocmd({
  "WinScrolled",
  "BufWinEnter",
  "CursorMoved",
  "InsertLeave",
  "BufWritePost",
  "TextChanged",
  "TextChangedI",
  -- add more events here
}, {
  group = vim.api.nvim_create_augroup("barbecue", {}),
  callback = function()
    require("barbecue.ui").update()

    -- maybe a bit more logic here
  end,
})

🚠 Configuration

{
  ---whether to attach navic to language servers automatically
  ---@type boolean
  attach_navic = true,

  ---whether to create winbar updater autocmd
  ---@type boolean
  create_autocmd = true,

  ---buftypes to enable winbar in
  ---@type string[]
  include_buftypes = { "" },

  ---filetypes not to enable winbar in
  ---@type string[]
  exclude_filetypes = { "toggleterm" },

  modifiers = {
    ---filename modifiers applied to dirname
    ---@type string
    dirname = ":~:.",

    ---filename modifiers applied to basename
    ---@type string
    basename = "",
  },

  ---returns a string to be shown at the end of winbar
  ---@type fun(bufnr: number): string
  custom_section = function()
    return ""
  end,

  ---whether to replace file icon with the modified symbol when buffer is modified
  ---@type boolean
  show_modified = false,

  symbols = {
    ---modification indicator
    ---@type string
    modified = "●",

    ---truncation indicator
    ---@type string
    ellipsis = "…",

    ---entry separator
    ---@type string
    separator = "",
  },

  ---icons for different context entry kinds
  ---`false` to disable kind icons
  ---@type table<string, string>|false
  kinds = {
    File = "",
    Package = "",
    Module = "",
    Namespace = "",
    Macro = "",
    Class = "",
    Constructor = "",
    Field = "",
    Property = "",
    Method = "",
    Struct = "",
    Event = "",
    Interface = "",
    Enum = "",
    EnumMember = "",
    Constant = "",
    Function = "",
    TypeParameter = "",
    Variable = "",
    Operator = "",
    Null = "",
    Boolean = "",
    Number = "",
    String = "",
    Key = "",
    Array = "",
    Object = "",
  },
}

🎨 Highlight Groups

Highlight Group Default Group
BarbecueModified BufferVisibleMod
BarbecueEllipsis Conceal
BarbecueSeparator Conceal
BarbecueDirname Normal
BarbecueBasename Normal
BarbecueContext Normal
BarbecueContextFile CmpItemKindFile
BarbecueContextModule CmpItemKindModule
BarbecueContextNamespace CmpItemKindModule
BarbecueContextPackage CmpItemKindFolder
BarbecueContextClass CmpItemKindClass
BarbecueContextMethod CmpItemKindMethod
BarbecueContextProperty CmpItemKindProperty
BarbecueContextField CmpItemKindField
BarbecueContextConstructor CmpItemKindConstructor
BarbecueContextEnum CmpItemKindEnum
BarbecueContextInterface CmpItemKindInterface
BarbecueContextFunction CmpItemKindFunction
BarbecueContextVariable CmpItemKindVariable
BarbecueContextConstant CmpItemKindConstant
BarbecueContextString CmpItemKindValue
BarbecueContextNumber CmpItemKindValue
BarbecueContextBoolean CmpItemKindValue
BarbecueContextArray CmpItemKindValue
BarbecueContextObject CmpItemKindValue
BarbecueContextKey CmpItemKindValue
BarbecueContextNull CmpItemKindValue
BarbecueContextEnumMember CmpItemKindEnumMember
BarbecueContextStruct CmpItemKindStruct
BarbecueContextEvent CmpItemKindEvent
BarbecueContextOperator CmpItemKindOperator
BarbecueContextTypeParameter CmpItemKindTypeParameter