mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-03-29 19:14:05 +08:00
Merge 5db0813da6 into 4daba14316
This commit is contained in:
commit
f4fed7fd3d
23
plugins/ruff/README.md
Normal file
23
plugins/ruff/README.md
Normal file
@ -0,0 +1,23 @@
|
||||
# ruff plugin
|
||||
|
||||
This plugin automatically installs [ruff](https://github.com/astral-sh/ruff)'s completions for you,
|
||||
and keeps them up to date. It also adds convenient aliases for common usage.
|
||||
|
||||
To use it, add `ruff` to the plugins array in your zshrc file:
|
||||
|
||||
```zsh
|
||||
plugins=(... ruff)
|
||||
```
|
||||
|
||||
## Aliases
|
||||
|
||||
| Alias | Command | Description |
|
||||
| :---- | -------------------- | :----------------------------------------------------------- |
|
||||
| ruc | `ruff check` | Run Ruff linter on the given files or directories |
|
||||
| rucf | `ruff check --fix` | Run Ruff linter and fix auto-fixable issues |
|
||||
| ruf | `ruff format` | Run the Ruff formatter on the given files or directories |
|
||||
| rufc | `ruff format --check`| Check if files are already formatted without making changes |
|
||||
| rur | `ruff rule` | Explain a rule (or all rules) |
|
||||
| rul | `ruff linter` | List all supported upstream linters |
|
||||
| rucl | `ruff clean` | Clear any caches in the current directory and subdirectories |
|
||||
| ruup | `ruff self update` | Update Ruff to the latest version |
|
||||
24
plugins/ruff/ruff.plugin.zsh
Normal file
24
plugins/ruff/ruff.plugin.zsh
Normal file
@ -0,0 +1,24 @@
|
||||
# Return immediately if ruff is not found
|
||||
if (( ! ${+commands[ruff]} )); then
|
||||
return
|
||||
fi
|
||||
|
||||
alias ruc='ruff check'
|
||||
alias rucf='ruff check --fix'
|
||||
alias ruf='ruff format'
|
||||
alias rufc='ruff format --check'
|
||||
alias rur='ruff rule'
|
||||
alias rul='ruff linter'
|
||||
alias rucl='ruff clean'
|
||||
alias ruup='ruff self update'
|
||||
|
||||
# If the completion file doesn't exist yet, we need to autoload it and
|
||||
# bind it. Otherwise, compinit will have already done that.
|
||||
if [[ ! -f "$ZSH_CACHE_DIR/completions/_ruff" ]]; then
|
||||
typeset -g -A _comps
|
||||
autoload -Uz _ruff
|
||||
_comps[ruff]=_ruff
|
||||
fi
|
||||
|
||||
# Overwrites the file each time as completions might change with ruff versions.
|
||||
ruff generate-shell-completion zsh >| "$ZSH_CACHE_DIR/completions/_ruff" &|
|
||||
Loading…
Reference in New Issue
Block a user