Neovim Overhaul: 5 Easy Steps to Streamline Your Workflow and Boost Speed
Your no-BS weekly brief on software engineering.
Join 100,000+ developers
Neovim has become the editor of choice for developers seeking customization and power. However, as configurations grow over time, they can become bloated, slow, and difficult to maintain. This article explores how to streamline your Neovim setup, keeping it clean, fast, and efficient, without sacrificing functionality.
After all, you don't need everything and the kitchen sink.
If you're just starting out with Neovim, consider setting up a simple configuration before diving into optimization.
Why Debloat Your Configuration?
When starting with Neovim, it’s easy to add plugins, keybindings, and settings that seem useful at the time. Over months or years, this can lead to:
- Slower startup times: A plethora of plugins can drastically increase load time.
- Conflicting features: Multiple plugins may overlap in functionality, creating redundancy or errors.
- Maintenance headaches: Larger configurations are harder to debug and adapt.
Debloating simplifies your setup, improving performance and maintainability while ensuring that every component serves a clear purpose. However, if you use a plugin manager like lazy.nvim
, which dynamically loads plugins based on context, some of these issues are inherently mitigated.
NOTE: Even if you're not using lazy.nvim
, these steps apply to other plugin managers like packer.nvim
or vim-plug
.
Step 1: Audit Your Plugins
Even with lazy.nvim
optimizing plugin loading, it's essential to audit your plugin list periodically. Identify plugins that:
- You rarely use: Remove these outright.
- Have overlapping functionality: Pick one plugin to handle a specific task.
- Don’t align with your workflow: Focus on tools that provide real value.
Example
Instead of using multiple plugins for file navigation, consider consolidating around a single tool like telescope.nvim
or fzf-lua
. Even with lazy loading, reducing redundant plugins makes maintenance easier.
Step 2: Benchmark Your Configuration
To complement lazy.nvim
's optimizations, use tools like --startuptime
to identify any remaining performance bottlenecks. This can reveal non-plugin-related delays or highlight plugins that still impact performance.
nvim --startuptime startup.log
Analyze the generated log to pinpoint issues outside of lazy-loaded plugins. Consider further optimizing initialization code or keybindings. Look for lines with the highest load times and determine if they’re associated with plugins or custom initialization scripts.
Step 3: Review Keybindings
At Typecraft, a modular setup ensures that each plugin’s keybindings are contained within its respective file. This keeps configurations organized and avoids clutter. However, you should still review keybindings to ensure:
- You actually use them: Remove bindings that aren’t helpful.
- They’re logically grouped: Maintain intuitive mappings for smoother workflows.
Example
Instead of mapping unnecessary commands, focus on essentials:
vim.keymap.set('n', 'ff', 'Telescope find_files', { desc = 'Find Files' })
vim.keymap.set('n', 'fg', 'Telescope live_grep', { desc = 'Live Grep' })
Step 4: Organize Configuration Files
With a file-per-plugin structure, modularity is already a strength of your setup. Ensure each plugin file contains:
Plugin-specific keybindings
Settings and configurations
Lazy loading conditions, if applicable.
This approach not only simplifies debugging but also makes it easier to share or adapt configurations.
Step 5: Embrace Minimalism
Focus on tools and settings that provide maximum impact with minimal complexity. Even with lazy.nvim
, aim for a configuration that aligns with your specific workflow rather than including every shiny feature.
Plugins Worth Considering
When curating your Neovim setup, focus on plugins that deliver high impact with minimal overhead. Here’s a breakdown of essential categories and carefully chosen plugins:
File Navigation
- Telescope.nvim: A versatile fuzzy finder that integrates with multiple sources (e.g., files, git, and LSP).
- fzf-lua: A faster alternative if you’re comfortable using Lua-based configurations and want better performance for large projects.
- Oil.nvim: A lightweight alternative to traditional file explorers like NERDTree, providing a streamlined interface for directory navigation.
Syntax Highlighting and Parsing
- nvim-treesitter: Leverages Treesitter for robust syntax highlighting and code parsing. Focus on enabling only the languages you actively use to minimize overhead.
- LiteSyntax.nvim: A more lightweight alternative if you don’t require the full power of Treesitter.
Version Control
- Gitsigns.nvim: Displays inline git changes, hunk previews, and staging directly in the editor.
- Fugitive.vim: A time-tested plugin for managing git operations inside Neovim.
- vim-signify: A lightweight option for inline git change indicators if you prefer minimal features.
- Lazygit: A powerful terminal-based Git client that provides an intuitive TUI for committing, branching, and resolving merge conflicts. You can integrate it into Neovim with plugins like lazygit.nvim.
Coding Assistance
- nvim-lspconfig: Simplifies the setup for built-in LSP, enabling code completion, diagnostics, and hover functionality.
- null-ls.nvim: Integrates with formatters and linters to complement your LSP setup.
- copilot.lua: A plugin to use GitHub Copilot with Neovim, ideal for AI-assisted coding, but disable when not needed for resource efficiency.
UI Enhancements
- Which-key.nvim: Displays keybinding hints in real-time, helping manage complex configurations.
- Lualine.nvim: A sleek, customizable status line that balances aesthetics and functionality.
- MinimalStatus.nvim: A super-lightweight alternative for users who prefer simplicity.
Utility Plugins
- Comment.nvim: Simplifies commenting across multiple languages with intuitive keybindings.
- Todo-comments.nvim: Highlights and organizes TODOs, FIXMEs, and other comments directly in your codebase.
- Toggleterm.nvim: Adds a versatile terminal emulator that integrates well with Neovim workflows.
Minimalism in Practice
When selecting plugins, focus on the ones that:
Solve a recurring problem in your workflow.
Introduce significant value without adding redundancy.
Integrate cleanly with your existing configuration.
By sticking to purpose-driven tools, you ensure that your setup remains lean, efficient, and enjoyable to use.
Final Thoughts
Debloating your Neovim configuration is an ongoing process, even with a tool like lazy.nvim
. Periodically revisit your setup to ensure it remains clean and aligned with your workflow. By auditing plugins, optimizing keybindings, and maintaining a modular structure, you can create a lean and efficient Neovim environment that enhances your productivity.