From b1b2ccedd4750989606d951625b253b6c4bf389e Mon Sep 17 00:00:00 2001 From: Wu Zhenyu Date: Mon, 22 Jan 2024 20:42:54 +0800 Subject: [PATCH] :sparkles: Add ruff --- sources/ruff-check.zsh | 2 ++ sources/ruff-generate-shell-completion.zsh | 7 +++++++ sources/ruff-rule.zsh | 6 ++++++ sources/ruff.zsh | 6 ++++++ 4 files changed, 21 insertions(+) create mode 100644 sources/ruff-check.zsh create mode 100644 sources/ruff-generate-shell-completion.zsh create mode 100644 sources/ruff-rule.zsh create mode 100644 sources/ruff.zsh diff --git a/sources/ruff-check.zsh b/sources/ruff-check.zsh new file mode 100644 index 0000000..8df0f30 --- /dev/null +++ b/sources/ruff-check.zsh @@ -0,0 +1,2 @@ +# :fzf-tab:complete:(\\|*/|)ruff-command-check:argument-rest +[[ -f $realpath ]] && ruff check --show-fixes --show-source -e $realpath || less $realpath diff --git a/sources/ruff-generate-shell-completion.zsh b/sources/ruff-generate-shell-completion.zsh new file mode 100644 index 0000000..6c970b4 --- /dev/null +++ b/sources/ruff-generate-shell-completion.zsh @@ -0,0 +1,7 @@ +# :fzf-tab:complete:(\\|*/|)ruff-command-generate-shell-completion:argument-1 +case $group in +shell) + ruff generate-shell-completion $word | bat -pl$word 2>/dev/null || + ruff generate-shell-completion $word + ;; +esac diff --git a/sources/ruff-rule.zsh b/sources/ruff-rule.zsh new file mode 100644 index 0000000..496451e --- /dev/null +++ b/sources/ruff-rule.zsh @@ -0,0 +1,6 @@ +# :fzf-tab:complete:(\\|*/|)ruff-command-rule:argument-1 +case $group in +'rule -- Rule to explain') + ruff rule $word | mdcat + ;; +esac diff --git a/sources/ruff.zsh b/sources/ruff.zsh new file mode 100644 index 0000000..a50dfed --- /dev/null +++ b/sources/ruff.zsh @@ -0,0 +1,6 @@ +# :fzf-tab:complete:(\\|*/|)ruff(|ruff-command-help):argument-1 +case $group in +'ruff commands'|'ruff help commands') + ruff help $word | bat -plhelp + ;; +esac