Skip to main content

Neovim Configuration

Config-Sway includes a modern Neovim setup based on NvChad v2.5, providing a powerful IDE-like experience with LSP support, syntax highlighting, and efficient keybindings.

Configuration Structure

NvChad Framework

What is NvChad?

NvChad is a Neovim configuration framework that provides:
  • Pre-configured LSP (Language Server Protocol)
  • Modern UI with custom statusline
  • File explorer (NvimTree)
  • Fuzzy finder (Telescope)
  • Git integration
  • Syntax highlighting (Treesitter)

Initialization

~/.config/nvim/init.lua
Leader key: Set to Space

Plugin Management

  • Lazy loading improves startup time
  • NvChad v2.5 provides base functionality
  • Custom plugins loaded from lua/plugins/

Core Configuration

Editor Options

~/.config/nvim/init.lua
  • Line numbers: Absolute line numbers displayed
  • Relative numbers: Distance from current line (useful for motions like 5j)
With relative numbers, you can quickly jump 7 lines down with 7j or delete 3 lines up with d3k.

Additional Options

~/.config/nvim/lua/options.lua
This file extends NvChad’s default options. Uncomment lines to enable features.

Keybindings

Universal Exit: zx

~/.config/nvim/init.lua
Usage: Press zx in any mode to return to Normal mode.
This creates a consistent escape mechanism across all modes, as an alternative to Esc or Ctrl+C.

Split Navigation

~/.config/nvim/init.lua
  • Ctrl + H - Move to left split
  • Ctrl + L - Move to right split
NvChad provides Ctrl+J and Ctrl+K for vertical navigation by default.
~/.config/nvim/lua/mappings.lua

Custom Additions

  • ; in Normal mode - Enter command mode (alternative to :)
  • jk in Insert mode - Quick exit to Normal mode

Common NvChad Mappings

LSP Configuration

Language Server Setup

~/.config/nvim/lua/configs/lspconfig.lua
NvChad automatically configures common language servers. Install them with Mason: Open Mason: :Mason Install servers:

LSP Keybindings

Once LSP is active in a buffer:

Code Formatting

Conform.nvim

~/.config/nvim/lua/configs/conform.lua
Format on save or manually: Manual format: Space + fm Auto-format on save:

File Explorer (NvimTree)

Opening NvimTree

  • Ctrl + N - Toggle file explorer
  • Space + e - Focus file explorer

NvimTree Navigation

Fuzzy Finding (Telescope)

Search Commands

Quick Keybindings

  • Space + ff - Find files
  • Space + fw - Find word (live grep)
  • Space + fb - Find buffers
  • Space + fh - Find help
  • Space + fo - Find old files
  • Space + fz - Find in current buffer

Telescope Navigation

Syntax Highlighting (Treesitter)

NvChad includes Treesitter for advanced syntax highlighting and code understanding.

Installing Parsers

Install all maintained parsers:

Treesitter Features

  • Syntax highlighting - Context-aware colors
  • Code folding - Fold functions, classes, blocks
  • Incremental selection - Expand selection based on syntax tree
  • Indentation - Smart auto-indent

Customization

Edit ~/.config/nvim/lua/plugins/init.lua:
Restart Neovim to install new plugins.
NvChad includes multiple themes:List themes:
Or use keybinding: Space + thSet default theme:Edit ~/.config/nvim/lua/chadrc.lua:
Edit ~/.config/nvim/lua/autocmds.lua:

Useful Commands

NvChad Commands

Plugin Management

Mason (LSP/Tools)

Troubleshooting

Profile startup time:
Optimize plugin loading:
  • Ensure plugins are set to lazy = true where possible
  • Use event, ft, or cmd triggers for lazy loading
Example:
Check if LSP is attached:
Install language server:
Restart LSP:
Check logs:
Update parsers:
Reinstall specific parser:
Check health:
Sync plugins:
Clear cache:
Then restart Neovim.

Neovim Tips

Built-in tutor:
Practice with:
  • ciw - Change inner word
  • di" - Delete inside quotes
  • va{ - Select around curly braces
  • gg=G - Auto-indent entire file
  • :%s/old/new/g - Replace all occurrences
  • . - Repeat last change
  • * - Search for word under cursor
  • <C-o> - Jump to previous location
  • <C-i> - Jump to next location
  1. Press q + letter (e.g., qa for register ‘a’)
  2. Perform actions
  3. Press q to stop recording
  4. Play macro with @a
  5. Repeat with @@
Example: Record qa, type :s/foo/bar<CR>, press q, then @a to replay.

Kitty Terminal

Terminal emulator where Neovim runs

Sway Keybindings

Window manager shortcuts

Additional Resources

Press Space + ch in Neovim to open the NvChad cheatsheet with all keybindings.