Your Neovim setup now includes:
- LSP Support: Pyright for type checking + Ruff for linting/formatting
- Auto-formatting: Automatic code formatting with Ruff on save
- Debugging: Full debugging support with nvim-dap
- Testing: Integrated test runner with neotest
- Virtual Environment: Automatic detection and selection
- Project Detection: Auto-detects UV projects (pyproject.toml/uv.lock)
- Environment Activation: Automatically uses correct Python interpreter
- Dependency Management: Works seamlessly with uv commands
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Or with pip
pip install uvThe updated configuration is already in your init.lua. Restart Neovim to install the new plugins:
nvimWait for all plugins to install, then restart Neovim again.
# Make the script executable and add to PATH
chmod +x ~/.local/bin/uvnvim
# Or add the functions to your shell profile
cat >> ~/.bashrc << 'EOF'
# UV + Neovim integration (paste the content from the UV script here)
EOFgd- Go to definitionK- Show hover info<Space>vrn- Rename symbol<Space>vca- Code actions[d/]d- Navigate diagnostics
<Space>db- Toggle breakpoint<Space>dc- Continue/Start debugging<Space>dr- Open REPL<Space>dt- Terminate debugging
<Space>tt- Run test under cursor<Space>tf- Run all tests in file<Space>td- Debug test under cursor<Space>ts- Toggle test summary<Space>to- Open test output
<Space>vs- Select virtual environment<Space>vc- Use cached environment selection
<Space>f- Format current buffer
# Create a new project with proper structure
create_uv_project my-awesome-project
cd my-awesome-project
# Start Neovim with UV context
uvnvimcd existing-uv-project
# Start Neovim (auto-detects UV project)
uvnvim
# Or just use regular nvim (auto-detection still works)
nvim# In your project directory
uv venv
# Install dependencies
uv add requests pytest black ruff
# Install development dependencies
uv add --dev mypy pre-commitmy-project/
βββ pyproject.toml # Project configuration
βββ uv.lock # Dependency lock file
βββ .venv/ # Virtual environment (auto-created)
βββ src/
β βββ my_project/
β βββ __init__.py
β βββ main.py
βββ tests/
β βββ test_main.py
βββ README.md
βββ .gitignore
- Select virtual environment:
<Space>vs - Or manually set:
:lua vim.g.python3_host_prog = '/path/to/python'
- Check Mason installations:
:Mason - Restart LSP:
:LspRestart - Check LSP status:
:LspInfo
- Ensure debugpy is installed:
uv add --dev debugpy - Check DAP status:
:lua print(vim.inspect(require('dap').configurations.python))
- Install pytest:
uv add --dev pytest - Check test adapter:
:lua print(vim.inspect(require('neotest').status()))
The configuration automatically formats Python files on save using Ruff.
The status line shows your current virtual environment.
Use Ctrl+\ to open a floating terminal that inherits the UV environment.
Use the create_uv_project function to scaffold new projects with all the right tools.
Set breakpoints in multiple files and debug complex workflows easily.
# Project management
uv init # Initialize new project
uv add <package> # Add dependency
uv add --dev <package> # Add dev dependency
uv remove <package> # Remove dependency
uv sync # Install all dependencies
# Running code
uv run python script.py # Run with project environment
uv run pytest # Run tests
uv run black . # Format code
uv run ruff check . # Lint code
# Environment management
uv venv # Create virtual environment
uv pip install <package> # Install with pip compatibilityDisclaimer: this is claude generated.