Skip to content
Shawon edited this page Nov 18, 2025 · 11 revisions

🧩 Winbar

See the following files,

🧭 Configuration

The winbar can be configured via require("bars").setup({ winbar = { ... } }) or require("bars.winbar").setup({ ... }).

Tip

You can use require("bars").setup({ winbar = false }) or require("bars.winbar").setup(false) to disable it!

The configuration table has the following structure.

--- Configuration for the winbar module.
---@class winbar.config
---
---@field force_attach? string[] List of `winbar`s to ignore when attaching.
---
---@field ignore_filetypes string[] Filetypes to ignore when attaching.
---@field ignore_buftypes string[] Buffer types to ignore when attaching.
---
---@field condition? fun(buffer: integer, window: integer): boolean Additional condition for attaching to windows.
---
---@field default winbar.style Default style.
---@field [string] winbar.style Named style.

The default configuration is given below,

winbar.config = {
	force_attach = {},

	ignore_filetypes = { "blink-cmp-menu" },
	ignore_buftypes = { "nofile", "help" },

	default = {
		components = {
			---|fS

			{
				kind = "path",
				condition = function (buffer)
					local check_parsers, parser = pcall(vim.treesitter.get_parser, buffer);

					if check_parsers == false then
						return true;
					elseif parser == nil then
						return true;
					else
						return false;
					end
				end,

				separator = "",
				separator_hl = "Comment",

				default = {
					dir_icon = "󰉋 ",
					icon = "󰈔 ",

					hl = "Special"
				}
			},
			{
				kind = "node",
				depth = 3,

				separator = "",
				separator_hl = "Comment",

				default = {
					_ellipsis = {
						padding_left = " ",
						padding_right = " ",

						icon = "󱎓",

						hl = "BarsVisualBlock"
					},

				},

				["^luadoc$"] = {
					---|fS

					documentation = {
						icon = "󱪙 ",
						hl = "Title"
					},

					class_annotation = {
						icon = "",
						hl = "@keyword.luadoc"
					},

					type_annotation = {
						icon = "󰐫 ",
						hl = "@keyword.luadoc"
					},

					param_annotation = {
						icon = "󰡱 ",
						hl = "@keyword.luadoc"
					},

					alias_annotation = {
						icon = "󰔌 ",
						hl = "@keyword.luadoc"
					},

					continuation = {
						icon = "󰌑 ",
						hl = "@keyword.luadoc"
					},

					return_annotation = {
						icon = "",
						hl = "@keyword.luadoc"
					},

					field_annotation = {
						icon = "",
						hl = "@keyword.luadoc"
					},

					qualifier_annotation = {
						icon = "󰙴 ",
						hl = "@keyword.luadoc"
					},

					generic_annotation = {
						icon = "",
						hl = "@keyword.luadoc"
					},

					vararg_annotation = {
						icon = "",
						hl = "@keyword.luadoc"
					},

					diagnostic_annotation = {
						icon = "",
						hl = "@keyword.luadoc"
					},

					deprecated_annotation = {
						icon = "",
						hl = "@error"
					},

					meta_annotation = {
						icon = "󰐱 ",
						hl = "@keyword.luadoc"
					},

					module_annotation = {
						icon = "",
						hl = "@keyword.luadoc"
					},

					source_annotation = {
						icon = "",
						hl = "@keyword.luadoc"
					},

					version_annotation = {
						icon = "󰯏 ",
						hl = "@keyword.luadoc"
					},

					package_annotation = {
						icon = "󰏖 ",
						hl = "@keyword.luadoc"
					},

					operator_annotation = {
						icon = "",
						hl = "@keyword.luadoc"
					},

					nodiscard_annotation = {
						icon = "󰌾 ",
						hl = "@keyword.luadoc"
					},

					cast_annotation = {
						icon = "󱦈 ",
						hl = "@keyword.luadoc"
					},

					async_annotation = {
						icon = "󰦖 ",
						hl = "@keyword.luadoc"
					},

					overload_annotation = {
						icon = "󱐋 ",
						hl = "@keyword.luadoc"
					},

					enum_annotation = {
						icon = "",
						hl = "@keyword.luadoc"
					},

					language_injection = {
						icon = "",
						hl = "@keyword.luadoc"
					},

					see_reference = {
						icon = "󰈈 ",
						hl = "@keyword.luadoc"
					},

					link_reference = {
						icon = "",
						hl = "@keyword.luadoc"
					},

					since_annotation = {
						icon = "󰔚 ",
						hl = "@keyword.luadoc"
					},

					as_annotation = {
						icon = "󰤖 ",
						hl = "@keyword.luadoc"
					},

					[".+%_type"] = {
						icon = "",
						hl = "@type.luadoc"
					},

					identifier = {
						icon = "󰮄 ",
						hl = "Special"
					},

					["^comment$"] = {
						icon = "󱀡 ",
						hl = "@comment.lua"
					},

					comment_content = {
						icon = "󱀢 ",
						hl = "@comment.lua"
					},

					parameter = {
						icon = "",
						hl = "@variable.parameter.luadoc"
					},

					---|fE
				},

				["^lua$"] = {
					---|fS

					chunk = {
						icon = "󰢱 ",
						hl = "@function.lua"
					},

					variable_declaration = {
						icon = "󰏖 ",
						hl = "@variable"
					},

					function_declaration = {
						icon = "󰡱 ",
						hl = "@function"
					},


					binary_expression = {
						icon = "󱃲 ",
						hl = "Comment"
					},

					["false"] = {
						icon = "󰌶 ",
						hl = "@boolean"
					},

					function_call = {
						icon = "󰡱 ",
						hl = "@function.call.lua"
					},

					function_definition = {
						icon = "󰡱 ",
						hl = "@function.lua"
					},

					["nil"] = {
						icon = "󰆧 ",
						hl = "@constant.builtin.lua"
					},

					number = {
						icon = "",
						hl = "@number.lua"
					},

					parenthesized_expression = {
						icon = "󰅲 ",
						hl = "Comment"
					},

					["string"] = {
						icon = "󰛓 ",
						hl = "@string.lua"
					},

					string_content = {
						icon = "󰴓 ",
						hl = "@string.lua"
					},

					table_constructor = {
						icon = "",
						hl = "@constructor.lua"
					},

					["true"] = {
						icon = "󱠂 ",
						hl = "@boolean"
					},

					unary_expression = {
						icon = "󰋙 ",
						hl = "Comment"
					},

					vararg_expression = {
						icon = "󰋘 ",
						hl = "Comment"
					},

					variable = {
						icon = "󰋘 ",
						hl = "@variable.lua"
					},


					assignment_statement = {
						icon = "󰆦 ",
						hl = "@operator.lua"
					},

					break_statement = {
						icon = "󰆋 ",
						hl = "@keyword.lua"
					},

					declaration = {
						icon = "󰆨 ",
						hl = "@keyword.lua"
					},

					do_statement = {
						icon = "󰣖 ",
						hl = "@keyword.lua"
					},

					empty_statement = {
						icon = "󰆧 ",
						hl = "@keyword.lua"
					},

					for_statement = {
						icon = "󰓦 ",
						hl = "@keyword.lua"
					},

					goto_statement = {
						icon = "󱤬 ",
						hl = "@keyword.lua"
					},

					if_statement = {
						icon = "󰘬 ",
						hl = "@keyword.lua"
					},

					elseif_statement = {
						icon = "󰘬 ",
						hl = "@keyword.lua"
					},

					else_statement = {
						icon = "󰘬 ",
						hl = "@keyword.lua"
					},

					label_statement = {
						icon = "󰓽 ",
						hl = "@label.lua"
					},

					repeat_statement = {
						icon = "",
						hl = "@keyword.lua"
					},

					while_statement = {
						icon = "󰅐 ",
						hl = "@keyword.lua"
					},

					bracket_index_expression = {
						icon = "󰅪 ",
						hl = "@punctuation.bracket.lua"
					},

					dot_index_expression = {
						icon = "󱦜 ",
						hl = "@punctuation.delimiter.lua"
					},

					identifier = {
						icon = "󰮄 ",
						hl = "Special"
					},


					arguments = {
						icon = "󰅲 ",
						hl = "@punctuation.bracket.lua"
					},

					expression = {
						icon = "󱓝 ",
						hl = "@punctuation.bracket.lua"
					},


					expression_list = {
						icon = "󱇂 ",
						hl = "@punctuation.bracket.lua"
					},

					variable_list = {
						icon = "󱇂 ",
						hl = "@punctuation.bracket.lua"
					},


					attribute = {
						icon = "󱈝 ",
						hl = "@attribute.lua"
					},

					block = {
						icon = "󰴓 ",
						hl = "Special"
					},


					return_statement = {
						icon = "",
						hl = "@keyword.lua"
					},

					hash_bang_line = {
						icon = "",
						hl = "Comment"
					},


					["^comment$"] = {
						icon = "󱀡 ",
						hl = "@comment.lua"
					},

					comment_content = {
						icon = "󱀢 ",
						hl = "@comment.lua"
					},


					field = {
						icon = "󱏒 ",
						hl = "@property.lua"
					},


					for_numeric_clause = {
						icon = "",
						hl = "@keyword.lua"
					},

					for_generic_clause = {
						icon = "",
						hl = "@keyword.lua"
					},


					method_index_expression = {
						icon = "",
						hl = "@method.lua"
					},


					parameters = {
						icon = "",
						hl = "@variable.parameter.luadoc"
					},

					---|fE
				},

				["^lua_patterns$"] = {
					chunk = {
						icon = "󰛪 ",
						hl = "@comment"
					},


					start_assertion = {
						icon = "󰾺 ",
						hl = "@keyword"
					},

					end_assertion = {
						icon = "󰾸 ",
						hl = "@keyword"
					},


					zero_or_more = {
						icon = "",
						hl = "@keyword.operator"
					},

					one_or_more = {
						icon = "",
						hl = "@keyword.operator"
					},

					lazy = {
						icon = "",
						hl = "@keyword.operator"
					},

					optional = {
						icon = "",
						hl = "@keyword.operator"
					},


					literal_character = {
						icon = "󱄽 ",
						hl = "@character"
					},

					character_reference = {
						icon = "",
						hl = "@constant.builtin"
					},

					any_character = {
						icon = "",
						hl = "@variable.member"
					},


					character_class = {
						icon = "󰏗 ",
						hl = "@variable.builtin"
					},

					character_range = {
						icon = "󰊱 ",
						hl = "@comment"
					},

					character_set = {
						icon = "󱉓 ",
						hl = "@label"
					},

					character_set_content = {
						icon = "󰆦 ",
						hl = "@comment"
					},

					caprure_group = {
						icon = "",
						hl = "@label"
					},


					escaped_character = {
						icon = "󰩈 ",
						hl = "@string.escape"
					},

					escape_sequence = {
						icon = "󰩈 ",
						hl = "@character.special"
					},
				}
			}

			---|fE
		}
	}
};

🎨 Styles

You can use various styles to easily change how the winbar looks.

--[[ Style for the `winbar`. ]]
---@class winbar.style
---
---@field condition? fun(buffer: integer, window: integer): boolean Condition for this style.(unused when style is `default`)
---@field components winbar.component[] Components for this style.

Example,

default = {
	components = {
		---|fS

		{
			kind = "path",
			condition = function (buffer)
				local check_parsers, parser = pcall(vim.treesitter.get_parser, buffer);

				if check_parsers == false then
					return true;
				elseif parser == nil then
					return true;
				else
					return false;
				end
			end,

			separator = "",
			separator_hl = "Comment",

			default = {
				dir_icon = "󰉋 ",
				icon = "󰈔 ",

				hl = "Special"
			}
		},
		{
			kind = "node",
			depth = 3,

			separator = "",
			separator_hl = "Comment",

			default = {
				_ellipsis = {
					padding_left = " ",
					padding_right = " ",

					icon = "󱎓",

					hl = "BarsVisualBlock"
				},

			},

			["^luadoc$"] = {
				---|fS

				documentation = {
					icon = "󱪙 ",
					hl = "Title"
				},

				class_annotation = {
					icon = "",
					hl = "@keyword.luadoc"
				},

				type_annotation = {
					icon = "󰐫 ",
					hl = "@keyword.luadoc"
				},

				param_annotation = {
					icon = "󰡱 ",
					hl = "@keyword.luadoc"
				},

				alias_annotation = {
					icon = "󰔌 ",
					hl = "@keyword.luadoc"
				},

				continuation = {
					icon = "󰌑 ",
					hl = "@keyword.luadoc"
				},

				return_annotation = {
					icon = "",
					hl = "@keyword.luadoc"
				},

				field_annotation = {
					icon = "",
					hl = "@keyword.luadoc"
				},

				qualifier_annotation = {
					icon = "󰙴 ",
					hl = "@keyword.luadoc"
				},

				generic_annotation = {
					icon = "",
					hl = "@keyword.luadoc"
				},

				vararg_annotation = {
					icon = "",
					hl = "@keyword.luadoc"
				},

				diagnostic_annotation = {
					icon = "",
					hl = "@keyword.luadoc"
				},

				deprecated_annotation = {
					icon = "",
					hl = "@error"
				},

				meta_annotation = {
					icon = "󰐱 ",
					hl = "@keyword.luadoc"
				},

				module_annotation = {
					icon = "",
					hl = "@keyword.luadoc"
				},

				source_annotation = {
					icon = "",
					hl = "@keyword.luadoc"
				},

				version_annotation = {
					icon = "󰯏 ",
					hl = "@keyword.luadoc"
				},

				package_annotation = {
					icon = "󰏖 ",
					hl = "@keyword.luadoc"
				},

				operator_annotation = {
					icon = "",
					hl = "@keyword.luadoc"
				},

				nodiscard_annotation = {
					icon = "󰌾 ",
					hl = "@keyword.luadoc"
				},

				cast_annotation = {
					icon = "󱦈 ",
					hl = "@keyword.luadoc"
				},

				async_annotation = {
					icon = "󰦖 ",
					hl = "@keyword.luadoc"
				},

				overload_annotation = {
					icon = "󱐋 ",
					hl = "@keyword.luadoc"
				},

				enum_annotation = {
					icon = "",
					hl = "@keyword.luadoc"
				},

				language_injection = {
					icon = "",
					hl = "@keyword.luadoc"
				},

				see_reference = {
					icon = "󰈈 ",
					hl = "@keyword.luadoc"
				},

				link_reference = {
					icon = "",
					hl = "@keyword.luadoc"
				},

				since_annotation = {
					icon = "󰔚 ",
					hl = "@keyword.luadoc"
				},

				as_annotation = {
					icon = "󰤖 ",
					hl = "@keyword.luadoc"
				},

				[".+%_type"] = {
					icon = "",
					hl = "@type.luadoc"
				},

				identifier = {
					icon = "󰮄 ",
					hl = "Special"
				},

				["^comment$"] = {
					icon = "󱀡 ",
					hl = "@comment.lua"
				},

				comment_content = {
					icon = "󱀢 ",
					hl = "@comment.lua"
				},

				parameter = {
					icon = "",
					hl = "@variable.parameter.luadoc"
				},

				---|fE
			},

			["^lua$"] = {
				---|fS

				chunk = {
					icon = "󰢱 ",
					hl = "@function.lua"
				},

				variable_declaration = {
					icon = "󰏖 ",
					hl = "@variable"
				},

				function_declaration = {
					icon = "󰡱 ",
					hl = "@function"
				},


				binary_expression = {
					icon = "󱃲 ",
					hl = "Comment"
				},

				["false"] = {
					icon = "󰌶 ",
					hl = "@boolean"
				},

				function_call = {
					icon = "󰡱 ",
					hl = "@function.call.lua"
				},

				function_definition = {
					icon = "󰡱 ",
					hl = "@function.lua"
				},

				["nil"] = {
					icon = "󰆧 ",
					hl = "@constant.builtin.lua"
				},

				number = {
					icon = "",
					hl = "@number.lua"
				},

				parenthesized_expression = {
					icon = "󰅲 ",
					hl = "Comment"
				},

				["string"] = {
					icon = "󰛓 ",
					hl = "@string.lua"
				},

				string_content = {
					icon = "󰴓 ",
					hl = "@string.lua"
				},

				table_constructor = {
					icon = "",
					hl = "@constructor.lua"
				},

				["true"] = {
					icon = "󱠂 ",
					hl = "@boolean"
				},

				unary_expression = {
					icon = "󰋙 ",
					hl = "Comment"
				},

				vararg_expression = {
					icon = "󰋘 ",
					hl = "Comment"
				},

				variable = {
					icon = "󰋘 ",
					hl = "@variable.lua"
				},


				assignment_statement = {
					icon = "󰆦 ",
					hl = "@operator.lua"
				},

				break_statement = {
					icon = "󰆋 ",
					hl = "@keyword.lua"
				},

				declaration = {
					icon = "󰆨 ",
					hl = "@keyword.lua"
				},

				do_statement = {
					icon = "󰣖 ",
					hl = "@keyword.lua"
				},

				empty_statement = {
					icon = "󰆧 ",
					hl = "@keyword.lua"
				},

				for_statement = {
					icon = "󰓦 ",
					hl = "@keyword.lua"
				},

				goto_statement = {
					icon = "󱤬 ",
					hl = "@keyword.lua"
				},

				if_statement = {
					icon = "󰘬 ",
					hl = "@keyword.lua"
				},

				elseif_statement = {
					icon = "󰘬 ",
					hl = "@keyword.lua"
				},

				else_statement = {
					icon = "󰘬 ",
					hl = "@keyword.lua"
				},

				label_statement = {
					icon = "󰓽 ",
					hl = "@label.lua"
				},

				repeat_statement = {
					icon = "",
					hl = "@keyword.lua"
				},

				while_statement = {
					icon = "󰅐 ",
					hl = "@keyword.lua"
				},

				bracket_index_expression = {
					icon = "󰅪 ",
					hl = "@punctuation.bracket.lua"
				},

				dot_index_expression = {
					icon = "󱦜 ",
					hl = "@punctuation.delimiter.lua"
				},

				identifier = {
					icon = "󰮄 ",
					hl = "Special"
				},


				arguments = {
					icon = "󰅲 ",
					hl = "@punctuation.bracket.lua"
				},

				expression = {
					icon = "󱓝 ",
					hl = "@punctuation.bracket.lua"
				},


				expression_list = {
					icon = "󱇂 ",
					hl = "@punctuation.bracket.lua"
				},

				variable_list = {
					icon = "󱇂 ",
					hl = "@punctuation.bracket.lua"
				},


				attribute = {
					icon = "󱈝 ",
					hl = "@attribute.lua"
				},

				block = {
					icon = "󰴓 ",
					hl = "Special"
				},


				return_statement = {
					icon = "",
					hl = "@keyword.lua"
				},

				hash_bang_line = {
					icon = "",
					hl = "Comment"
				},


				["^comment$"] = {
					icon = "󱀡 ",
					hl = "@comment.lua"
				},

				comment_content = {
					icon = "󱀢 ",
					hl = "@comment.lua"
				},


				field = {
					icon = "󱏒 ",
					hl = "@property.lua"
				},


				for_numeric_clause = {
					icon = "",
					hl = "@keyword.lua"
				},

				for_generic_clause = {
					icon = "",
					hl = "@keyword.lua"
				},


				method_index_expression = {
					icon = "",
					hl = "@method.lua"
				},


				parameters = {
					icon = "",
					hl = "@variable.parameter.luadoc"
				},

				---|fE
			},

			["^lua_patterns$"] = {
				chunk = {
					icon = "󰛪 ",
					hl = "@comment"
				},


				start_assertion = {
					icon = "󰾺 ",
					hl = "@keyword"
				},

				end_assertion = {
					icon = "󰾸 ",
					hl = "@keyword"
				},


				zero_or_more = {
					icon = "",
					hl = "@keyword.operator"
				},

				one_or_more = {
					icon = "",
					hl = "@keyword.operator"
				},

				lazy = {
					icon = "",
					hl = "@keyword.operator"
				},

				optional = {
					icon = "",
					hl = "@keyword.operator"
				},


				literal_character = {
					icon = "󱄽 ",
					hl = "@character"
				},

				character_reference = {
					icon = "",
					hl = "@constant.builtin"
				},

				any_character = {
					icon = "",
					hl = "@variable.member"
				},


				character_class = {
					icon = "󰏗 ",
					hl = "@variable.builtin"
				},

				character_range = {
					icon = "󰊱 ",
					hl = "@comment"
				},

				character_set = {
					icon = "󱉓 ",
					hl = "@label"
				},

				character_set_content = {
					icon = "󰆦 ",
					hl = "@comment"
				},

				caprure_group = {
					icon = "",
					hl = "@label"
				},


				escaped_character = {
					icon = "󰩈 ",
					hl = "@string.escape"
				},

				escape_sequence = {
					icon = "󰩈 ",
					hl = "@character.special"
				},
			}
		}

		---|fE
	}
}

📦 Components

Each style contains one or more components which can be any one of,

---@alias winbar.component
---| winbar.components.custom Custom text.
---| winbar.components.node Node hierarchy for the node under cursor.
---| winbar.components.path Path segments relative to `current working directory`.

🧩 Component: custom

Shows some custom text.

--- Custom section for the winbar.
---@class winbar.components.custom
---
---@field kind "custom"
---@field condition? fun(buffer: integer, window: integer, winbar: string): boolean Condition for this component.
---
---@field value string | fun(buffer: integer, window: integer, winbar: string): string Text to show for this section.

🧩 Component: node

Shows the node hierarchy of the current node.

--- Shows the current node's hierarchy.
---@class winbar.components.node
---
---@field kind "node"
---@field condition? fun(buffer: integer, window: integer, winbar: string): boolean Condition for this component.
---
---@field throttle? integer Update delay(in milliseconds).
---@field depth? integer Maximum node depth.
---
---@field separator? string Separator between nodes.
---@field separator_hl? string Highlight group for the separator.
---
---@field default node.language.opts Default configuration for languages.
---@field [string] node.language.opts Configuration for language named `string`.

Example,

{
	kind = "node",
	depth = 3,

	separator = "",
	separator_hl = "Comment",

	default = {
		_ellipsis = {
			padding_left = " ",
			padding_right = " ",

			icon = "󱎓",

			hl = "BarsVisualBlock"
		},

	},

	["^luadoc$"] = {
		---|fS

		documentation = {
			icon = "󱪙 ",
			hl = "Title"
		},

		class_annotation = {
			icon = "",
			hl = "@keyword.luadoc"
		},

		type_annotation = {
			icon = "󰐫 ",
			hl = "@keyword.luadoc"
		},

		param_annotation = {
			icon = "󰡱 ",
			hl = "@keyword.luadoc"
		},

		alias_annotation = {
			icon = "󰔌 ",
			hl = "@keyword.luadoc"
		},

		continuation = {
			icon = "󰌑 ",
			hl = "@keyword.luadoc"
		},

		return_annotation = {
			icon = "",
			hl = "@keyword.luadoc"
		},

		field_annotation = {
			icon = "",
			hl = "@keyword.luadoc"
		},

		qualifier_annotation = {
			icon = "󰙴 ",
			hl = "@keyword.luadoc"
		},

		generic_annotation = {
			icon = "",
			hl = "@keyword.luadoc"
		},

		vararg_annotation = {
			icon = "",
			hl = "@keyword.luadoc"
		},

		diagnostic_annotation = {
			icon = "",
			hl = "@keyword.luadoc"
		},

		deprecated_annotation = {
			icon = "",
			hl = "@error"
		},

		meta_annotation = {
			icon = "󰐱 ",
			hl = "@keyword.luadoc"
		},

		module_annotation = {
			icon = "",
			hl = "@keyword.luadoc"
		},

		source_annotation = {
			icon = "",
			hl = "@keyword.luadoc"
		},

		version_annotation = {
			icon = "󰯏 ",
			hl = "@keyword.luadoc"
		},

		package_annotation = {
			icon = "󰏖 ",
			hl = "@keyword.luadoc"
		},

		operator_annotation = {
			icon = "",
			hl = "@keyword.luadoc"
		},

		nodiscard_annotation = {
			icon = "󰌾 ",
			hl = "@keyword.luadoc"
		},

		cast_annotation = {
			icon = "󱦈 ",
			hl = "@keyword.luadoc"
		},

		async_annotation = {
			icon = "󰦖 ",
			hl = "@keyword.luadoc"
		},

		overload_annotation = {
			icon = "󱐋 ",
			hl = "@keyword.luadoc"
		},

		enum_annotation = {
			icon = "",
			hl = "@keyword.luadoc"
		},

		language_injection = {
			icon = "",
			hl = "@keyword.luadoc"
		},

		see_reference = {
			icon = "󰈈 ",
			hl = "@keyword.luadoc"
		},

		link_reference = {
			icon = "",
			hl = "@keyword.luadoc"
		},

		since_annotation = {
			icon = "󰔚 ",
			hl = "@keyword.luadoc"
		},

		as_annotation = {
			icon = "󰤖 ",
			hl = "@keyword.luadoc"
		},

		[".+%_type"] = {
			icon = "",
			hl = "@type.luadoc"
		},

		identifier = {
			icon = "󰮄 ",
			hl = "Special"
		},

		["^comment$"] = {
			icon = "󱀡 ",
			hl = "@comment.lua"
		},

		comment_content = {
			icon = "󱀢 ",
			hl = "@comment.lua"
		},

		parameter = {
			icon = "",
			hl = "@variable.parameter.luadoc"
		},

		---|fE
	},

	["^lua$"] = {
		---|fS

		chunk = {
			icon = "󰢱 ",
			hl = "@function.lua"
		},

		variable_declaration = {
			icon = "󰏖 ",
			hl = "@variable"
		},

		function_declaration = {
			icon = "󰡱 ",
			hl = "@function"
		},


		binary_expression = {
			icon = "󱃲 ",
			hl = "Comment"
		},

		["false"] = {
			icon = "󰌶 ",
			hl = "@boolean"
		},

		function_call = {
			icon = "󰡱 ",
			hl = "@function.call.lua"
		},

		function_definition = {
			icon = "󰡱 ",
			hl = "@function.lua"
		},

		["nil"] = {
			icon = "󰆧 ",
			hl = "@constant.builtin.lua"
		},

		number = {
			icon = "",
			hl = "@number.lua"
		},

		parenthesized_expression = {
			icon = "󰅲 ",
			hl = "Comment"
		},

		["string"] = {
			icon = "󰛓 ",
			hl = "@string.lua"
		},

		string_content = {
			icon = "󰴓 ",
			hl = "@string.lua"
		},

		table_constructor = {
			icon = "",
			hl = "@constructor.lua"
		},

		["true"] = {
			icon = "󱠂 ",
			hl = "@boolean"
		},

		unary_expression = {
			icon = "󰋙 ",
			hl = "Comment"
		},

		vararg_expression = {
			icon = "󰋘 ",
			hl = "Comment"
		},

		variable = {
			icon = "󰋘 ",
			hl = "@variable.lua"
		},


		assignment_statement = {
			icon = "󰆦 ",
			hl = "@operator.lua"
		},

		break_statement = {
			icon = "󰆋 ",
			hl = "@keyword.lua"
		},

		declaration = {
			icon = "󰆨 ",
			hl = "@keyword.lua"
		},

		do_statement = {
			icon = "󰣖 ",
			hl = "@keyword.lua"
		},

		empty_statement = {
			icon = "󰆧 ",
			hl = "@keyword.lua"
		},

		for_statement = {
			icon = "󰓦 ",
			hl = "@keyword.lua"
		},

		goto_statement = {
			icon = "󱤬 ",
			hl = "@keyword.lua"
		},

		if_statement = {
			icon = "󰘬 ",
			hl = "@keyword.lua"
		},

		elseif_statement = {
			icon = "󰘬 ",
			hl = "@keyword.lua"
		},

		else_statement = {
			icon = "󰘬 ",
			hl = "@keyword.lua"
		},

		label_statement = {
			icon = "󰓽 ",
			hl = "@label.lua"
		},

		repeat_statement = {
			icon = "",
			hl = "@keyword.lua"
		},

		while_statement = {
			icon = "󰅐 ",
			hl = "@keyword.lua"
		},

		bracket_index_expression = {
			icon = "󰅪 ",
			hl = "@punctuation.bracket.lua"
		},

		dot_index_expression = {
			icon = "󱦜 ",
			hl = "@punctuation.delimiter.lua"
		},

		identifier = {
			icon = "󰮄 ",
			hl = "Special"
		},


		arguments = {
			icon = "󰅲 ",
			hl = "@punctuation.bracket.lua"
		},

		expression = {
			icon = "󱓝 ",
			hl = "@punctuation.bracket.lua"
		},


		expression_list = {
			icon = "󱇂 ",
			hl = "@punctuation.bracket.lua"
		},

		variable_list = {
			icon = "󱇂 ",
			hl = "@punctuation.bracket.lua"
		},


		attribute = {
			icon = "󱈝 ",
			hl = "@attribute.lua"
		},

		block = {
			icon = "󰴓 ",
			hl = "Special"
		},


		return_statement = {
			icon = "",
			hl = "@keyword.lua"
		},

		hash_bang_line = {
			icon = "",
			hl = "Comment"
		},


		["^comment$"] = {
			icon = "󱀡 ",
			hl = "@comment.lua"
		},

		comment_content = {
			icon = "󱀢 ",
			hl = "@comment.lua"
		},


		field = {
			icon = "󱏒 ",
			hl = "@property.lua"
		},


		for_numeric_clause = {
			icon = "",
			hl = "@keyword.lua"
		},

		for_generic_clause = {
			icon = "",
			hl = "@keyword.lua"
		},


		method_index_expression = {
			icon = "",
			hl = "@method.lua"
		},


		parameters = {
			icon = "",
			hl = "@variable.parameter.luadoc"
		},

		---|fE
	},

	["^lua_patterns$"] = {
		chunk = {
			icon = "󰛪 ",
			hl = "@comment"
		},


		start_assertion = {
			icon = "󰾺 ",
			hl = "@keyword"
		},

		end_assertion = {
			icon = "󰾸 ",
			hl = "@keyword"
		},


		zero_or_more = {
			icon = "",
			hl = "@keyword.operator"
		},

		one_or_more = {
			icon = "",
			hl = "@keyword.operator"
		},

		lazy = {
			icon = "",
			hl = "@keyword.operator"
		},

		optional = {
			icon = "",
			hl = "@keyword.operator"
		},


		literal_character = {
			icon = "󱄽 ",
			hl = "@character"
		},

		character_reference = {
			icon = "",
			hl = "@constant.builtin"
		},

		any_character = {
			icon = "",
			hl = "@variable.member"
		},


		character_class = {
			icon = "󰏗 ",
			hl = "@variable.builtin"
		},

		character_range = {
			icon = "󰊱 ",
			hl = "@comment"
		},

		character_set = {
			icon = "󱉓 ",
			hl = "@label"
		},

		character_set_content = {
			icon = "󰆦 ",
			hl = "@comment"
		},

		caprure_group = {
			icon = "",
			hl = "@label"
		},


		escaped_character = {
			icon = "󰩈 ",
			hl = "@string.escape"
		},

		escape_sequence = {
			icon = "󰩈 ",
			hl = "@character.special"
		},
	}
}

🧩 Component: path

Shows the path segments of the current file relative to the current working directory.

Note

This is disabled if any tree-sitter parser(s) is attached to the buffer.

--- Configuration for file path segment.
---@class winbar.components.path
---
---@field kind "path"
---@field condition? fun(buffer: integer, window: integer, winbar: string): boolean Condition for this component.
---
---@field throttle? integer Update delay(in milliseconds).
---
---@field separator? string Separator between path components.
---@field separator_hl? string Highlight group for the separator.
---
---@field default winbar.section Default configuration for path segment.
---@field [string] winbar.section Configuration for segments matching `string`.

Example,

{
	kind = "path",
	condition = function (buffer)
		local check_parsers, parser = pcall(vim.treesitter.get_parser, buffer);

		if check_parsers == false then
			return true;
		elseif parser == nil then
			return true;
		else
			return false;
		end
	end,

	separator = "",
	separator_hl = "Comment",

	default = {
		dir_icon = "󰉋 ",
		icon = "󰈔 ",

		hl = "Special"
	}
},

💡 API

You can access this module via,

local winbar = require("bars.winbar");

🧩 High level API

The winbar module has the following API functions.

  • winbar.setup(config), Updates configuration of the winbar.

  • winbar.Start(), Starts the module and attaches & enables custom winbar for all valid windows.

  • winbar.Stop(), Stops the module and detaches & disables custom winbar for all valid windows.

  • winbar.Toggle(), Toggles the custom winbar for all valid windows.

  • winbar.Enable(), Enables the custom winbar for all disabled windows.

  • winbar.Disable(), Disables the custom winbar for all enabled windows.

  • winbar.toggle(window), Toggles the custom winbar for window.

  • winbar.enable(window), Enables the custom winbar for window(if it's valid & disabled).

  • winbar.disable(window), Disables the custom winbar for window(if it's valid & disabled).

🧩 Low level API

  • winbar.config, Current configuration.
  • winbar.state, Current state.
winbar.state = {
	enable = true,
	attached_windows = {}
};
  • winbar.attach(window), Attaches to window(doesn't check ignore_filetypes, ignore_buftypes & condition).
  • winbar.detach(window), Detaches from window.
    • vim.w.bars_winbar_style, User defined winbar style of the current window.
    • vim.w._bars_winbar_style, Calculated winbar style of the current window.

Clone this wiki locally