Skip to content

Usage_Core

Shawon edited this page Mar 14, 2025 · 1 revision

🚀 Usage: Core

🧭 Configuration

Bars.nvim normally works out-of-the-box. You can use require("bars").setup() to configure various parts of the plugin.

See type definition.
--- Primary configuration table.
---@class bars.config
---
--- When true, all options are set
--- **globally**.
--- Can be used to prevent visible
--- changes to the bars & lines when
--- opening Neovim or new windows.
---@field global? boolean
---
--- Statusline configuration.
---@field statusline? boolean | statusline.config | fun(): (boolean | statusline.config)
---
--- Statuscolumn configuration.
---@field statuscolumn? boolean | statuscolumn.config | fun(): (boolean | statuscolumn.config)
---
--- Winbar configuration.
---@field winbar? boolean | winbar.config | fun(): (boolean | winbar.config)
---
--- Tabline configuration.
---@field tabline? boolean | tabline.config | fun(): (boolean | tabline.config)
require("bars").setup({
    global = true,

    statuscolumn = true,
    statusline = true,
    winbar = false, -- Disables the winbar.

    tabline = true
});

Tip

The values can also be functions too! And can also be the configuration table for the module.

require("bars").setup({
    winbar = function ()
        local TERMUX_VERSION = vim.fn.getenv("TERMUX_APP__APP_VERSION_NAME");

        if TERMUX_VERSION then
            --- Disable winbar inside Termux.
            return false;
        else
            return {
                default = {
                    --- Config
                }
            };
        end
    end
});

🧰 Commands

This plugin provides a single command :Bars which has sub-commands that can be used to do different things.

USAGE,
    :Bars

    :Bars [sub-command]

    :Bars [sub-command] [modifier]

    :Bars [sub-command] [modifier] [window_1] [window_2] ..

EXAMPLE,
    :Bars toggle ? 1000

The sub-commands are given below,

Sub-command Description
Toggle Used to toggle statusline, statuscolumn etc. globally.
Enable Used to enable statusline, statuscolumn etc. globally.
Disable Used to disable statusline, statuscolumn etc. globally.
toggle Used to toggle statusline, statuscolumn etc. of given window(s).
enable Used to enable statusline, statuscolumn etc. of given window(s).
disable Used to disable statusline, statuscolumn etc. of given window(s).
clean Cleans up cached values of deleted windows.
update Updates the module's configuration ID of given window.

All the sub-commands support modifier to specify which modules should be affected by the command.

Tip

If you want to run a sub-command on the current window then you can ignore the modifier.

" Toggles all bars & lines for the current window.
:Bars toggle

Modifiers are given below,

Modifier Description
all Affects all modules.
? Prompt which module(s) to affect.
statusline Self-explanatory.
statuscolumn Self-explanatory.
tabline Self-explanatory.
winbar Self-explanatory.

You can add any number of windows after the modifier to specify which windows to run the command on.

Tip

Cmdline completion are provided for all sub-commands/modifiers/windows!

Clone this wiki locally