Neovim for Beginners — Status Line

Customize the status line to show useful information, with and without plugins.

alpha2phi

--

Neovim for Beginners — Status Line

Let’s learn how to customize the status line with and without any plugins.

We are going to

  • Configure the status line without using any plugins (:h statusline).
  • Use the Lualine plugin to configure the status line in Lua.
  • Integrate nvim-gps with Lualine to see the current scope in the status line.

This article is part of the Neovim for Beginners series.

The Neovim configuration files can be found in this repository.

Configure Status Line without Plugin

The Basics

By default Neovim status line is empty (:h statusline). The laststatusoption determines when the last window will have a status line (:h status-line).

  • 0: No status line.
  • 1: Display the status line if there is more than one window.
  • 2: Always display a status line.
  • 3: have a global statusline at the bottom instead of one for each window (available since release 0.7)

The status line consists of multiple items, e.g. file name, current line number, total line numbers, date and time, etc.

For each item, it consists of printf style ‘%’ items interspersed with
normal text. Each status line item is of the form

%-0{minwid}.{maxwid}{item}

All fields except the {item} are optional. A single percent sign can
be given as %%. (:h statusline).

Help for Status Line

Configure the Status Line with Lua

With the basics, let’s proceed to configure the status line using Lua.

Type :luafile % to run the Lua file below.

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.