This article provides a guide on setting up a modern and efficient development environment using Neovim, including configuring completion and LSP, optimizing the user interface, and setting up a remote development environment with Neovim.
Abstract
In this article, we continue our journey to set up a modern and blazingly fast development environment using Neovim. We will configure completion and LSP, optimize the user interface, and set up a remote development environment with Neovim. The Neovim configuration files are available in a GitHub repository. We will use the modern lazy.nvim plugin manager, and our Neovim configuration now has a powerful user interface to manage every plugin that we need. For completion, we will set up completion for the path, buffer, LSP, and command line, set up snippets using LuaSnip, and use the icons in the icons.lua file. For LSP, we will configure the plugins in the init.lua file, set up LSP using nvim-lspconfig and other related plugins, fine-tune the user interface, and set up a remote development environment. We will also configure code formatting and LSP key mappings, and use null-ls.nvim for code formatting if a source is configured. The article includes code snippets and screenshots to guide the reader through the setup process.
Bullet points
Set up completion for the path, buffer, LSP, and command line
Set up snippets using LuaSnip
Use the icons in the icons.lua file
Configure LSP using nvim-lspconfig and other related plugins
Fine-tune the user interface to use the window bar to display the code context, and the status line to show the connected language servers
Set up a remote development environment
Configure code formatting and LSP key mappings
Use null-ls.nvim for code formatting if a source is configured
The Neovim configuration files are available in a GitHub repository
Modern Neovim — LSP and Remote Development
Set up LSP and remote development environment with Neovim.
Modern Neovim — LSP and Remote Development
In this article, we continue our journey to set up a modern and blazingly fast development environment using Neovim. We will configure completion and LSP, optimize the user interface, and set up a remote development environment with Neovim.
The Neovim configuration files are available in this repository.
Getting Started
Using the modernlazy.nvimplugin manager, our Neovim configuration now has a powerful user interface to manage every plugin that we need. In this article, we are going to
set up completion using nvim-cmp and other related completion plugins.
set up LSP using nvim-lspconfig and other related plugins.
fine-tune the user interface to use the window bar to display the code context, and the status line to show the connected language servers.
We use null-ls.nvim to inject LSP diagnostics, code actions, and more via Lua. E.g., we use stylua for Lua formatting and ruff as Python linter (line 48 — line 49).
We use mason.nvim to ensure the stylua and ruff utilities are installed (line 25 — line 28).
neoconf.nvim is used to manage global and project local settings.
neodev.nvim provides full signature help, docs, and completion for the Neovim Lua APIs.
We also installed the language-specific plugins for Rust (line 10 — line 11).
We want to configure the language servers for Python (pyright), Rust (rust_analyzer), Lua (sumneko_lua), JavaScript/TypeScript (tsserver), and Docker (dockerls) (line 3 — line 45).
We use the LspAttach (h :LspAttach) event to configure code formatting and LSP key mappings (line 62 — line 66).
We use mason-lspconfig.nvim to configure the language servers (line 61 — line 81). For language-specific configuration, e.g. rust_analyzer, we use a different setup function (line 75 — line 80).
The screenshot below shows the current code context in the window bar as we navigate the current buffer. If we click on the method or function, the cursor will be positioned at the method/function.
Code Context
We can also develop a Lua module to display the current code context. Check out the following article for details!
Using the status line, we display the connected language servers for the current buffer.
The screenshots below show the language servers for Lua (stylua, sumneko_lua). When we click on the status line component, the LSP information is displayed.
Status Line with LSP InfoStatus Line with LSP Info
The git_repo (line 11) component shows the Git repository when there is more than 1 tab page.
The diagnostics (28) component shows LSP diagnostics.
The lsp_client (line 39) component shows the connected language servers, including those we configure using null-ls.nvim (formatters, linters, hovers, and code actions).
The lua/plugins/lsp/utils.lua file contains the utility functions to get the sources provided by null-ls.nvim.
Remote Development Environment
For remote editing, Netrw makes reading files, writing files, browsing over a network, and local browsing easy. It supports many protocols like scp, ftp, http, rsync, sftp, fetch, dav, etc (:h netrw-ref).
If you are yet to be a Medium member and want to become one, click here. You will gain unlimited access to all Medium articles and support my work directly.