A Neovim plugin for seamless integration with uv, the fast Python package manager and project manager.
- Run Python scripts with
uv run
directly from Neovim buffers - Manage dependencies with
uv add
,uv remove
,uv sync
- Project management with
uv init
,uv lock
,uv tree
- Virtual environments with
uv venv
- Pip integration with
uv pip install
,uv pip list
,uv pip show
- Flexible UI - Display results in floating windows, splits, or notifications
- User commands - Easy-to-use
:Uv*
commands for all functionality
- Neovim >= 0.8.0
- uv installed and available in PATH
Using lazy.nvim
{
'yourusername/uv.nvim',
ft = 'python',
config = function()
require('uv').setup()
end,
}
Using packer.nvim
use {
'yourusername/uv.nvim',
ft = 'python',
config = function()
require('uv').setup()
end,
}
Command | Description | Arguments |
---|---|---|
:UvRunBuf |
Run current Python buffer | None |
:UvSync |
Sync project dependencies | None |
:UvAdd <packages> |
Add packages to project | Package names |
:UvRemove <packages> |
Remove packages from project | Package names |
:UvTree |
Show dependency tree | None |
:UvLock |
Regenerate lockfile | None |
:UvVenv |
Create/show virtual environment | Optional path |
:UvRun <command> |
Run arbitrary command with uv | Command and args |
:UvInit [name] |
Initialize new project | Optional project name |
:UvPipInstall <packages> |
Install packages with pip | Package names |
" Run the current Python file
:UvRunBuf
" Add development dependencies
:UvAdd requests pytest black
" Remove unused packages
:UvRemove old-package
" Show dependency tree in split window
:UvTree
" Run a specific Python script
:UvRun python scripts/build.py
" Initialize a new project
:UvInit my-project
local uv = require('uv')
-- Basic usage
uv.sync() -- Sync dependencies (notify UI)
uv.add({'requests', 'httpx'}) -- Add packages (notify UI)
uv.tree() -- Show tree (split UI)
-- Advanced usage with flexible command API
local Command = require('uv.command')
-- Simple commands
local result = Command.execute('sync')
print(result.command) -- "uv sync"
print(result.success) -- true/false
-- Commands with arguments
local result = Command.execute('add', {'requests'})
print(result.command) -- "uv add requests"
-- Table format for complex commands
local result = Command.execute({
subcmd = 'pip',
args = {'install', 'numpy>=1.20'},
cmd = 'uv' -- optional, defaults to 'uv'
})
require('uv').setup({
-- Configuration options will be added here
-- Currently, setup() auto-registers user commands
})
The plugin supports three display modes:
- Float (default): Floating window overlay
- Split: Horizontal split window
- Notify: Neovim notifications
Each command uses an appropriate default UI, but you can customize by using the programmatic API:
local uv = require('uv')
local UI = require('uv.ui')
-- Execute command and display with custom UI
local result = require('uv.command').execute('tree')
UI.display_result(result, 'notify') -- Use notify instead of default split
The plugin follows a modular architecture with clear separation of concerns:
uv.command
- Core command building and executionuv.ui
- Display primitives (float, split, notify)uv.init
- High-level API and user command registration
This design makes the plugin highly testable and extensible.
The plugin uses mini.test for testing:
# Run all tests
nvim --headless -c "lua require('mini.test').run()"
# Run specific test file
nvim --headless -c "lua require('mini.test').run('tests/test_command.lua')"
The project uses stylua for Lua code formatting:
# Check formatting
stylua --check .
# Format code
stylua .
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass and code is formatted
- Submit a pull request
MIT License - see LICENSE file for details.