Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
Neovim's LSP ecosystem is growing, and plugins like telescope.nvim and trouble.nvim make it a joy to work with LSP features like code actions and diagnostics.
Unlike the VS Code and coc.nvim ecosystems, Neovim doesn't provide a way for non-LSP sources to hook into its LSP client. null-ls is an attempt to bridge that gap and simplify the process of creating, sharing, and setting up LSP sources using pure Lua.
null-ls is also an attempt to reduce the boilerplate required to set up general-purpose language servers and improve performance by removing the need for external processes.
null-ls is in beta status. Please see below for steps to follow if something doesn't work the way you expect (or doesn't work at all).
At the moment, null-is is compatible with Neovim 0.6.0 (stable) and 0.7 (head), but some features and performance improvements are exclusive to the latest version.
null-ls sources are able to hook into the following LSP features:
-
Code actions
-
Diagnostics (file- and project-level)
-
Formatting (including range formatting)
-
Hover
-
Completion
null-ls includes built-in sources for each of these features to provide out-of-the-box functionality. See BUILTINS for instructions on how to set up sources and a list of available sources.
null-ls also provides helpers to streamline the process of spawning and transforming the output of command-line processes into an LSP-friendly format. If you want to create your own source, either for personal use or for a plugin, see HELPERS for details.
Install null-ls using your favorite package manager. The plugin depends on plenary.nvim, which you are (probably) already using.
To get started, you must set up null-ls and register at least one source. See BUILTINS to learn about available built-in sources and CONFIG for information about setting up and configuring null-ls.
require("null-ls").setup({
sources = {
require("null-ls").builtins.formatting.stylua,
require("null-ls").builtins.diagnostics.eslint,
require("null-ls").builtins.completion.spell,
},
})
The definitive source for information about null-ls is its documentation, which contains information about how null-ls works, how to set it up, and how to create sources.
< 8000 div class="markdown-heading" dir="auto">