From 8da75e390bbe3b64f01fa643cfab815a20bc48f6 Mon Sep 17 00:00:00 2001 From: Lin <56944601+LinPr@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:00:29 +0800 Subject: [PATCH] feat(buf): add completion plugin --- plugins/buf/README.md | 9 +++++++++ plugins/buf/buf.plugin.zsh | 14 ++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 plugins/buf/README.md create mode 100644 plugins/buf/buf.plugin.zsh diff --git a/plugins/buf/README.md b/plugins/buf/README.md new file mode 100644 index 000000000..946cf38dd --- /dev/null +++ b/plugins/buf/README.md @@ -0,0 +1,9 @@ +# Buf plugin + +This plugin adds completion for [Buf CLI](https://github.com/bufbuild/buf), a tool working with Protocol Buffers. + +To use it, add `buf` to the plugins array in your zshrc file: + +```zsh +plugins=(... buf) +``` \ No newline at end of file diff --git a/plugins/buf/buf.plugin.zsh b/plugins/buf/buf.plugin.zsh new file mode 100644 index 000000000..0b251ac37 --- /dev/null +++ b/plugins/buf/buf.plugin.zsh @@ -0,0 +1,14 @@ +# Autocompletion for the Buf CLI (buf). +if (( !$+commands[buf] )); then + return +fi +# If the completion file doesn't exist yet, we need to autoload it and +# bind it to `buf`. Otherwise, compinit will have already done that. +if [[ ! -f "$ZSH_CACHE_DIR/completions/_buf" ]]; then + typeset -g -A _comps + autoload -Uz _buf + _comps[buf]=_buf +fi + +# Generate and load buf completion +buf completion zsh >! "$ZSH_CACHE_DIR/completions/_buf" &| \ No newline at end of file