Neovim for Beginners — Window Bar
In this article, we will explore the basics of the window bar (:h winbar
), and learn how to customize it to show the current code context using LSP.
This article is part of the Neovim for Beginners series.
The Neovim configuration files can be found in this repository.
Window Bar
The window bar is a bar that is shown at the top of every window when the winbar
option is configured.
The winbar
(:h winbar
) option can be either global or local to a window (:h global-local
). By default the value is empty.
When non-empty, the winbar
option enables the window bar and determines its contents and the value is evaluated just like the status line (:h ‘statusline’
).
We already talked about the status line in a previous article.
In the lua/statusline/init.lua
file, we have the following configuration.
Instead of setting the status line, we use the same configuration to set the window bar (line 25).
vim.opt.winbar = status_line()
We can see the mode, file name, line number, modified flag, file type, line number, total lines, and percentage through the file.
Code Context
Let’s customize the window bar to show more useful information to help us in coding.
Below is a screenshot of what we want to achieve.