Neovim for Beginners —LSP using null-ls.nvim
We configured the built-in Neovim LSP in the previous articles. However, depending on the language servers' implementation, some LSP features may not be available.
E.g. if we are using Pyright as the Python language server, the code formatting feature is not supported. Even if the feature is available, we may still want to use other tools for the same purpose.
There are several options available to complement the missing language server features, e.g. use a general-purpose language server like
efm, or plugins like
null-ls.nvim to inject LSP diagnostics, code actions, and more by allowing third-party tools and utilities to hook into the LSP client.
In this article, we are going to
- Configure the
null-ls.nvimplugin for diagnostics/linting, code actions, formatting, and hover dictionary.
- Configure auto-formatting.
- Enhance the status line to display the third-party diagnostics and formatting tools used by
This article is part of the Neovim for Beginners series.
The Neovim configuration files can be found in this repository.
null-ls.nvim sources are able to hook into the following LSP features:
- Code actions
- Diagnostics (file- and project-level)
- Formatting (including range formatting)
Tip: To see the capabilities of the language server attached to the current buffer, run
Let’s get started by installing the plugin. In the
lua/plugins.lua file, add the lines to install
- We install
null-ls.nvim(line 5 and line 13).