summaryrefslogtreecommitdiff
path: root/plugins/buf
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/buf')
-rw-r--r--plugins/buf/README.md9
-rw-r--r--plugins/buf/buf.plugin.zsh14
2 files changed, 23 insertions, 0 deletions
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