This is a VS Code like winbar that uses nvim-navic in order to get LSP context from your language server.
demo.mp4
-
π±οΈ 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.
-
NVIM v0.8+: Winbar support.
-
nvim-lspconfig: Dependency of nvim-navic.
-
nvim-navic: LSP
textDocument/documentSymbol
provider. -
nvim-web-devicons: File icon provider. (optional)
NOTE: Make sure barbecue loads after your colorscheme.
-
local spec = { "utilyre/barbecue.nvim", version = "*", dependencies = { "neovim/nvim-lspconfig", "SmiteshP/nvim-navic", "nvim-tree/nvim-web-devicons", -- optional dependency }, } function spec.config() require("barbecue").setup() end return spec
-
use({ "utilyre/barbecue.nvim", tag = "*", requires = { "neovim/nvim-lspconfig", "SmiteshP/nvim-navic", "nvim-tree/nvim-web-devicons", -- optional dependency }, after = "nvim-web-devicons", -- keep this if you're using NvChad config = function() require("barbecue").setup() end, })
Barbecue will work right after installation, but there are several things you should be aware of.
-
Hide/Show/Toggle winbar
Barbecue {hide,show,toggle}
-
Hide/Show/Toggle winbar
require("barbecue.ui").toggle([false|true])
-
Update winbar in a single window
require("barbecue.ui").update([winnr])
-
Navigate to an entry by the given index
require("barbecue.ui").navigate(index --[[ negative values begin from the end ]], [winnr])
-
Gain better performance when moving the cursor around
-- triggers CursorHold event faster vim.opt.updatetime = 200 require("barbecue").setup({ create_autocmd = false, -- prevent barbecue from updating itself automatically }) vim.api.nvim_create_autocmd({ "WinScrolled", "BufWinEnter", "CursorHold", "InsertLeave", -- include these if you have set `show_modified` to `true` "BufWritePost", "TextChanged", "TextChangedI", }, { group = vim.api.nvim_create_augroup("barbecue#create_autocmd", {}), callback = function() require("barbecue.ui").update() end, })
-
Customize theme
You can pass a
theme
table to thesetup
function and override the default theme. Thistheme
table links each highlight to its value (value is the same type asval
parameter in:help nvim_set_hl
).require("barbecue").setup({ theme = { -- this highlight is used to override other highlights -- you can take advantage of its `bg` and set a background throughout your winbar -- (e.g. basename will look like this: { fg = "#c0caf5", bold = true }) normal = { fg = "#c0caf5" }, -- these highlights correspond to symbols table from config ellipsis = { fg = "#737aa2" }, separator = { fg = "#737aa2" }, modified = { fg = "#737aa2" }, -- these highlights represent the _text_ of three main parts of barbecue dirname = { fg = "#737aa2" }, basename = { bold = true }, context = {}, -- these highlights are used for context/navic icons context_file = { fg = "#ac8fe4" }, context_module = { fg = "#ac8fe4" }, context_namespace = { fg = "#ac8fe4" }, context_package = { fg = "#ac8fe4" }, context_class = { fg = "#ac8fe4" }, context_method = { fg = "#ac8fe4" }, context_property = { fg = "#ac8fe4" }, context_field = { fg = "#ac8fe4" }, context_constructor = { fg = "#ac8fe4" }, context_enum = { fg = "#ac8fe4" }, context_interface = { fg = "#ac8fe4" }, context_function = { fg = "#ac8fe4" }, context_variable = { fg = "#ac8fe4" }, context_constant = { fg = "#ac8fe4" }, context_string = { fg = "#ac8fe4" }, context_number = { fg = "#ac8fe4" }, context_boolean = { fg = "#ac8fe4" }, context_array = { fg = "#ac8fe4" }, context_object = { fg = "#ac8fe4" }, context_key = { fg = "#ac8fe4" }, context_null = { fg = "#ac8fe4" }, context_enum_member = { fg = "#ac8fe4" }, context_struct = { fg = "#ac8fe4" }, context_event = { fg = "#ac8fe4" }, context_operator = { fg = "#ac8fe4" }, context_type_parameter = { fg = "#ac8fe4" }, }, })
-
Get nvim-navic working with multiple tabs (#35)
require("barbecue").setup({ attach_navic = false, -- prevent barbecue from automatically attaching nvim-navic }) require("lspconfig")[server].setup({ -- ... on_attach = function(client, bufnr) -- ... if client.server_capabilities["documentSymbolProvider"] then require("nvim-navic").attach(client, bufnr) end -- ... end, -- ... })
Click to see default config
{
---whether to show/use navic in the winbar
---@type boolean
show_navic = true,
---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 = { "gitcommit", "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,
---`auto` uses your current colorscheme's theme or generates a theme based on it
---`string` is the theme name to be used (theme should be located under `barbecue.theme` module)
---`barbecue.Theme` is a table that overrides the `auto` theme detection/generation
---@type "auto"|string|barbecue.Theme
theme = "auto",
---whether to display path to file
---@type boolean
show_dirname = true,
---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 = "ξ©»",
Module = "ξͺ",
Namespace = "ξͺ",
Package = "ξͺ",
Class = "ξ",
Method = "ξͺ",
Property = "ξ₯",
Field = "ξ",
Constructor = "ξ",
Enum = "ξͺ",
Interface = "ξ‘",
Function = "ξͺ",
Variable = "ξͺ",
Constant = "ξ",
String = "ξͺ",
Number = "ξͺ",
Boolean = "ξͺ",
Array = "ξͺ",
Object = "ξͺ",
Key = "ξ¬",
Null = "ξͺ",
EnumMember = "ξ",
Struct = "ξͺ",
Event = "ξͺ",
Operator = "ξ€",
TypeParameter = "ξͺ",
},
}
See CONTRIBUTING.md.