Search

Search IconIcon to open search

How to Review a PR without Leaving the Terminal (Neovim)

Last updatedUpdated: by Simon Späti · CreatedCreated: · 5 min read

I made a video a while back with Neovim doing git diff:

There’s been many new tools since, see TUIs, but the best that seems to work well these days is Snacks.nvim., below are more tools with similar capabilities.

# Different Tools

  • Required is this plugin gh.nvim with its guide.
  • octo.nvim: Edit and review GitHub issues and pull requests from the comfort of your favorite editor
  • There is also gh-dash for “A beautiful CLI dashboard for GitHub” ( Origin).
  • New one by folke that I use now: gh.md (at snacks.nvim - keybinding:
    • <leader>gi: GitHub Issues (open)`
    • <leader>gI: GitHub Issues (all)
    • <leader>gp: GitHub Pull Requests (open)`
    • <leader>gP : GitHub Pull Requests (all)

# Details

# octa.nvim

GitHub - pwntester/octo.nvim: Edit and review GitHub issues and pull requests from the comfort of your favorite editor

There is only an Octo <object> <action> [arguments] command: If no command is passed, the argument to Octo is treated as a URL from where an issue or pr repo and number are extracted.

Object Action Arguments
issue close Close the current issue
reopen Reopen the current issue
create [repo] Creates a new issue in the current or specified repo
edit [repo] Edit issue <number> in current or specified repo
list [repo] [key=value] (1) List all issues satisfying given filter
search Live issue search
reload Reload issue. Same as doing e!
browser Open current issue in the browser
url Copies the URL of the current issue to the system clipboard
pr list [repo] [key=value] (2) List all PRs satisfying given filter
search Live issue search
edit [repo] Edit PR <number> in current or specified repo
reopen Reopen the current PR
create Creates a new PR for the current branch
close Close the current PR
checkout Checkout PR
commits List all PR commits
changes Show all PR changes (diff hunks)
diff Show PR diff
merge [commit|rebase|squash] [delete] Merge current PR using the specified method
ready Mark a draft PR as ready for review
draft Send a ready PR back to draft
checks Show the status of all checks run on the PR
reload Reload PR. Same as doing e!
browser Open current PR in the browser
url Copies the URL of the current PR to the system clipboard
repo list (3) List repos user owns, contributes or belong to
fork Fork repo
browser Open current repo in the browser
url Copies the URL of the current repo to the system clipboard
view Open a repo by path ({organization}/{name})
gist list [repo] [key=value] (4) List user gists
comment add Add a new comment
delete Delete a comment
thread resolve Mark a review thread as resolved
unresolve Mark a review thread as unresolved
label add [label] Add a label from available label menu
remove [label] Remove a label
create [label] Create a new label
assignee add [login] Assign a user
remove [login] Unassign a user
reviewer add [login] Assign a PR reviewer
reaction thumbs_up | +1 Add 👍 reaction
thumbs_down | -1 Add 👎 reaction
eyes Add 👀 reaction
laugh Add 😄 reaction
confused Add 😕 reaction
rocket Add 🚀 reaction
heart Add ❤️ reaction
hooray | party | tada Add 🎉 reaction
card add Assign issue/PR to a project new card
remove Delete project card
move Move project card to different project/column
review start Start a new review
submit Submit the review
resume Edit a pending review for current PR
discard Deletes a pending review for current PR if any
comments View pending review comments
commit Pick a specific commit to review
close Close the review window and return to the PR
actions Lists all available Octo actions
search Search GitHub for issues and PRs matching the  query
  1. [repo]: If repo is not provided, it will be derived from <cwd>/.git/config.
  2. In-menu mappings:
  • <CR>: Edit Issue
  • <C-b>: Opens issue in the browser
  • <C-y>: Copies URL to system clipboard

# PR Reviews

  • Open the PR (e.g. Octo <PR url> or Octo pr list or Octo pr edit <PR number>)
  • Start a review with Octo review start or resume a pending review with Octo review resume
  • A new tab will show a panel with changed files and two windows showing the diff on any of them.
  • Change panel entries with ]q and [q or by selecting an entry in the window
  • Add comments with <space>ca or suggestions with <space>sa on single or multiple visual-selected lines
    • A new buffer will appear in the alternate diff window. The cursor will be positioned in the new buffer
    • When ready, save the buffer to commit changes to GitHub
    • Move back to the diff window and move the cursor, the thread buffer will hide
  • Hold the cursor on a line with a comment to show a thread buffer with all the thread comments
    • To modify, delete, react or reply to a comment, move to the window containing the thread buffer
    • Perform any operations as if you were in a regular issue buffer
  • Review pending comments with Octo review comments
    • Use to jump to the selected pending comment
  • If you want to review a specific commit, use Octo review commit to pick a commit. The file panel will get filtered to show only files changed by that commit. Any comments placed on these files will be applied at that specific commit level and will be added to the pending review.
  • When ready, submit the review with Octo review submit
  • A new float window will pop up. Enter the top level review comment and exit to normal mode. Then press <C-m> to submit a comment, <C-a> to approve it or <C-r> to request changes

Links to shortcuts

# gh.nvim

Here the most important steps:

Open PR with GHOpenPR <PR number> (or without, which will open a fuzzy finder)

# snack.nvim

GitHub - folke/snacks.nvim: 🍿 A collection of QoL plugins for Neovim · GitHub has a PR and issue puller, too

# Simple Diff Wiew in Neovim

For simple diff views, not full blown PRs, there are plugins too,:

# Further Reads


Origin: video, retriggered by tweet by Mitchell Hashimoto