At the time of writing, the only Gerrit provider Zed implicitly supports is the Chromium Gerrit provider for stuff like copying permalinks and opening the review link for a "PR" when drilling down into commits.
Its hardcoded to use Chromium's Gerrit URLs, which are https://chromium-review.googlesource.com for the Gerrit UI,
and https://chromium.googlesource.com for the Gerrit repo.
As git_hosting_providers exists today, there's not a simple way to extend the model without introducing
Gerrit-specifc params into the configuration.
As a workaround, we can leverage Zed's tasks configuration. Zed tasks allow access to some Zed state during runtime (like selected text, current file, etc.).
That means its possible to add some key bindings to trigger shell-based tasks for creating permalinks or opening reviews from highlighted Change-Id's.
You can copy over the zed-gerrit-provider.sh script to ~/.local/bin and the zed/ configs to your ~/.config/zed.
Or do a one-line install:
curl -fsSL https://raw.githubusercontent.com/catgrep/zed-gerrit-provider-tasks/main/install.sh | shThe install.sh script is idempotent, so its safe to re-run it. It will:
- Download the
zed-gerrit-provider.shscript to~/.local/bin/zed-gerrit-provider.shand mark it executable - Download
zed/tasks.jsonandzed/keymap.jsonto~/.config/zed(and merge them if those files already exist)
You should probably change the default key bindings post-installation.
They don't conflict with Zed's MacOS or Linux defaults, but might with your profile or system.
To copy a permalink to the current file and line, enter:
ctrl-cmd-k(Darwin)alt-shift-c(Linux)
You'll see a terminal window pop-up with some basic logging, like:
Copied: /plugins/gitiles/k8s-gerrit/+/$COMMIT_SHA/Jenkinsfile#1
⏵ Task `gerrit_copy_permalink` finished successfully
⏵ Command: /bin/zsh -i -c '~/.local/bin/zed-gerrit-provider.sh'For opening a review, hover over a line to show the git blame modal and click the branch symbol with the commit hash in the lower right-hand corner.
This opens up the commit message and diff.
Select the Change-Id with your cursor:
To open the Gerrit review in your browser, enter:
ctrl-cmd-g(Darwin)alt-shift-g(Linux)
You'll see a terminal window pop-up with some basic logging, like:
Opened: https://gerrit-review.googlesource.com/q/$CHANGE_ID
⏵ Task `gerrit_open_review` finished successfully
⏵ Command: /bin/zsh -i -c '~/.local/bin/zed-gerrit-provider.sh'There are two tasks provided by zed/tasks.json:
gerrit_open_review: a task for opening a Gerrit review url generated from a highlighted Change-Idgerrit_copy_permalink: a task for generating and copying a Gerrit Gitiles permalink line to your clipboard
These tasks can be trigged by either running task: spawn from the Command Pallete or by the keyboard shortcuts in zed/keymap.json:
ctrl+cmd+g: runsgerrit_open_reviewwhen highlighting the Change-Id in a commit message (or anywhere in the Workspace)ctrl+cmd+k: runsgerrit_copy_permalinkwhen the cursor is on a line (or anywhere in the Workspace)
The tasks have an overrideable field ZED_GERRIT_REVIEW_URL that can be set from the environment, or in the
tasks.json. You won't need to touch this unless your Gerrit UI has a different domain than your Gerrit repository.

