Turn Neovim into a Professional IDE with LazyVim: LSP Configuration, Mason, and Workflow Optimization

Development tutorial - IT technology blog
Development tutorial - IT technology blog

Why switch from VS Code to Neovim?

The question I get asked most is: “VS Code works great, so why struggle with Neovim keybindings?”. After 5 years of grinding through various editors, my answer boils down to: Absolute Focus.

Working on a Next.js project with over 100 components, I realized that taking my hands off the keyboard to use the mouse for file selection constantly interrupted my train of thought. After switching to LazyVim, my productivity skyrocketed. Neovim only consumes about 60-80MB of RAM, whereas VS Code often hogs 1GB to 1.5GB for the same project.

Approaches to Customizing Neovim

Before diving into the configuration, you need to understand the existing options:

  • Build it yourself (Vanilla Neovim): You write your own init.lua and manage plugins with lazy.nvim. This approach gives you a deep understanding of the system but is extremely time-consuming. I once spent three sleepless nights just getting LSP to recognize a config file correctly.
  • Use a distribution (Distros): Like NvChad, AstroNvim, or LazyVim. These are pre-optimized frameworks that are ready to use out of the box.

Why is LazyVim the #1 Choice?

After trying NvChad (fast but hard to customize) and AstroNvim (a bit bloated), I settled on LazyVim. The biggest selling point is its modular structure. Thanks to the lazy-loading mechanism, plugins only load when actually needed. As a result, the startup time consistently stays under 50ms.

Implementation: Turning Neovim into a Coding Machine

1. Environment Preparation

You need to install Neovim version 0.9.0 or higher. To avoid display issues, install a Nerd Font. I prefer JetBrainsMono Nerd Font for its crisp rendering.

# Check current version
nvim --version

2. Installing LazyVim Starter

We will clone the starter version to get the standard framework. Don’t forget to back up your old configuration to avoid data loss:

# Backup old configuration
mv ~/.config/nvim ~/.config/nvim.bak
mv ~/.local/share/nvim ~/.local/share/nvim.bak

# Clone LazyVim starter
git clone https://github.com/LazyVim/starter ~/.config/nvim
rm -rf ~/.config/nvim/.git

Open Neovim using the nvim command, and the system will automatically download the plugins. Seeing the packages installed automatically with a modern UI that rivals JetBrains is truly exciting.

3. Managing LSP and Tooling with Mason

Mason is one of the most valuable features. It acts as an “App Store” for Language Servers (LSP), Linters, and Formatters.

Just type :Mason, and you can instantly install pyright for Python, tsserver for TypeScript, or gopls for Go with a single keystroke. Instead of manually installing each binary on your OS, Mason manages everything centrally within the nvim directory.

4. Keybindings for Workflow Optimization

LazyVim’s keybinding system is based on the <leader> key (Space bar). These are the combinations I use constantly to code faster:

  • <space> f f: Instantly search for files via Telescope.
  • <space> s g: Search for text strings across the entire project (Live grep).
  • <space> e: Toggle the Neo-tree directory structure.
  • K: Quickly view documentation (hover doc) for a function or variable.
  • g d: Jump directly to the code definition (Go to definition).

Configuring Extras for Each Language

LazyVim supports a very convenient LazyExtras feature. You no longer need to copy-paste dozens of complex Lua code lines to set up environments for Docker or Rust.

Type :LazyExtras and use the x key to activate modules like lang.typescript or ui.edgy. The system will automatically configure format-on-save and proper auto-completion for that language.

Personal Customization to Master the Tool

To make Neovim truly work for you, you should edit the lua/config/options.lua file. An essential setting is relativenumber, which helps you calculate line distances to jump through code extremely fast.

-- File: lua/config/options.lua
vim.opt.relativenumber = true -- Show relative line numbers
vim.opt.cursorline = true     -- Highlight current line

If you frequently work with Git, take advantage of the built-in LazyGit. Press <space> g g, and a powerful Git management interface will appear. You can stage, commit, or resolve conflicts without ever leaving your code screen.

Conclusion

Switching to Neovim might slow you down for the first 1-2 weeks as you memorize keybindings. However, the reward is a smooth, mouse-free workflow that is extremely resource-efficient. Start with basic configurations, then gradually build a workspace that reflects your personal style.

Share: