A modern Neovim configuration focused on Python/Django development with extensive LSP integration, debugging capabilities, AI assistance, and efficient navigation features.
- Features
- Installation
- Configuration Structure
- Plugin Details and Usage Examples
- Common Workflows
- Python Development Examples
- Plugin Shortcuts Cheatsheet
- Customization
- Full Python Development Environment: LSP support via Pyright and Ruff, Django-specific configurations
- Comprehensive Debugging: Python/Django debugging with DAP and interactive UI
- Modern UI: Status line, Git integration, file explorer, and clean theme
- Intelligent Code Completion: Context-aware suggestions via nvim-cmp with various sources
- AI Code Assistant: Integration with Avante AI for code explanations, fixes, test generation, and intelligent code refactoring
- Database Integration: SQL query execution and database management via vim-dadbod
- REST Client: HTTP request testing with rest-nvim
- Session Management: Automatic session saving and restoration
Install this Neovim configuration with a single command:
bash <(curl -sSL https://raw.githubusercontent.com/iklobato/iklobato-nvim-config-python/main/install.sh)Or using git clone:
git clone --depth=1 https://github.com/iklobato/iklobato-nvim-config-python.git /tmp/nvim-config-install && bash /tmp/nvim-config-install/install.sh && rm -rf /tmp/nvim-config-installThe installation script will:
- Automatically detect your OS (macOS or Ubuntu/Debian)
- Install all required dependencies (Neovim 0.11.0+, Git, Node.js, Ripgrep, Python 3)
- Prompt you to backup existing Neovim config (if present)
- Clone the repository and install configuration files
- Set up the configuration directory
Supported OS: macOS (via Homebrew) and Ubuntu/Debian (via apt-get)
Note: Plugins will be automatically installed by lazy.nvim when you first launch Neovim. No manual plugin installation needed!
If you prefer to install manually:
-
Ensure you have the necessary dependencies:
- Neovim 0.11.0+ (https://github.com/neovim/neovim/releases) - Required for nvim-lspconfig compatibility
- Node.js and npm (for LSP servers)
- Git
- Ripgrep (for Telescope searching)
- Python 3 (for Pyright and Ruff LSP servers)
-
Clone this configuration to your Neovim config directory:
git clone https://github.com/iklobato/iklobato-nvim-config-python.git ~/.config/nvim -
Launch Neovim, and plugins will be automatically installed by lazy.nvim.
This configuration uses Nerd Fonts to display file icons in the file explorer, status line, and other UI elements.
Automatic Installation: The install script automatically installs Meslo LG Nerd Font on Ubuntu. However, you must configure your terminal to use it.
Manual Font Installation (Ubuntu):
# Create fonts directory
mkdir -p ~/.local/share/fonts
cd ~/.local/share/fonts
# Download Meslo LG Nerd Font
curl -L https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Meslo.zip -o Meslo.zip
unzip Meslo.zip
rm Meslo.zip
# Update font cache
fc-cache -fvConfigure Terminal:
- GNOME Terminal: Edit > Preferences > Text > Custom font > Select "MesloLGS Nerd Font"
- VS Code Terminal: Add to
settings.json:{ "terminal.integrated.fontFamily": "MesloLGS Nerd Font" } - Other terminals: Check terminal settings for font configuration
Verify Installation:
# Check if font is installed
fc-list | grep -i "meslo.*nerd"
# Restart terminal and Neovim after font changeTroubleshooting:
- If icons show as Chinese/Korean characters: Terminal font is not set to Nerd Font
- If icons show as boxes: Font cache needs refresh (
fc-cache -fv) - If no icons appear: Check that
nvim-web-deviconsplugin is loaded
init.lua: Main configuration entry point, loads core settings and plugins.lua/config/: Core Neovim settings and general configurations.options.lua: General editor options.keymaps.lua: Organized key mappings by functionality.autocmds.lua: Autocommands for various behaviors.
lua/plugins/: Plugin-specific configurations, organized into subdirectories by category.lua/plugins/completion/: Configuration for completion plugins (e.g.,nvim-cmp).lua/plugins/ui/: Configuration for UI-related plugins (e.g.,barbecue-nvim,lualine-nvim,nvim-tree).lua/plugins/utility/: Configuration for general utility plugins (e.g.,auto-session,nvim-autopairs).lua/plugins/git/: Configuration for Git integration plugins (e.g.,git-blame-nvim).lua/plugins/linter/: Configuration for linting plugins (e.g.,nvim-lintfor Terraform).lua/plugins/lsp/: Configuration for LSP-related plugins (e.g.,nvim-lspconfig,nvim-dap-ui).lua/plugins/syntax/: Configuration for syntax highlighting and parsing (e.g.,nvim-treesitter).lua/plugins/database/: Configuration for database interaction plugins (e.g.,nvim-sql).lua/plugins/formatter/: Configuration for code formatting plugins (e.g.,conform-nvim).lua/plugins/misc/: Miscellaneous plugin configurations.
lua/lsp/: Individual Language Server Protocol (LSP) client configurations.scripts/: Installation and utility scripts.ftplugin/: Filetype-specific settings.stylua.toml: Stylua formatter configuration for consistent Lua code formatting.db_ui/: Database UI configuration and runtime data.db_ui/connections.json.example: Template for database connections (copy toconnections.jsonand customize).
Note: For a complete list of keyboard shortcuts, see the Plugin Shortcuts Cheatsheet section.
This section provides an overview of the installed plugins, their purpose, and when to use them. For detailed keyboard shortcuts and quick reference, see the Plugin Shortcuts Cheatsheet.
The mini.surround plugin provides tools for working with pairs of characters (like quotes, parentheses, etc.). It allows you to quickly add, delete, or replace surrounding characters around text selections.
When to use:
- Wrapping text in quotes or brackets
- Changing quote types (single to double quotes)
- Removing surrounding characters
Key Usage Patterns:
sa{motion}{char}- Add surroundingsd{char}- Delete surroundingsr{target}{replacement}- Replace surrounding
See Plugin Shortcuts Cheatsheet for all shortcuts.
File explorer with custom icons and git integration. Provides a visual file tree for navigating your project structure.
Key Features:
- File and directory browsing with icons
- Git status indicators
- File operations (create, delete, rename)
- Bookmarks and navigation
When to use:
- Exploring project structure
- Quick file operations (create, delete, rename)
- Visual navigation of directories
See Plugin Shortcuts Cheatsheet for shortcuts.
Powerful fuzzy finder for files, text, and more. The primary tool for finding files, searching text, and navigating your codebase.
Key Features:
- Fuzzy file finding with live preview
- Text search across files (ripgrep integration)
- Buffer navigation
- Symbol and method finding
- Recent files
When to use:
- Finding files quickly
- Searching for text across the codebase
- Switching between open buffers
- Finding functions, classes, or methods
Tips:
- Press
<C-h>in Telescope to toggle hidden files - Use
!node_modules/to exclude directories from results - Use
*wildcards for pattern matching
See Plugin Shortcuts Cheatsheet for all shortcuts.
Advanced debugging with breakpoints, stepping, and variable inspection. Provides a full debugging experience for Python and Django applications.
Key Features:
- Breakpoint management
- Step debugging (into, over, out)
- Variable inspection
- Django-specific debug configurations
- Interactive REPL in debug context
When to use:
- Debugging Python code
- Debugging Django applications
- Inspecting variable values
- Testing code execution flow
Django-Specific Configurations:
- Debug Django server
- Debug Django tests
- Debug Django shell
- Debug custom management commands
See Plugin Shortcuts Cheatsheet for all shortcuts and Common Workflows for usage examples.
Automatic session management that remembers your workspace. Saves and restores your editor state (open files, window layouts, buffer states) automatically.
Key Features:
- Automatic session saving on exit
- Automatic session restoration on open
- Project-based sessions (by directory)
- Git branch awareness
When to use:
- Switching between multiple projects
- Resuming work after closing Neovim
- Maintaining context across work sessions
See Plugin Shortcuts Cheatsheet for shortcuts and Common Workflows for usage examples.
HTTP request testing tool integrated into Neovim. Allows you to write and execute HTTP requests directly in your editor.
Key Features:
- Execute GET, POST, PUT, DELETE requests
- JSON response formatting
- Request/response viewing in split windows
When to use:
- Testing API endpoints
- Debugging REST APIs
- Quick API exploration
Request Example:
# In a .rest or .http file:
GET https://api.example.com/users
Authorization: Bearer TOKEN
Content-Type: application/json
See Plugin Shortcuts Cheatsheet for all shortcuts and Common Workflows for usage examples.
Database client integration with Neovim for querying and viewing data. Provides a UI for browsing databases, tables, and executing SQL queries.
Key Features:
- Visual database browser
- SQL query execution
- Connection management
- Query result viewing
When to use:
- Browsing database structure
- Executing SQL queries
- Viewing table data
- Testing database queries
Configuration:
- Configure connections in
db_ui/connections.json(seedb_ui/connections.json.examplefor template) - Supports PostgreSQL, MySQL, SQLite, MongoDB, and more
See Plugin Shortcuts Cheatsheet for shortcuts and Common Workflows for usage examples.
Git blame information displayed inline in your editor. Shows author, date, and commit message for each line of code.
When to use:
- Understanding code history
- Finding who wrote specific code
- Reviewing commit information
See Plugin Shortcuts Cheatsheet for shortcuts.
Enhanced syntax highlighting and code navigation based on language grammars. Provides more accurate syntax highlighting and enables advanced code navigation features.
Key Features:
- Syntax highlighting based on language grammar
- Code folding based on structure
- Method/function navigation
- Symbol finding
When to use:
- Better syntax highlighting
- Navigating code structure
- Finding functions and methods
See Plugin Shortcuts Cheatsheet for shortcuts.
This workflow guides you through a typical Python/Django development session, leveraging LSP, debugging, and AI assistance. For detailed keyboard shortcuts, see the Plugin Shortcuts Cheatsheet.
-
Navigate your project:
- Find files quickly using Telescope (see Plugin Shortcuts Cheatsheet - File Navigation)
- Search for text across files using live grep
- Switch between open buffers
-
Code Navigation and Understanding:
- Jump to definitions and find references using LSP (see Plugin Shortcuts Cheatsheet - LSP & Diagnostics)
- View documentation for symbols under cursor
- Explain complex code blocks using Avante AI (see Plugin Shortcuts Cheatsheet - AI Assistant)
-
Fixing and Refactoring Code:
- View and navigate LSP diagnostics
- Apply code actions for quick fixes
- Format code automatically on save
- Use Avante AI to fix and generate tests (see Python Development Examples for detailed examples)
-
Debugging Django Applications:
- Set breakpoints and debug Django applications (see Plugin Shortcuts Cheatsheet - Debugging)
- Use Django-specific debug configurations (server, tests, shell)
- Inspect variables and step through code
- Use debug REPL for interactive testing
-
Leveraging AI Assistant (Avante AI):
- Use Avante AI for code explanations, fixes, and test generation
- Generate commit messages from staged changes
- Build context in chat for complex refactoring tasks
- Open your Django
views.pyfile. - Visually select a view function you want to refactor (e.g.,
Vto start visual mode, then move cursor). - Press
<leader>acto add the current buffer to Avante AI, then press<leader>aato show the sidebar. - In the Avante AI sidebar, type:
Help me refactor this view to use class-based views. - Review the suggested changes provided by Avante AI.
- Apply the suggestions directly using Avante AI's edit functionality.
- Open a Django model or view file containing ORM queries.
- Visually select the ORM query or a block of queries you want to optimize.
- Press
<leader>acto add the current buffer to Avante AI, then press<leader>aato show the sidebar. - Ask:
How can I optimize these database queries? Consider prefetch_related and select_related. - Avante AI will provide suggestions. Apply the optimizations to your code.
- When encountering an API issue (e.g., a 500 error), open the relevant code file.
- Visually select the code block suspected of causing the issue.
- Press
<leader>aeto edit the selected code with Avante AI, which will provide explanations and suggestions. - If the explanation helps identify the problem, you can use Avante AI's edit functionality to apply fixes.
- For deeper analysis, press
<leader>aato show the Avante AI sidebar and provide more context, e.g.,The API returns status 500 when I send this payload: { "data": "example" }. Avante AI can then offer more targeted debugging steps or solutions.
This section outlines how to interact with your databases directly from Neovim using vim-dadbod. For keyboard shortcuts, see Plugin Shortcuts Cheatsheet - Database & API.
-
Configure Database Connections:
- Edit
db_ui/connections.jsonto add your database connection details (e.g., PostgreSQL, MySQL, SQLite). - See
db_ui/connections.json.examplefor a template.
- Edit
-
Open the Database UI:
- Toggle the database UI to browse your databases
- Navigate through your configured connections, databases, and tables
- Expand a connection to see available tables and views
- Press
Enteron a table name to view its schema or browse its data
-
Write and Execute Custom Queries:
- Open a new SQL buffer from the database UI
- Write your SQL query in the buffer
- Execute queries (entire buffer or selected portion)
- View results in a new split window
- Ensure your Django database connection is configured in
db_ui/connections.json. - Press
<leader>dbto open the database UI. - Navigate to your Django database connection and expand it.
- Browse the
auth_usertable to see its columns and some data. - Press
son your Django connection to open a new SQL buffer. - Type the following query:
SELECT id, username, email FROM auth_user WHERE is_staff = TRUE;
- Place your cursor on any line of the query and press
<leader>dq. - The results (staff users) will be displayed in a new buffer.
This section details how to effectively use the integrated AI assistant (Avante AI) for various coding tasks. For keyboard shortcuts, see Plugin Shortcuts Cheatsheet - AI Assistant.
-
Basic AI Interactions (Normal/Visual Mode):
- Explain Code: Visually select code and get detailed explanations
- Fix Code: Get suggestions for fixing issues in selected code
- Generate Tests: Generate unit tests for selected code
- Toggle Chat: Open/close the interactive chat window
- Show Sidebar: Press
<leader>aato show the Avante AI sidebar
-
Advanced Chat Workflows:
- Start a new chat with selected code: Visually select code to begin a chat with context
- Add current selection to active chat: Build context by adding selections to ongoing chat
- Chat buffer commands: Send messages, close chat, stop requests, and extract code blocks
-
Using Avante AI Features: Avante AI provides powerful features for code assistance:
- Edit Selected Blocks: Visually select code and press
<leader>aeto edit with AI assistance - Add Files to Context: Press
<leader>acto add current buffer, or<leader>aBto add all buffers - New Ask: Press
<leader>anto start a new question - Select Model: Press
<leader>a?to choose different AI models - Chat History: Press
<leader>ahto access previous conversations - Stop Request: Press
<leader>aSto stop the current AI request
- Edit Selected Blocks: Visually select code and press
- Press
<leader>aato show the Avante AI sidebar. - Press
<leader>acto add the current buffer to the context. - Open another related file (e.g., a utility file or a model) and press
<leader>acagain to add it. - Now, type a complex request like:
Explain how these two files work together to handle user authentication. - Avante AI will provide a comprehensive analysis across both files, leveraging the context you provided.
- Visually select a code block you want reviewed.
- Press
<leader>aeto edit the selected code with AI assistance. - Or press
<leader>aato show the sidebar and ask:What potential edge cases am I missing in this error handling logic? - Avante AI will provide targeted feedback.
- You can iterate by adding more files with
<leader>acor asking follow-up questions.
This section explains how to use the integrated REST client (rest-nvim) for testing APIs. For keyboard shortcuts, see Plugin Shortcuts Cheatsheet - Database & API.
-
Create or Open a Request File:
- Create a new file with a
.httpor.restextension (e.g.,api_test.http) - Write your HTTP request in this file. For example:
GET https://jsonplaceholder.typicode.com/posts/1 ### POST https://jsonplaceholder.typicode.com/posts Content-Type: application/json { "title": "foo", "body": "bar", "userId": 1 } ### PUT https://jsonplaceholder.typicode.com/posts/1 Content-Type: application/json { "title": "updated title" } ### DELETE https://jsonplaceholder.typicode.com/posts/1
- Create a new file with a
-
Execute Requests:
- Place your cursor on the line of the request you want to execute.
- Press
<leader>rrto execute the request under the cursor. - Press
<leader>rpto preview the request before sending. - Press
<leader>rlto re-run the last request.
-
Environment Variables:
- Create a
.envfile in your project directory - Use variables with
{{VAR_NAME}}syntax - Example:
GET {{API_BASE_URL}}/users - Variables are automatically loaded from
.envfiles
- Create a
-
View Response:
- The API response will open in a horizontal split window below.
- Response includes HTTP headers and formatted JSON/XML body.
- Create a file named
test_api.http. - Add the following content:
GET https://api.github.com/users/octocat
- Place your cursor on the
GETline and press<leader>rr. - A horizontal split window will open below with the HTTP response from the GitHub API, showing details for the
octocatuser.
This section explains how automatic session management works and how to manually control sessions. For keyboard shortcuts, see Plugin Shortcuts Cheatsheet - Utilities.
-
Automatic Session Saving and Restoration:
- Sessions are automatically saved when you exit Neovim from a project directory
- Sessions are automatically restored when you reopen Neovim in the same project directory
- Includes open files, window layouts, and buffer states
- Particularly useful for maintaining context across different projects or work sessions
-
Manually Managing Sessions:
- Search and Load Sessions: View and load saved sessions using Telescope
- Delete a Session: Remove unwanted sessions
- Open Neovim in
~/projects/project_a. - Open several files, create some splits, and make some edits.
- Exit Neovim (
:wqor:q). The session forproject_ais automatically saved. - Open Neovim in
~/projects/project_b. - Work on
project_b, opening different files and layouts. - Now, you want to go back to
project_a. - Press
<leader>ss. - Select the session corresponding to
project_afrom the list. - Neovim will close
project_b's session and restoreproject_a's session, including all its open buffers and window layouts.
This section provides comprehensive step-by-step guides for debugging different types of Python code. For keyboard shortcuts, see Plugin Shortcuts Cheatsheet - Debugging.
Use Case: Debugging standalone Python files, scripts, or modules that aren't part of a Django project.
Example Script (calculate.py):
def calculate_total(items):
total = 0
for item in items: # Set breakpoint here
total += item.get('price', 0)
return total
if __name__ == '__main__':
items = [{'price': 10}, {'price': 20}, {'name': 'free'}]
result = calculate_total(items)
print(f"Total: {result}")Step-by-Step:
- Open the Python file:
<leader>ff, type filename - Set breakpoint: Place cursor on the line where you want to pause (e.g., line 3), press
<leader>bb(red dot appears) - Start debugging: Press
<leader>dc(Debug Control) - Select configuration: Choose "๐ PYTHON: Current File"
- When breakpoint hits:
- Inspect variables: Hover over
itemor press<leader>dion the variable - View all variables: Press
<leader>d?to see all variables in current scope - Step through code:
<leader>dj(Step Over) - Execute current line, don't enter functions<leader>dk(Step Into) - Enter function calls<leader>do(Step Out) - Exit current function
- Use REPL: Press
<leader>drto open Python REPL, test expressions:>>> item.get('price', 0) 10 >>> total 0
- Inspect variables: Hover over
- Continue execution: Press
<leader>dcto continue to next breakpoint or end - Terminate: Press
<leader>dtwhen done
Tips:
- Set multiple breakpoints in different functions
- Use conditional breakpoints:
<leader>bc, enter condition likelen(items) > 5 - Use logpoints:
<leader>bl, enter message likeItems: {items}, Total: {total}to log without stopping
Use Case: Debugging Django view functions, class-based views, or API endpoints.
Example View (views.py):
from django.http import JsonResponse
from .models import Product
def product_list(request):
category = request.GET.get('category') # Set breakpoint here
products = Product.objects.filter(category=category) if category else Product.objects.all()
data = [{'id': p.id, 'name': p.name} for p in products]
return JsonResponse(data, safe=False)Step-by-Step:
- Open the view file:
<leader>ff, navigate toviews.py - Set breakpoint: Place cursor on the line you want to debug, press
<leader>bb - Start Django server in debug mode: Press
<leader>dc, select "๐ DJANGO: Run Server" - Trigger the view:
- Use REST client: Create
.restfile, make GET request to the endpoint - Or use browser: Navigate to the URL
- Or use curl/Postman
- Use REST client: Create
- When breakpoint hits:
- Inspect request:
- Hover over
requestor press<leader>dionrequest - Check
request.GET: Use REPL (<leader>dr), typerequest.GET.get('category') - Check
request.POST: In REPL, typerequest.POST - Check
request.user: In REPL, typerequest.user.username
- Hover over
- Inspect queryset: In REPL, type
list(products.values('id', 'name')) - Step through logic: Use
<leader>djto step over,<leader>dkto step into - View call stack: Press
<leader>dfto see how you got to this view
- Inspect request:
- Continue or terminate: Press
<leader>dcto continue,<leader>dtto stop
Advanced:
- Debug class-based views: Set breakpoint in
get(),post(), or other methods - Debug middleware: Set breakpoint in middleware
process_request()method - Debug template context: Set breakpoint in view, inspect context variables before rendering
Use Case: Debugging model methods, properties, signals, or model validation.
Example Model (models.py):
from django.db import models
class Product(models.Model):
name = models.CharField(max_length=100)
price = models.DecimalField(max_digits=10, decimal_places=2)
def get_discounted_price(self, discount=0.1): # Set breakpoint here
return self.price * (1 - discount)
@property
def is_expensive(self): # Set breakpoint here
return self.price > 100Step-by-Step:
- Open the model file:
<leader>ff, navigate tomodels.py - Set breakpoint in model method: Place cursor in the method, press
<leader>bb - Start Django shell in debug mode: Press
<leader>dc, select "๐ฎ DJANGO: Shell Plus" - In the shell, create or retrieve a model instance:
>>> product = Product.objects.first() >>> product.get_discounted_price(0.2) # This will hit the breakpoint
- When breakpoint hits:
- Inspect
self: Press<leader>dionselfto see model instance - Check attributes: In REPL, type
self.name,self.price - Test method logic: In REPL, test calculations
- Inspect
- For property debugging: Access the property in shell, breakpoint will trigger
- Continue or terminate: Press
<leader>dcor<leader>dt
Debugging Signals:
- Set breakpoint in signal handler
- Start Django shell:
<leader>dcโ "๐ฎ DJANGO: Shell Plus" - Perform action that triggers signal (e.g.,
Product.objects.create(...)) - Breakpoint will hit in signal handler
Use Case: Debugging tests written with Django's test framework.
Example Test (test_models.py):
from django.test import TestCase
from .models import Product
class ProductModelTest(TestCase):
def setUp(self):
self.product = Product.objects.create(name="Test", price=50)
def test_get_discounted_price(self):
result = self.product.get_discounted_price(0.2) # Set breakpoint here
self.assertEqual(result, 40)Step-by-Step:
- Open the test file:
<leader>ff, navigate to test file - Set breakpoint: Place cursor in the test method, press
<leader>bb - Start debugging: Press
<leader>dc, select "๐งช DJANGO: Run Tests" - Enter test path:
- For specific test:
test_models.ProductModelTest.test_get_discounted_price - For all tests in file:
test_models - For all tests: Leave empty
- For specific test:
- When breakpoint hits:
- Inspect test data: Press
<leader>dionself.product - Check assertions: In REPL, test
self.product.get_discounted_price(0.2) - View test database: In REPL, type
Product.objects.all() - Step through test logic: Use
<leader>djor<leader>dk
- Inspect test data: Press
- Continue or terminate: Press
<leader>dcto continue,<leader>dtto stop
Rerunning Last Test:
- Press
<leader>dlto rerun the last debugged test command - Or use "โฎ๏ธ DJANGO: Rerun Last Command" from
<leader>dc
Use Case: Debugging tests written with pytest.
Example Test (test_calculations.py):
import pytest
from myapp.calculations import calculate_total
def test_calculate_total():
items = [{'price': 10}, {'price': 20}]
result = calculate_total(items) # Set breakpoint here
assert result == 30Step-by-Step:
- Open the test file:
<leader>ff, navigate to pytest test file - Set breakpoint: Place cursor in test function, press
<leader>bb - Start debugging: Press
<leader>dc, select one of:- "๐ฏ PYTEST: Run All Tests" - Run all pytest tests
- "๐ PYTEST: Current File" - Run tests in current file
- "๐ ๏ธ PYTEST: Custom Path/Args" - Run specific test with custom arguments
- If using custom path:
- Enter test path:
test_calculations.py::test_calculate_total - Enter extra args (optional):
-v -k "test_calculate"
- Enter test path:
- When breakpoint hits:
- Inspect test data: Press
<leader>dion variables - Test assertions: In REPL, verify expected values
- Step through: Use
<leader>djor<leader>dk
- Inspect test data: Press
- Continue or terminate: Press
<leader>dcor<leader>dt
Pytest-Specific Tips:
- Use "๐ ๏ธ PYTEST: Custom Path/Args" for pytest-specific flags like
-k,-m,-x - Debug fixtures: Set breakpoint in fixture function
- Debug parametrized tests: Breakpoint will hit for each parameter combination
Use Case: Debugging custom Django management commands.
Example Command (management/commands/import_data.py):
from django.core.management.base import BaseCommand
class Command(BaseCommand):
def handle(self, *args, **options):
filename = options['file'] # Set breakpoint here
data = self.load_data(filename)
self.process_data(data)
def load_data(self, filename):
# Set breakpoint here
with open(filename) as f:
return json.load(f)Step-by-Step:
- Open the management command file:
<leader>ff, navigate to command file - Set breakpoint: Place cursor in
handle()method or other methods, press<leader>bb - Start debugging: Press
<leader>dc, select "โ๏ธ DJANGO: Custom Command" - Enter command: Type the management command name and arguments:
- Example:
import_data --file data.json - Example:
migrate - Example:
createsuperuser
- Example:
- When breakpoint hits:
- Inspect options: Press
<leader>dionoptionsto see command arguments - Check args: In REPL, type
argsto see positional arguments - Step through command logic: Use
<leader>djor<leader>dk - Test data processing: In REPL, test functions with sample data
- Inspect options: Press
- Continue or terminate: Press
<leader>dcor<leader>dt
Rerunning Commands:
- After running a command, use "โฎ๏ธ DJANGO: Rerun Last Command" to quickly rerun it
- The last command is stored automatically
Use Case: Interactive debugging and testing in Django shell context.
Step-by-Step:
- Start Django shell in debug mode: Press
<leader>dc, select "๐ฎ DJANGO: Shell Plus" - Shell opens with debugger attached
- Set breakpoints in any file: Open file, place cursor, press
<leader>bb - Execute code in shell that triggers breakpoint:
>>> from myapp.models import Product >>> product = Product.objects.first() >>> product.get_discounted_price(0.2) # If breakpoint in method
- When breakpoint hits:
- Inspect variables: Use
<leader>dior REPL - Test expressions: Use REPL (
<leader>dr) to test code - Step through: Use
<leader>dj,<leader>dk,<leader>do
- Inspect variables: Use
- Continue or terminate: Press
<leader>dcor<leader>dt
Tips:
- Use shell plus for better experience (includes IPython if available)
- Test ORM queries before using in views
- Debug model methods interactively
Use Case: Debugging Django REST Framework views, serializers, or API endpoints.
Example API View (views.py):
from rest_framework.decorators import api_view
from rest_framework.response import Response
from .serializers import ProductSerializer
@api_view(['GET', 'POST'])
def product_list(request):
if request.method == 'POST':
serializer = ProductSerializer(data=request.data) # Set breakpoint here
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=201)
else:
products = Product.objects.all()
serializer = ProductSerializer(products, many=True)
return Response(serializer.data)Step-by-Step:
- Open the API view file:
<leader>ff, navigate to view file - Set breakpoint: Place cursor in view function, press
<leader>bb - Start debug server: Press
<leader>dc, select "๐ DJANGO: Run Server" - Make API request:
- Using REST client: Create
.restfile:Place cursor onPOST http://localhost:8000/api/products/ Content-Type: application/json { "name": "New Product", "price": 99.99 }
POSTline, press<leader>rg - Or use external tool: Postman, curl, or browser
- Using REST client: Create
- When breakpoint hits:
- Inspect request data:
- Press
<leader>dionrequest.datato see POST/PUT data - In REPL (
<leader>dr), typerequest.datato see full payload
- Press
- Check query params: In REPL, type
request.query_params - Inspect serializer: Press
<leader>dionserializer - Check validation errors: In REPL, type
serializer.errorsif invalid - Step through logic: Use
<leader>djor<leader>dk
- Inspect request data:
- View response: Continue execution (
<leader>dc), check REST client output - Terminate: Press
<leader>dtwhen done
Debugging Serializers:
- Set breakpoint in serializer's
validate()orcreate()method - Make API request that triggers serializer
- Breakpoint will hit in serializer method
Conditional Breakpoints:
- Place cursor where you want breakpoint
- Press
<leader>bc(Conditional Breakpoint) - Enter condition:
user.is_staff == Truelen(items) > 10price > 100 and category == 'electronics'
- Breakpoint only triggers when condition is true
Logpoints (Log Without Stopping):
- Place cursor where you want logging
- Press
<leader>bl(Logpoint) - Enter log message with variable placeholders:
User: {user.username}, Count: {count}Processing item {item.id}: {item.name}
- Values are logged to console without stopping execution
Using the Debug REPL:
- When breakpoint hits, press
<leader>drto open REPL - Test expressions in current context:
>>> user.email '[email protected]' >>> Product.objects.filter(price__gte=100).count() 5 >>> calculate_discount(100, 0.2) 80.0
- Modify variables (if mutable):
>>> items.append({'price': 30})
- Test function calls before using in code
Variable Inspection:
- Hover: Hover over variable to see value and type
- Detailed info: Press
<leader>dion variable for full details - All scopes: Press
<leader>d?to see all variables in current scope - Call stack: Press
<leader>dfto see function call hierarchy
Debug UI Panels: When debugging starts, DAP UI automatically opens with:
- Left Panel: Scopes, Stacks, Watches, Breakpoints
- Right Panel: REPL and Console
- Navigate panels: Use mouse or arrow keys
- Close UI: Press
qin panel or<leader>dtto terminate
Troubleshooting:
- Breakpoint not hitting:
- Verify file is saved
- Check you're using correct debug configuration
- Ensure code path is actually executed
- Variables not showing:
- Use REPL to verify variable exists
- Check variable is in current scope
- Debugger not starting:
- Verify
debugpyis installed:pip install debugpy - Check virtual environment is detected correctly
- Verify Python path in debug configuration
- Verify
This section provides practical, step-by-step examples for common Python development tasks. These examples are designed for Python developers working with Django, Flask, or pure Python projects.
Note: Keyboard shortcuts are included in examples for context. For a complete reference, see the Plugin Shortcuts Cheatsheet.
- Open a new file:
<leader>ff(Telescope Find Files), then type the new filename (e.g.,utils.py) - Start writing a function:
def calculate_total(items): return sum(item.price for item in items)
- Add type hints: Place cursor on
itemsparameter, press<leader>gg(hover) to see type suggestions, then add:from typing import List def calculate_total(items: List[dict]) -> float: return sum(item['price'] for item in items)
- Format the file:
<leader>f(auto-formats on save, or manually format) - Check for errors:
<leader>eto see any diagnostics
- Open your Python file (e.g.,
main.py) - Open terminal:
<leader>tt - Run the script:
python main.pyorpython3 main.py - Exit terminal mode:
<Esc>
- Open a Python file with import issues
- View diagnostics:
<leader>eor[d/]dto navigate errors - Fix missing imports: Place cursor on the undefined symbol, press
<leader>ga(Code Actions) - Select "Import [module]" from the code actions menu
- The import will be automatically added at the top of the file
- Find a function in current file:
<leader>fo(Find symbols in document) - Find a function across project:
<leader>fg(Live grep), typedef function_name - Find a class:
<leader>fg, typeclass ClassName - Find methods in current file:
<leader>fm(Find methods)
- Open your test file (e.g.,
test_models.py) - Navigate to the test function you want to run
- Set a breakpoint (optional): Place cursor on line, press
<leader>bb - Open terminal:
<leader>tt - Run the specific test:
pytest test_models.py::TestUserModel::test_create_user -v - Or run all tests in file:
pytest test_models.py -v
- Open the test file with the failing test
- Set a breakpoint at the start of the test: Place cursor, press
<leader>bb - Start debugging:
<leader>dc(Debug Control) - Select "๐งช PYTEST: Run Current Test" or "๐งช DJANGO: Run Tests"
- When breakpoint hits:
- Inspect variables: Place cursor on variable, press
<leader>di(Variable Info) - Step through code:
<leader>dj(Step Over),<leader>dk(Step Into) - View call stack:
<leader>df(List Frames) - Use REPL:
<leader>dr(Toggle REPL) to test expressions
- Inspect variables: Place cursor on variable, press
- Continue execution:
<leader>dc - Terminate when done:
<leader>dt
- Open the Python file with the function you want to test
- Visually select the function (e.g.,
Vto start visual mode, then}to select function) - Press
<leader>aeto edit with Avante AI and ask to generate tests, or press<leader>aato show sidebar and ask - Review the generated test code
- Apply the suggestions directly using Avante AI's edit functionality
- Create or open test file:
<leader>ff, typetest_*.py - Paste and save the test
- Open terminal:
<leader>tt - Run with coverage:
pytest --cov=. --cov-report=html - View coverage report: Open
htmlcov/index.htmlin browser, or use<leader>ffto find the file
- Open a Python file with linting issues
- View all diagnostics:
<leader>q(List all diagnostics) - Navigate to errors:
[d(Previous),]d(Next) - Auto-fix issues: Place cursor on error, press
<leader>ga(Code Actions) - Select "Fix all auto-fixable problems" if available
- Or format file:
<leader>f(Ruff will auto-format on save)
- Format current file:
<leader>f(formats on save automatically) - Format selected code: Visual select code, then
<leader>f - Check formatting: View diagnostics with
<leader>e- Ruff will show formatting issues
- Open file with type errors (shown with diagnostic icons)
- View type error: Place cursor on error, press
<leader>e(Show diagnostic) - Get suggestions: Press
<leader>ga(Code Actions) for quick fixes - Add type hints: Use hover (
<leader>gg) to see expected types, then add annotations - Example fix:
# Before (error) def process(data): return data.upper() # After (fixed) def process(data: str) -> str: return data.upper()
Automatic Import Resolution (Recommended):
- Place cursor on undefined symbol (e.g.,
Accountordatetime) - Press
<leader>ai(Auto-import) - If multiple import options exist: A picker menu will appear showing all possible imports
- Use arrow keys or
<C-j>/<C-k>to navigate - Press
<Enter>to select the desired import - Press
<Esc>to cancel
- Use arrow keys or
- If only one option: The import is added automatically
- The import statement is inserted at the top of the file
Using Code Actions (Alternative):
- Use undefined symbol (e.g.,
datetime) - View error:
<leader>eshows "undefined name 'datetime'" - Quick fix: Press
<leader>ga(Code Actions) - If multiple import options: A code action menu appears with all import options
- Type the number of the desired import and press
<Enter> - Or click with mouse
- Type the number of the desired import and press
- Select "Import datetime" - import is added automatically
Manual Import:
- Type
from datetime import datetime, use completion (<C-Space>) for suggestions
Choosing Between Multiple Import Options:
When multiple import paths exist (e.g., Account model in multiple Django apps):
- Method 1 (Auto-import):
<leader>aishows a picker menu - select the desired import path - Method 2 (Code Actions):
<leader>gashows numbered options - type the number to select - Method 3 (Manual): Use
<leader>gdto go to definition first, see the file path, then add import manually
Note: When using uv run nvim ., the configuration automatically detects:
uvvirtual environment and configures Pyright to use it- Django project structure and adds app paths to
extraPaths - This enables better import resolution and code actions for Django models
- Select the code block to extract (Visual mode:
Vthen move cursor) - Press
<leader>aato show Avante AI sidebar - Ask: "Extract this code into a function named
calculate_discountwith parameters for price and discount_rate" - Review suggested function and apply using Avante AI's edit functionality
- Create the function, replace original code with function call
- Place cursor on function name
- Rename:
<leader>lr(Rename symbol) - Type new name, press Enter
- Pyright will show preview of all occurrences
- Confirm rename - all references across the project are updated
- Select the code to move (Visual mode)
- Cut:
d(delete/cut in visual mode) - Create new file:
<leader>ff, type new filename (e.g.,helpers.py) - Paste:
p - Add imports if needed: Use
<leader>gato fix import errors - Update original file: Add import statement for the moved code
- Place cursor on function definition
- Get suggestions:
<leader>gg(Hover) to see function usage - Press
<leader>aato show Avante AI sidebar - Ask: "Improve this function signature with better type hints and parameter names"
- Apply suggestions from Avante AI
- Open or create
models.pyin your Django app - Write model definition:
class Product(models.Model): name = models.CharField(max_length=100) price = models.DecimalField(max_digits=10, decimal_places=2)
- Get field suggestions: Type
models.and use completion (<C-Space>) - Check for errors:
<leader>eto see any model issues - Generate migration: Open terminal (
<leader>tt), runpython manage.py makemigrations - Apply migration:
python manage.py migrate
- Open terminal:
<leader>tt - Create migrations:
python manage.py makemigrations - Debug migration (if issues): Set breakpoint in migration file, use
<leader>dcโ "โ๏ธ DJANGO: Custom Command" โ typemigrate - Or run normally:
python manage.py migrate
- Open your view file (e.g.,
views.py) - Find the view function:
<leader>fo(Find symbols) or<leader>fm(Find methods) - Set breakpoint in view: Place cursor, press
<leader>bb - Start Django server in debug mode:
<leader>dcโ "๐ DJANGO: Run Server" - Make request to trigger view (use REST client or browser)
- When breakpoint hits:
- Inspect
requestobject:<leader>dionrequest - Check
request.POSTorrequest.GET: Use REPL (<leader>dr) - Step through view logic
- Inspect
- Continue or terminate:
<leader>dcor<leader>dt
- Open
admin.pyin your app - Register model: Use completion for
admin.site.registerfrom django.contrib import admin from .models import Product @admin.register(Product) class ProductAdmin(admin.ModelAdmin): list_display = ['name', 'price']
- Check for errors:
<leader>e - Test admin: Start server (
<leader>dcโ "๐ DJANGO: Run Server"), visit/admin
- Open a view or management command file
- Write ORM query:
products = Product.objects.filter(price__gte=100).select_related('category')
- Optimize query: Select query, press
<leader>ac, ask "Optimize this Django ORM query" - Check query in database: Use
<leader>dbto open database UI, write equivalent SQL - Test query performance: Use Django shell (
<leader>dcโ "๐ฎ DJANGO: Shell Plus")
- Create or open
views.pyorviewsets.py - Write endpoint:
from rest_framework.decorators import api_view from rest_framework.response import Response @api_view(['GET']) def product_list(request): products = Product.objects.all() return Response([{'id': p.id, 'name': p.name} for p in products])
- Add type hints: Use
<leader>ggfor suggestions - Format:
<leader>f - Check for errors:
<leader>e
- Create test file:
<leader>ff, createapi_tests.rest - Write API request:
GET http://localhost:8000/api/products/ Content-Type: application/json
- Execute request: Place cursor on
GETline, press<leader>rg - View response: Opens in
_OUTPUT.jsonbuffer - Format JSON response:
<leader>xjif needed - Debug if error: Set breakpoint in view, restart server with debugger
- Set breakpoint in API view:
<leader>bb - Start debug server:
<leader>dcโ "๐ DJANGO: Run Server" - Make API request: Use REST client (
<leader>rg) or external tool - When breakpoint hits:
- Inspect request data:
<leader>dionrequest.data - Check query params: Use REPL (
<leader>dr), typerequest.query_params - Step through response generation
- Inspect request data:
- View response: Continue execution, check REST client output
- Receive JSON in API: Response opens in
_OUTPUT.json - Format JSON:
<leader>xj(Format as JSON) - Copy JSON structure: Select JSON, use for creating serializers
- Create serializer: Open
serializers.py, use JSON structure as reference - Validate: Press
<leader>aato show Avante AI sidebar and ask "Create a DRF serializer for this JSON structure"
This section provides comprehensive workflows for navigating files, paths, and code locations throughout your project using all available tools.
Primary Navigation Tools:
- Telescope - Fuzzy file finder and text search
- nvim-tree - Visual file explorer
- LSP Navigation - Jump to definitions, references, implementations
- Buffer Navigation - Switch between open files
- DAP Navigation - Debug-time path and frame navigation
- Quickfix Lists - Navigate search results and diagnostics
Scenario: You need to open a specific file but don't remember its exact location.
Workflow:
- Press
<leader>ffto open Telescope file finder - Start typing the filename (fuzzy matching works)
- Use
<C-j>/<C-k>to navigate results - Preview shows full file path
- Press
<Enter>to open, or:<C-t>to open in new tab<C-v>to open in vertical split<C-x>to open in horizontal split
Alternative: Use <leader>fr to browse recently opened files with paths.
Scenario: You want to see all places where a function is called across the codebase.
Workflow:
- Place cursor on the function name
- Press
<leader>gr(Find references) - Telescope shows all file locations with line numbers
- Navigate with
<C-j>/<C-k> - Preview shows code context at each location
- Press
<Enter>to jump to that file and line
Example: Finding Django view usage
Cursor on: def my_view(request):
Press: <leader>gr
Result: Shows all urls.py files and templates that reference this view
Scenario: You want to understand the project layout or navigate directories.
Workflow:
- Press
<leader>eeto open nvim-tree file explorer - Use
j/kto navigate up/down - Press
oor<Enter>to:- Expand/collapse directories
- Open files
- Press
<leader>efto reveal current file in explorer - Press
cto copy file path,wto copy filename - Press
?to see all available commands
Tips:
- The explorer shows git status indicators
- Use
Rto refresh if files change externally - Press
qto close explorer
Scenario: You need to find where a specific string or pattern appears.
Workflow:
- Press
<leader>fgto open live grep - Type your search term
- Results show:
- File paths
- Line numbers
- Matching line content
- Navigate with
<C-j>/<C-k> - Press
<Enter>to jump to location - Use
<leader>qoto open quickfix list for all results - Navigate quickfix with
<leader>qn(next) /<leader>qp(previous)
Example: Finding all Django model usages
Press: <leader>fg
Type: class User(AbstractUser)
Result: Shows all files importing or referencing User model
Scenario: You want to understand code structure by jumping between definitions.
Workflow:
- Go to definition: Place cursor on symbol, press
<leader>gd - Go to declaration: Press
<leader>gD - Find implementations: Press
<leader>gi - Find type definition: Press
<leader>gt - View hover info: Press
<leader>ggto see type/definition without jumping - Return: Use
<C-o>(jump back) or<C-i>(jump forward)
Example: Understanding Django model relationships
1. Cursor on: ForeignKey(User)
2. Press: <leader>gd โ jumps to User model definition
3. Press: <leader>gr โ shows all ForeignKey references to User
4. Press: <C-o> โ returns to original location
Scenario: You have multiple files open and need to switch quickly.
Workflow:
- Press
<leader>fbto open buffer picker - See all open files with preview
- Navigate with
<C-j>/<C-k> - Press
<Enter>to switch to buffer - Or use
<leader>bn(next) /<leader>bp(previous) for quick cycling - Press
<leader>bdto close current buffer
Tip: Buffer picker shows file paths, making it easy to identify files.
Scenario: You're in a large file and need to find a specific function or class.
Workflow:
- Press
<leader>foto find symbols in current document (LSP) - Or press
<leader>fmto find methods (Treesitter) - Filter by typing symbol name
- Navigate with
<C-j>/<C-k> - Press
<Enter>to jump to that symbol - Use
]m/[mto jump between methods in file
Example: Navigating Django views.py
Press: <leader>fo
Type: class
Result: Shows all class-based views in file
Press: <Enter> on a view โ jumps to that class
Scenario: You want to reopen a file you worked on recently.
Workflow:
- Press
<leader>frto open recent files - See list of recently opened files with full paths
- Navigate with
<C-j>/<C-k> - Preview shows file content
- Press
<Enter>to reopen
Use Case: Quickly returning to files you were editing earlier in your session.
Scenario: You're debugging and need to navigate the call stack and file locations.
Workflow:
- Set breakpoint:
<leader>bbon a line - Start debugging:
<leader>dc - View call stack: Press
<leader>dfto see frames with file paths - Navigate frames: In Telescope, select a frame to jump to that location
- View scopes: Press
<leader>d?to see variable scopes with locations - Step through:
<leader>dj- Step over (stay in current file)<leader>dk- Step into (may jump to other files)<leader>do- Step out (return to caller)
- Inspect variables: Press
<leader>dion a variable to see its value
Example: Debugging Django view
1. Set breakpoint in views.py: <leader>bb
2. Start debug: <leader>dc
3. View call stack: <leader>df
โ Shows: views.py โ urls.py โ middleware.py
4. Select urls.py frame โ jumps to URL configuration
5. Step back: <leader>do โ returns to views.py
Scenario: You've searched for something or have diagnostics and want to navigate through results.
Workflow:
- After grep/search: Press
<leader>qoto open quickfix list - View diagnostics: Press
<leader>qto see all LSP diagnostics - Navigate results:
<leader>qn- Next item (jumps to next file/location)<leader>qp- Previous item<leader>qf- First item<leader>ql- Last item
- Each navigation jumps to the file and line
- Press
<leader>qcto close quickfix
Use Case: Fixing multiple linting errors or reviewing search results systematically.
Scenario: You're editing a file and want to see where it is in the project structure.
Workflow:
- While editing any file, press
<leader>ef - nvim-tree opens and highlights the current file
- You can see:
- Full directory structure
- File location in project
- Sibling files and directories
- Navigate from there using tree commands
Tip: Useful when you're deep in a file and lose context of project structure.
Scenario: You need to review code across multiple files systematically.
Workflow:
- Find files to review:
<leader>ff, select files with<C-t>(opens in tabs) - Or use
<leader>fbto see all open buffers - Navigate tabs:
<leader>tn(next) /<leader>tb(previous) - In each file:
- Check diagnostics:
<leader>q - Find symbols:
<leader>fo - Find references:
<leader>gron key functions
- Check diagnostics:
- Compare files:
<leader>sv(vertical split) to view side-by-side - Search across:
<leader>fgto find patterns
Path Awareness:
- Telescope always shows full paths in preview
- nvim-tree shows relative paths from project root
- LSP navigation shows file paths in Telescope results
- DAP frames show file paths in call stack
Efficient Navigation Patterns:
- Quick file access:
<leader>fffor fuzzy finding - Code understanding:
<leader>gdโ<leader>grโ<leader>fo - Project exploration:
<leader>eeโ navigate tree โ<leader>efto reveal - Debug navigation:
<leader>bbโ<leader>dcโ<leader>dffor stack
Keyboard Shortcuts Summary:
- File finding:
<leader>ff,<leader>fr,<leader>fb - Code navigation:
<leader>gd,<leader>gr,<leader>gi,<leader>fo - Explorer:
<leader>ee,<leader>ef,<leader>er - Debug:
<leader>df,<leader>dh,<leader>di - Results:
<leader>qo,<leader>qn,<leader>qp
Working Directory:
- Your config automatically tracks the current working directory
- Telescope searches are relative to current directory
- Directory changes trigger auto-session updates
- nvim-tree reflects current directory structure
- Jump to error:
]d(next diagnostic) or[d(previous) to quickly navigate errors - Fix all auto-fixable:
<leader>gathen select "Fix all" when available - Format on save: Enabled by default - just save with
<leader>ww - Quick file switch:
<leader>fb(Find buffers) to switch between open Python files - Split and compare:
<leader>sv(vertical split) to compare two files side-by-side
- The debugger automatically detects virtual environments (
.venv,venv,env) - For Poetry projects: Automatically uses
poetry env - For pipenv: Uses
$VIRTUAL_ENVif activated - Check Python path: In debugger config, it auto-detects the correct interpreter
Type Hints Workflow:
- Write function without types
- Let Pyright infer types (hover with
<leader>gg) - Add type hints based on suggestions
- Fix type errors as they appear
Import Management:
- Use undefined symbol โ
<leader>aiโ Auto-import (recommended, uses LSP) - Or use code actions:
<leader>gaโ Select import action - Organize imports: Ruff auto-organizes on format
- Remove unused: Ruff flags unused imports,
<leader>gato remove
Automatic Project Detection:
- When using
uv run nvim ., the configuration automatically:- Detects
uvvirtual environment and configures Pyright - Detects Django projects and adds app paths to
extraPaths - Sets
PYTHONPATHcorrectly for import resolution - Enables import code actions for Django models
- Detects
Error Handling:
- Write code that might raise exception
- Pyright shows potential issues
- Use Avante AI: Select code, press
<leader>ae(Edit selected blocks) for error handling suggestions
- Conditional breakpoints:
<leader>bcto set breakpoint that only triggers on condition - Log points:
<leader>blto log variable values without stopping - REPL for testing:
<leader>dropens Python REPL in debug context - test expressions live - Variable inspection:
<leader>dion any variable to see its value and type
- Open file to review
- Check for issues:
<leader>q(List all diagnostics) - Explain complex code: Select code,
<leader>ae(Explain) - Suggest improvements: Select code,
<leader>ac, ask "Review this code and suggest improvements" - Generate tests: Select function,
<leader>at(Generate tests)
- Create a new file in the appropriate subdirectory under
lua/plugins/(e.g.,lua/plugins/completion/my-new-plugin.lua). - Use this structure:
return {
'author/plugin-name',
dependencies = { -- optional
'dependency1',
'dependency2',
},
config = function()
-- Configuration code here
end
}Edit lua/plugins/ui/colorscheme.lua and uncomment your preferred theme configuration.
Edit lua/config/keymaps.lua - organized by functionality sections for easy navigation.
This repository includes scripts to export and import Homebrew packages for environment reproducibility.
To export all installed Homebrew packages to a Brewfile:
./scripts/brew-export.shOptions:
--file FILE- Specify custom output file (default:Brewfile)--include-mas- Include Mac App Store apps (requiresmas-cli)--help- Show usage information
The script exports:
- All installed Homebrew formulas
- All installed Homebrew casks
- All installed Homebrew taps
- Optional: Mac App Store apps (if
--include-masis used)
To install all packages from a Brewfile:
./scripts/brew-import.shOptions:
--file FILE- Specify custom input file (default:Brewfile)--dry-run- Show what would be installed without installing--force- Install packages even if already installed--help- Show usage information
You can also use Homebrew's built-in bundle commands:
# Install all packages from Brewfile
brew bundle install
# Check if all packages are installed
brew bundle check
# Update Brewfile with current packages
brew bundle dump --force-
Regular Updates: Periodically update your
Brewfileto reflect current packages:./scripts/brew-export.sh
-
Version Control: The
Brewfileis tracked in git by default. If you have user-specific packages, you can addBrewfileto.gitignore. -
New Machine Setup: On a new machine, clone this repository and run:
./scripts/brew-import.sh
-
Dry Run First: Before importing, check what will be installed:
./scripts/brew-import.sh --dry-run
This configuration includes Lua code formatting:
- Formatting: Uses
styluaviaconform.nvimfor Lua code formatting- Automatically formats on save
- Manual format:
<leader>f(Format buffer) - Configuration:
stylua.tomlin the config root
Installation Requirements:
- Install
stylua:cargo install styluaor via your package manager - Alternatively, install via Mason:
:MasonInstall stylua
Configuration Files:
stylua.toml: Stylua formatter configuration (indentation, line width, etc.)
Note: This section replaces the previous "Key Mappings" section and provides a comprehensive reference for all plugin shortcuts.
Quick reference for the most commonly used shortcuts organized by plugin. All shortcuts use <Space> as the leader key.
Mode Indicators:
n= Normal mode,v= Visual mode,i= Insert mode,t= Terminal mode
| Shortcut | Mode | Description |
|---|---|---|
<leader>ff |
n | Find files (fuzzy search) |
<leader>fg |
n | Live grep (search text across files) |
<leader>fb |
n | Find buffers (switch between open files) |
<leader>fh |
n | Find help tags |
<leader>fr |
n | Find recent files |
<leader>fs |
n | Find in current buffer (fuzzy search) |
<leader>fo |
n | Find symbols in document (LSP) |
<leader>fi |
n | Find incoming calls (LSP) |
<leader>fm |
n | Find methods (Treesitter) |
Telescope Navigation (when picker is open):
<C-j>/<C-k>- Navigate up/down<Enter>- Select item<Esc>- Close picker<C-t>- Open in new tab<C-v>- Open in vertical split<C-x>- Open in horizontal split
| Shortcut | Mode | Description |
|---|---|---|
<leader>ee |
n | Toggle file explorer |
<leader>ef |
n | Find current file in explorer |
<leader>er |
n | Focus file explorer |
nvim-tree Navigation (when explorer is open):
o/<Enter>- Open file or expand directorya- Add file/folderd- Delete file/folderr- Rename file/folderx- Cut file/folderp- Paste file/foldery- Copy file/folderc- Copy file/folder pathw- Copy file/folder nameq- Close explorerR- Refresh explorer?- Show help
| Shortcut | Mode | Description |
|---|---|---|
<C-Space> |
i | Show completion suggestions |
<C-j> |
i | Next completion item |
<C-k> |
i | Previous completion item |
<Tab> |
i | Select next item or jump to next snippet placeholder |
<S-Tab> |
i | Select previous item or jump to previous snippet placeholder |
<C-b> |
i | Scroll documentation backward |
<C-f> |
i | Scroll documentation forward |
<Enter> |
i | Confirm selection (replaces text) |
Completion Sources:
- LSP suggestions (from Pyright, Ruff, etc.)
- Buffer text (words in current file)
- File paths
| Shortcut | Mode | Description |
|---|---|---|
sa{motion}{char} |
n | Add surrounding (e.g., saiw" surrounds word with quotes) |
sd{char} |
n | Delete surrounding (e.g., sd" removes quotes) |
sr{target}{replacement} |
n | Replace surrounding (e.g., sr"' changes quotes to single quotes) |
S{char} |
v | Add surrounding to visual selection |
Common Surrounding Characters:
"- Double quotes'- Single quotes`- Backticks(or)- Parentheses[or]- Square brackets{or}- Curly bracest- HTML/XML tags
Auto-pairs automatically closes brackets, parentheses, and quotes. No shortcuts needed - it works automatically in Insert mode.
Features:
- Automatically closes
(),[],{},"",'',`` - Smart pairing (respects Treesitter syntax)
- Works with LSP completion
| Shortcut | Mode | Description |
|---|---|---|
<leader>gd |
n | Go to definition |
<leader>gD |
n | Go to declaration |
<leader>gi |
n | Go to implementation |
<leader>gr |
n | Find references |
<leader>gt |
n | Go to type definition |
<leader>gg |
n | Show hover documentation |
<leader>gs |
n | Show signature help |
<leader>lr |
n | Rename symbol |
<leader>ga |
n | Code actions (quick fixes, refactors) |
<leader>ai |
n | Auto-import symbol under cursor (nvim-lspimport) |
<C-i> |
i | Auto-import symbol under cursor (insert mode) |
| Shortcut | Mode | Description |
|---|---|---|
<leader>e |
n | Show diagnostic float (error/warning under cursor) |
<leader>q |
n | Open diagnostics in location list |
]d |
n | Next diagnostic |
[d |
n | Previous diagnostic |
<leader>gn |
n | Next diagnostic (alternative) |
<leader>gp |
n | Previous diagnostic (alternative) |
Breakpoints:
| Shortcut | Mode | Description |
|---|---|---|
<leader>bb |
n | Toggle breakpoint |
<leader>bc |
n | Set conditional breakpoint |
<leader>bl |
n | Set logpoint (log without stopping) |
<leader>br |
n | Clear all breakpoints |
<leader>ba |
n | List all breakpoints (Telescope) |
Debug Session Control:
| Shortcut | Mode | Description |
|---|---|---|
<leader>dc |
n | Continue/Start debugging |
<leader>dj |
n | Step over |
<leader>dk |
n | Step into |
<leader>do |
n | Step out |
<leader>dl |
n | Run last debug configuration |
<leader>dt |
n | Terminate debug session |
<leader>dd |
n | Disconnect debugger |
Debug Info & UI:
| Shortcut | Mode | Description |
|---|---|---|
<leader>di |
n | Show variable information (hover) |
<leader>d? |
n | Show scopes |
<leader>dr |
n | Toggle REPL (debug console) |
<leader>df |
n | List frames (call stack) |
<leader>dh |
n | List debug commands |
<leader>de |
n | List diagnostics (errors) |
Django Debug Configurations:
<leader>dcโ Select "๐ DJANGO: Run Server" - Debug Django server<leader>dcโ Select "๐งช DJANGO: Run Tests" - Debug Django tests<leader>dcโ Select "๐ฎ DJANGO: Shell Plus" - Debug Django shell<leader>dcโ Select "โ๏ธ DJANGO: Custom Command" - Debug custom management command
Sidebar Operations:
| Shortcut | Mode | Description |
|---|---|---|
<leader>aa |
n/v | Show sidebar (ask AI) |
<leader>at |
n | Toggle sidebar visibility |
<leader>ar |
n | Refresh sidebar |
<leader>af |
n | Switch sidebar focus |
Code Editing:
| Shortcut | Mode | Description |
|---|---|---|
<leader>ae |
n/v | Edit selected blocks |
<leader>an |
n | Build/Compile avante |
Model and Provider:
| Shortcut | Mode | Description |
|---|---|---|
<leader>a? |
n | Switch AI provider |
| Shortcut | Mode | Description |
|---|---|---|
<leader>db |
n | Toggle database UI |
<leader>dq |
n | Execute query (entire buffer) |
<leader>dq |
v | Execute selected query |
Database UI Navigation (when UI is open):
Enter- Open table/view or execute querys- Open SQL buffer for connection?- Show helpR- Refreshd- Delete connection (when on connection)
| Shortcut | Mode | Description |
|---|---|---|
<leader>rr |
n | Execute HTTP request under cursor |
<leader>rp |
n | Preview HTTP request |
<leader>rl |
n | Run last HTTP request |
Commands:
| Command | Description |
|---|---|
:HttpFormatHelp |
Show REST client help and syntax |
Usage:
- Create
.httpor.restfile - Create
.envfile for variables (optional) - Write HTTP requests separated by
###(e.g.,GET {{API_BASE_URL}}/users) - Place cursor on request line and press
<leader>rr - Response opens in horizontal split with headers and formatted body
| Shortcut | Mode | Description |
|---|---|---|
<leader>f |
n | Format current buffer |
<leader>f |
v | Format selected code |
Formatters:
- Python:
ruff(formatting) - Lua:
stylua - JavaScript/TypeScript:
prettierd - Auto-formats on save (configured per filetype)
| Shortcut | Mode | Description |
|---|---|---|
<leader>ll |
n | Lint current buffer |
<leader>lf |
n | Auto-fix linting issues |
Linters:
- Terraform:
tflint - Python:
ruff(via LSP) - Auto-lints on file save and buffer enter
| Shortcut | Mode | Description |
|---|---|---|
<leader>gb |
n | Toggle git blame (shows author and commit info) |
Usage:
- Toggle blame to see commit info inline
- Shows author, date, and commit message for each line
| Shortcut | Mode | Description |
|---|---|---|
<C-Space> |
n | Show highlight groups under cursor |
<leader>tp |
n | Toggle Treesitter playground |
]m |
n | Next method/function |
[m |
n | Previous method/function |
Features:
- Enhanced syntax highlighting
- Code folding based on syntax
- Better code navigation
| Shortcut | Mode | Description |
|---|---|---|
<leader>ss |
n | Search and load session (Telescope) |
<leader>sd |
n | Delete session (Telescope) |
Features:
- Automatically saves session on exit
- Automatically restores session on open
- Sessions are project-based (by directory)
| Shortcut | Mode | Description |
|---|---|---|
<leader>sm |
n | Toggle maximize current window |
Usage:
- Maximize window to focus on single file
- Toggle again to restore previous layout
| Shortcut | Mode | Description |
|---|---|---|
<leader>sv |
n | Split window vertically |
<leader>sh |
n | Split window horizontally |
<leader>sx |
n | Close split window |
<leader>se |
n | Make splits equal size |
<leader>sw |
n | Move split to new tab |
<leader>sj |
n | Decrease window height |
<leader>sk |
n | Increase window height |
<leader>sl |
n | Increase window width |
| Shortcut | Mode | Description |
|---|---|---|
<leader>bn |
n | Next buffer |
<leader>bp |
n | Previous buffer |
<leader>bd |
n | Delete buffer |
<leader>fb |
n | Find buffers (Telescope) |
| Shortcut | Mode | Description |
|---|---|---|
<leader>to |
n | New tab |
<leader>tx |
n | Close tab |
<leader>tn |
n | Next tab |
<leader>tb |
n | Previous tab |
| Shortcut | Mode | Description |
|---|---|---|
<leader>tt |
n | Open terminal |
<Esc> |
t | Exit terminal mode |
| Shortcut | Mode | Description |
|---|---|---|
<leader>za |
n | Toggle fold |
<leader>zA |
n | Toggle all folds |
<leader>zo |
n | Open fold |
<leader>zc |
n | Close fold |
<leader>zR |
n | Open all folds |
<leader>zM |
n | Close all folds |
| Shortcut | Mode | Description |
|---|---|---|
<leader>qo |
n | Open quickfix list |
<leader>qc |
n | Close quickfix list |
<leader>qn |
n | Next quickfix item |
<leader>qp |
n | Previous quickfix item |
<leader>qf |
n | First quickfix item |
<leader>ql |
n | Last quickfix item |
| Shortcut | Mode | Description |
|---|---|---|
<leader>ww |
n | Save file |
<leader>wq |
n | Save and quit |
<leader>qq |
n | Quit without saving |
gx |
n | Open URL under cursor |
| Shortcut | Mode | Description |
|---|---|---|
<leader>S |
n | Replace word under cursor (interactive) |
<leader>S |
v | Replace visual selection (interactive) |
n |
n | Next search result (centers cursor) |
N |
n | Previous search result (centers cursor) |
* |
n | Search word under cursor (centers cursor) |
This configuration is built for productive Python/Django development with quick access to common tasks. All key mappings are logically organized around the space key as leader.