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
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)
Additional Options
~/.config/nvim/lua/options.lua
Keybindings
Exit Mode Bindings (ZX)
Exit Mode Bindings (ZX)
Universal Exit: zx
~/.config/nvim/init.lua
zx in any mode to return to Normal mode.| Mode | zx Effect |
|---|---|
| Insert | Exit to Normal mode |
| Visual | Exit to Normal mode |
| Command | Cancel command |
| Terminal | Exit to Normal mode |
Window Navigation
Window Navigation
NvChad Default Keybindings
NvChad Default Keybindings
~/.config/nvim/lua/mappings.lua
Custom Additions
;in Normal mode - Enter command mode (alternative to:)jkin Insert mode - Quick exit to Normal mode
Common NvChad Mappings
| Key | Mode | Action |
|---|---|---|
Space + e | Normal | Toggle NvimTree file explorer |
Space + ff | Normal | Find files (Telescope) |
Space + fw | Normal | Find word in files (live grep) |
Space + fb | Normal | Find buffers |
Space + fh | Normal | Find help tags |
Space + th | Normal | Change theme |
Space + ch | Normal | NvChad cheatsheet |
Ctrl + n | Normal | Toggle file explorer |
Tab | Normal | Next buffer |
Shift + Tab | Normal | Previous buffer |
Space + x | Normal | Close buffer |
Menu Integration
Menu Integration
LSP Configuration
Language Server Setup
~/.config/nvim/lua/configs/lspconfig.lua
:Mason
Install servers:
LSP Keybindings
Once LSP is active in a buffer:| Key | Action |
|---|---|
gd | Go to definition |
gr | Go to references |
K | Hover documentation |
Space + ca | Code actions |
Space + rn | Rename symbol |
[d | Previous diagnostic |
]d | Next diagnostic |
Space + q | Show diagnostics list |
Code Formatting
Conform.nvim
~/.config/nvim/lua/configs/conform.lua
Space + fm
Auto-format on save:
File Explorer (NvimTree)
Opening NvimTree
Ctrl + N- Toggle file explorerSpace + e- Focus file explorer
NvimTree Navigation
| Key | Action |
|---|---|
Enter | Open file or folder |
o | Open file |
a | Create new file/folder |
d | Delete file/folder |
r | Rename |
x | Cut |
c | Copy |
p | Paste |
R | Refresh |
H | Toggle hidden files |
? | Show help |
Fuzzy Finding (Telescope)
Search Commands
Quick Keybindings
Space + ff- Find filesSpace + fw- Find word (live grep)Space + fb- Find buffersSpace + fh- Find helpSpace + fo- Find old filesSpace + fz- Find in current buffer
Telescope Navigation
| Key | Action |
|---|---|
Ctrl + J/K | Move up/down in results |
Ctrl + U/D | Scroll preview up/down |
Enter | Open file |
Ctrl + X | Open in horizontal split |
Ctrl + V | Open in vertical split |
Ctrl + T | Open in new tab |
Esc | Close Telescope |
Syntax Highlighting (Treesitter)
NvChad includes Treesitter for advanced syntax highlighting and code understanding.Installing 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
Adding Custom Plugins
Adding Custom Plugins
Edit Restart Neovim to install new plugins.
~/.config/nvim/lua/plugins/init.lua:Changing Theme
Changing Theme
NvChad includes multiple themes:List themes:Or use keybinding:
Space + thSet default theme:Edit ~/.config/nvim/lua/chadrc.lua:Custom Auto-commands
Custom Auto-commands
Edit
~/.config/nvim/lua/autocmds.lua:Useful Commands
NvChad Commands
Plugin Management
Mason (LSP/Tools)
Troubleshooting
Neovim slow to start
Neovim slow to start
Profile startup time:Optimize plugin loading:
- Ensure plugins are set to
lazy = truewhere possible - Use
event,ft, orcmdtriggers for lazy loading
LSP not working
LSP not working
Check if LSP is attached:Install language server:Restart LSP:Check logs:
Treesitter highlighting broken
Treesitter highlighting broken
Update parsers:Reinstall specific parser:Check health:
Plugins not loading
Plugins not loading
Sync plugins:Clear cache:Then restart Neovim.
Neovim Tips
Learning Vim motions
Learning Vim motions
Built-in tutor:Practice with:
vimtutor- Interactive tutorial- Vim Adventures - Game-based learning
- OpenVim - Interactive tutorial
Useful motions
Useful motions
ciw- Change inner worddi"- Delete inside quotesva{- Select around curly bracesgg=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
Macro recording
Macro recording
- Press
q+ letter (e.g.,qafor register ‘a’) - Perform actions
- Press
qto stop recording - Play macro with
@a - Repeat with
@@
qa, type :s/foo/bar<CR>, press q, then @a to replay.Related Configuration
Kitty Terminal
Terminal emulator where Neovim runs
Sway Keybindings
Window manager shortcuts
Additional Resources
- NvChad Documentation - Official NvChad docs
- Neovim Documentation - Neovim reference
- Lua Guide for Neovim - Learn Lua config
- Awesome Neovim - Plugin directory