Diff
1diff --git a/plugins/uv/README.md b/plugins/uv/README.md
2new file mode 100644
3index 0000000000000000000000000000000000000000..1b99c1185a28c2c0e8feb746af45d96a4badb51a
4--- /dev/null
5+++ b/plugins/uv/README.md
6@@ -0,0 +1,28 @@
7+# uv plugin
8+
9+This plugin automatically installs [uv](https://github.com/astral-sh/uv)'s completions for you, and keeps them up to date. It also adds convenient aliases for common usage.
10+
11+To use it, add `uv` to the plugins array in your zshrc file:
12+
13+```zsh
14+plugins=(... uv)
15+```
16+
17+## Aliases
18+
19+| Alias | Command | Description |
20+|:----- |------------------------------------------------------------------------ |:-------------------------------------------------------------------- |
21+| uva | `uv add` | Add packages to the project |
22+| uvexp | `uv export --format requirements-txt --no-hashes --output-file requirements.txt --quiet` | Export the lock file to `requirements.txt` |
23+| uvl | `uv lock` | Lock the dependencies |
24+| uvlr | `uv lock --refresh` | Rebuild the lock file without upgrading dependencies |
25+| uvlu | `uv lock --upgrade` | Lock the dependencies to the newest compatible versions |
26+| uvp | `uv pip` | Manage pip packages |
27+| uvpy | `uv python` | Manage Python installs |
28+| uvr | `uv run` | Run commands within the project's environment |
29+| uvrm | `uv remove` | Remove packages from the project |
30+| uvs | `uv sync` | Sync the environment with the lock file |
31+| uvsr | `uv sync --refresh` | "Force" sync the environment with the lock file (ignore cache) |
32+| uvsu | `uv sync --upgrade` | Sync the environment, allowing upgrades and ignoring the lock file |
33+| uvup | `uv self update` | Update the UV tool to the latest version |
34+| uvv | `uv venv` | Manage virtual environments |
35diff --git a/plugins/uv/uv.plugin.zsh b/plugins/uv/uv.plugin.zsh
36new file mode 100644
37index 0000000000000000000000000000000000000000..f1ad37e15eb7530a525831ec78a488a4af51e4ce
38--- /dev/null
39+++ b/plugins/uv/uv.plugin.zsh
40@@ -0,0 +1,38 @@
41+# Return immediately if uv is not found
42+if (( ! ${+commands[uv]} )); then
43+ return
44+fi
45+
46+alias uva='uv add'
47+alias uvexp='uv export --format requirements-txt --no-hashes --output-file requirements.txt --quiet'
48+alias uvl='uv lock'
49+alias uvlr='uv lock --refresh'
50+alias uvlu='uv lock --upgrade'
51+alias uvp='uv pip'
52+alias uvpy='uv python'
53+alias uvr='uv run'
54+alias uvrm='uv remove'
55+alias uvs='uv sync'
56+alias uvsr='uv sync --refresh'
57+alias uvsu='uv sync --upgrade'
58+alias uvup='uv self update'
59+alias uvv='uv venv'
60+
61+# If the completion file doesn't exist yet, we need to autoload it and
62+# bind it. Otherwise, compinit will have already done that.
63+if [[ ! -f "$ZSH_CACHE_DIR/completions/_uv" ]]; then
64+ typeset -g -A _comps
65+ autoload -Uz _uv
66+ _comps[uv]=_uv
67+fi
68+
69+if [[ ! -f "$ZSH_CACHE_DIR/completions/_uvx" ]]; then
70+ typeset -g -A _comps
71+ autoload -Uz _uvx
72+ _comps[uvx]=_uvx
73+fi
74+
75+# uv and uvx are installed together (uvx is an alias to `uv tool run`)
76+# Overwrites the file each time as completions might change with uv versions.
77+uv generate-shell-completion zsh >| "$ZSH_CACHE_DIR/completions/_uv" &|
78+uvx --generate-shell-completion zsh >| "$ZSH_CACHE_DIR/completions/_uvx" &|