# Neovim Configuration with LazyVim A comprehensive Neovim setup with LSP support, AI chat, database integration, and debugging. ## Prerequisites - Neovim >= 0.9.0 (installed via Homebrew) - Git - A Nerd Font (for icons) - Node.js (for some LSP servers and formatters) - Go (for gopls and delve) ## Installation 1. **Backup existing configuration** (if any): ```bash mv ~/.config/nvim ~/.config/nvim.bak mv ~/.local/share/nvim ~/.local/share/nvim.bak mv ~/.local/state/nvim ~/.local/state/nvim.bak mv ~/.cache/nvim ~/.cache/nvim.bak ``` 2. **Clone this configuration**: ```bash git clone ~/.config/nvim ``` 3. **Start Neovim**: ```bash nvim ``` Lazy.nvim will automatically install all plugins on first launch. 4. **Install LSP servers and tools**: After plugins load, run: ``` :Mason ``` All required tools should install automatically. ## Features ### Language Support (LSP + Treesitter) - Go, Lua, TypeScript, JavaScript, HTML, CSS, JSON, YAML, Markdown, SQL, Makefile ### AI Chat Integration Supports multiple providers via [avante.nvim](https://github.com/yetone/avante.nvim): - Anthropic Claude - OpenAI GPT - Google Gemini - And more Set your API keys as environment variables: ```bash export ANTHROPIC_API_KEY="your-key" export OPENAI_API_KEY="your-key" export GEMINI_API_KEY="your-key" ``` Switch providers: `:AvanteProvider claude|openai|gemini` ### Database Integration (vim-dadbod) - `:DBUIToggle` - Open database UI - `:DBUIAddConnection` - Add a new connection Connection string examples: ``` postgresql://user:pass@localhost:5432/dbname mysql://user:pass@localhost:3306/dbname sqlite:path/to/db.sqlite ``` ### Go Debugging (DAP + Delve) Full debugging support with breakpoints, stepping, variable inspection. ## Key Bindings ### Terminal | Key | Action | |-----|--------| | `th` | Open terminal (horizontal split) | | `tv` | Open terminal (vertical split) | | `` | Toggle floating terminal | | `` | Exit terminal mode | ### File Explorer (Snacks explorer) | Key | Action | |-----|--------| | `` | Toggle explorer | | `` or `` | Open file in vertical split | | `` or `` | Open file in horizontal split | | `e` | Focus explorer (LazyVim default) | ### AI Chat | Key | Action | |-----|--------| | `aa` | Ask AI (with selection in visual mode) | | `ac` | Open AI chat | | `at` | Toggle AI sidebar | ### Database | Key | Action | |-----|--------| | `db` | Toggle database UI | | `da` | Add database connection | ### Debugging | Key | Action | |-----|--------| | `db` | Toggle breakpoint | | `dB` | Breakpoint with condition | | `dc` | Continue | | `di` | Step into | | `do` | Step out | | `dO` | Step over | | `du` | Toggle DAP UI | | `dT` | Debug Go test | | `dt` | Terminate debug session | ### Formatting | Key | Action | |-----|--------| | `cf` | Format buffer | | `:FormatToggle` | Toggle auto-format on save | | `:FormatDisable` | Disable auto-format | | `:FormatEnable` | Enable auto-format | ### General | Key | Action | |-----|--------| | `` | Save file | | `` / `` | Previous/Next buffer | | `` | Navigate windows | | `` / `` | Move line down/up | ## File Structure ``` ~/.config/nvim/ ├── init.lua # Entry point ├── lua/ │ ├── config/ │ │ ├── lazy.lua # Lazy.nvim bootstrap & LazyVim setup │ │ ├── options.lua # General Neovim options │ │ ├── keymaps.lua # Custom key bindings │ │ └── autocmds.lua # Auto commands │ └── plugins/ │ ├── lsp.lua # LSP & Treesitter configuration │ ├── ai.lua # AI chat integration (avante.nvim) │ ├── dadbod.lua # Database integration │ ├── dap.lua # Debugging configuration │ ├── formatting.lua # Auto-formatting (conform.nvim) │ └── editor.lua # Editor enhancements (snacks explorer, etc.) ``` ## Formatters by File Type | File Type | Formatter | |-----------|-----------| | Go | gofumpt, goimports | | Lua | stylua | | JS/TS/JSX/TSX | prettier | | HTML/CSS | prettier | | JSON/YAML | prettier | | Markdown | prettier | | SQL | sql-formatter | ## Troubleshooting ### LSP not working Run `:LspInfo` to check status. Run `:Mason` to verify tools are installed. ### Formatting not working Run `:ConformInfo` to check formatter status. ### Icons not displaying Install a Nerd Font and configure your terminal to use it. ### Ctrl+Shift keybindings not working Some terminals don't properly send Ctrl+Shift combinations. Use the alternative mappings (`` and `` in snacks explorer).