Skip to content

Neovim - AI-Enhanced Code Editor

A comprehensive Neovim setup based on AstroNvim v6 with extensive AI integration, database tools, and modern development features.

🎯 Overview

This Neovim configuration is built on AstroNvim v6, providing a modern, feature-rich development environment with:

  • AI Integration: Multiple AI assistants for coding help
  • Database Tools: Advanced SQL development with Snowflake support
  • LSP Support: Language servers for multiple programming languages
  • Modern UI: Beautiful interface with treesitter syntax highlighting
  • Project Management: Seamless integration with tmux sessionizer

Base Framework

  • AstroNvim v6: Modern Neovim distribution
  • Lazy.nvim: Fast plugin manager
  • Mason: LSP, formatter, and linter installer
  • Treesitter: Advanced syntax highlighting

✨ Key Features

🤖 AI-Powered Development

  • CodeCompanion: AI chat and inline assistance
  • Supermaven: Primary AI code completion (auto-triggers, Tab to accept)
  • Database AI: AI-powered SQL assistance
  • Streamlined AI System: Simplified, conflict-free AI completion

🗄️ Database Development

  • miu-db.nvim: Lightweight SQL buffer runner backed by miudb
  • Native miudb Store: Reuses saved miudb connections and secrets
  • SQL Completion: AI-powered SQL suggestions
  • Query Execution: Run queries directly from editor

🛠️ Development Tools

  • LSP Integration: Language servers for 20+ languages
  • Debugging: DAP integration for multiple languages
  • Testing: Integrated test runners
  • Git Integration: Advanced git workflows
  • File Management: Oil.nvim for file operations

🎨 UI & Experience

  • Custom Dashboard: Branded startup screen
  • Catppuccin Theme: Beautiful, consistent theming
  • Status Line: Rich status information
  • Notifications: Snacks.nvim for beautiful notifications

🚀 Installation & Setup

Prerequisites

Terminal window
# Install Neovim (latest stable)
brew install neovim
# Install required dependencies
brew install ripgrep fd fzf git

Configuration Installation

The configuration is automatically installed via the dotfiles setup:

Terminal window
# Via dotfiles installation
make stow-install
# Or manually symlink
ln -sf ~/.dotfiles/dotfiles/nvim/.config/nvim ~/.config/nvim

First Launch

  1. Open Neovim: nvim
  2. Plugin Installation: Plugins install automatically
  3. LSP Setup: Run :Mason to install language servers
  4. AI Setup: Configure API keys (see AI Tools section)

Post-Installation

Terminal window
# Install language servers
:Mason
# Update plugins
:Lazy sync
# Check health
:checkhealth

⌨️ Key Bindings

Leader Keys

  • Leader: <Space>
  • Local Leader: ,

Essential Shortcuts

ShortcutActionDescription
<C-f>Project SessionizerOpen tmux project picker
-File ManagerOpen Oil.nvim file manager
<leader>kPrevious BufferSwitch to last buffer
<leader>KNext TabGo to next tab

AI Assistance

ShortcutActionDescription
<leader>acAI ChatOpen CodeCompanion chat
<leader>aaAI ActionsShow AI action menu
<leader>atToggle ChatToggle AI chat window
<leader>aCAdd to ChatAdd selection to chat
<leader>aeExplain CodeAI code explanation
<leader>arReview CodeAI code review
<leader>afFix CodeAI code fixes
<leader>aoOptimize CodeAI optimization suggestions

AI Completion (Supermaven)

ShortcutActionDescription
<Tab>Accept/TabAccept suggestion or normal tab
<C-;>Accept FullAccept complete suggestion
<C-y>Accept AltAccept suggestion (alternative)
<C-'>Accept WordAccept next word
<C-]>Accept LineAccept current line
<C-[>PreviousPrevious suggestion
<C-\>NextNext suggestion
<C-BS>DismissDismiss current suggestion

Zen Mode & Focus

ShortcutActionDescription
<leader>zZen ModeEnter distraction-free mode (70% width)
<leader>ZFull Screen ZenEnter full-screen zen mode (100% width)
<leader>zxExit All ZenExit zen mode across all tmux panes
<leader>ttTwilightToggle twilight (dim inactive code)

Database Tools

ShortcutActionDescription
<leader>DdSelect ConnectionSelect a saved miudb connection
<leader>DlList ConnectionsShow saved miudb connections
<leader>DqExecute QueryRun current SQL buffer
<leader>jExecute QueryRun current SQL buffer

File Operations

ShortcutActionDescription
<leader>ffFind FilesTelescope file finder
<leader>fwFind WordSearch in files
<leader>fbFind BuffersOpen buffer list
<leader>fhFind HelpSearch help tags
<leader>frRecent FilesRecently opened files

LSP & Code

ShortcutActionDescription
gdGo to DefinitionJump to definition
grGo to ReferencesFind references
giGo to ImplementationJump to implementation
KHover DocumentationShow documentation
<leader>caCode ActionsShow code actions
<leader>crRename SymbolRename symbol
<leader>cfFormat CodeFormat current buffer

Git Integration

ShortcutActionDescription
<leader>ggLazygitOpen Lazygit TUI
<leader>gbGit BlameShow git blame
<leader>gdGit DiffShow git diff
<leader>gsGit StatusShow git status

🤖 AI Tools

CodeCompanion

Primary AI assistant for chat and inline help

Setup

  1. API Key: Set your OpenAI API key
    Terminal window
    export OPENAI_API_KEY="your-api-key"
  2. Configuration: See dotfiles/nvim/.config/nvim/docs/CODECOMPANION_USAGE.md

Features

  • Chat Interface: Full conversation with AI
  • Inline Assistance: AI suggestions in code
  • Code Actions: Context-aware AI actions
  • Multiple Models: Support for different AI models

Supermaven

Primary AI code completion (auto-triggers; copilot.vim is disabled)

Key Features

  • Smart Tab: Accepts suggestions when available, normal tab otherwise
  • Multiple Accept Options: Full suggestion, word, or line
  • Easy Navigation: Previous/next suggestions with bracket keys
  • Quick Dismiss: Ctrl+Backspace for natural dismiss motion

🗄️ Database Development

miu-db.nvim

Lightweight SQL buffer runner backed by the miudb CLI

Features

  • Connection Selection: Pick from saved miudb connections
  • Query Execution: Run SQL queries directly from Neovim
  • Result Viewing: Scratch split with tab-separated results
  • Secret Safety: Credentials stay in the miudb store

Setup

  1. Select Connection: <leader>Dd
  2. Open SQL File: edit any .sql buffer
  3. Run Buffer: <leader>j

Usage

-- Execute current buffer with <leader>j
SELECT * FROM my_table LIMIT 10;
-- Use completion for table names and columns
-- AI assistance for complex queries

Database AI

  • SQL Generation: AI-powered SQL query generation
  • Query Optimization: AI suggestions for query improvements
  • Schema Understanding: AI help with database schema

🔌 Plugin Management

Lazy.nvim

Modern plugin manager with lazy loading

Commands

Terminal window
:Lazy # Open plugin manager
:Lazy sync # Update all plugins
:Lazy install # Install missing plugins
:Lazy clean # Remove unused plugins
:Lazy profile # Profile startup time

Adding Plugins

  1. Create Plugin File: Add to dotfiles/nvim/.config/nvim/lua/plugins/
  2. Plugin Specification: Use Lazy.nvim format
  3. Reload: Restart Neovim or :Lazy reload

Mason

LSP, formatter, and linter installer

Commands

Terminal window
:Mason # Open Mason UI
:MasonInstall <tool> # Install specific tool
:MasonUpdate # Update all tools
:MasonLog # View installation logs

Installed Tools

  • Language Servers: lua_ls, pyright, tsserver, rust_analyzer, etc.
  • Formatters: prettier, stylua, black, rustfmt, etc.
  • Linters: eslint, flake8, shellcheck, etc.
  • Debuggers: debugpy, node-debug2, etc.

🎨 Customization

Adding Custom Keybindings

Edit dotfiles/nvim/.config/nvim/lua/plugins/astrocore.lua:

mappings = {
n = {
["<leader>custom"] = { ":echo 'Custom command'<cr>", desc = "Custom action" },
},
}

Custom Plugins

Create new file in dotfiles/nvim/.config/nvim/lua/plugins/:

-- custom-plugin.lua
return {
"author/plugin-name",
config = function()
require("plugin-name").setup({
-- configuration
})
end,
}

Theme Customization

Edit dotfiles/nvim/.config/nvim/lua/plugins/theme.lua:

-- Modify Catppuccin theme settings
opts = {
flavour = "mocha", -- latte, frappe, macchiato, mocha
-- custom colors and highlights
}

LSP Configuration

Edit dotfiles/nvim/.config/nvim/lua/plugins/astrolsp.lua:

-- Add custom LSP settings
config = {
servers = {
"new_language_server",
},
}

🔧 Troubleshooting

Common Issues

Plugins Not Loading

Terminal window
# Check plugin status
:Lazy
# Reinstall plugins
:Lazy clean
:Lazy sync
# Check for errors
:messages

LSP Not Working

Terminal window
# Check LSP status
:LspInfo
# Install language server
:Mason
# Restart LSP
:LspRestart

AI Tools Not Responding

Terminal window
# Check API keys
:echo $OPENAI_API_KEY
# Check network connectivity
# Verify API key validity
# Check plugin status
:Lazy

Database Connection Issues

Terminal window
# Check miudb from Neovim
:MiuDBConnections
# Verify connection details
# Check network connectivity to database

Performance Issues

Slow Startup

Terminal window
# Profile startup time
:Lazy profile
# Disable unnecessary plugins
# Optimize plugin loading

High Memory Usage

Terminal window
# Check memory usage
:lua print(vim.fn.system("ps aux | grep nvim"))
# Disable heavy plugins if needed
# Reduce treesitter parsers

Configuration Debugging

Check Health

Terminal window
:checkhealth # General health check
:checkhealth lazy # Plugin manager health
:checkhealth lsp # LSP health
:checkhealth treesitter # Treesitter health

View Configuration

Terminal window
:lua print(vim.inspect(require("lazy").plugins()))
:lua print(vim.inspect(vim.g))
:lua print(vim.inspect(vim.o))

📚 Advanced Features

Custom Commands

Terminal window
# Database helpers
:MiuDBConnections # List saved connections
:MiuDBSelectConnection # Select active connection
:MiuDBQuery # Run current SQL buffer
# AI commands
:CodeCompanion # Open AI chat
:CodeCompanionActions # Show AI actions

Automation

  • Auto-save: Automatic file saving (configurable)
  • Session Management: Integration with tmux sessions
  • Project Detection: Automatic project-specific settings

Integration

  • Tmux: Seamless tmux integration with sessionizer
  • Git: Advanced git workflows with Lazygit
  • Terminal: Integrated terminal with toggleterm
  • File Manager: Oil.nvim for file operations