Neovim for Beginners — Code Context

Show code context with line number using the window bar.

alpha2phi
3 min readSep 6, 2022
Neovim for Beginners — Code Context

In the previous articles, we learned how to customize the window bar, and use the lualine.nvim plugin to show the current code context together with other information like diagnostics.

In this article, we will customize the code context further to add the absolute or relative line number to ease navigation.

This article is part of the Neovim for Beginners series.

The Neovim configuration files are available in this repository.

Check out the related articles if you are unfamiliar with the window bar.

Getting Started

Code Context using Tree-sitter

The nvim-treesitter-context plugin shows the current code context using Tree-sitter.

For this plugin, depending on the relativenumber option, it shows the line number relative to the current cursor position, or the actual line number.

--

--