Revue Companion for Neovim #70

Closed
opened 2026-11-12 01:48:16 +01:00 by thatrichan · 1 comment
Owner

A Neovim plugin, revue-companion.nvim, doing what the JetBrains plugin (jetbrains-plugins/revue-companion) does, in Neovim's way: commands, a pull request list in a buffer or picker, signs in the gutter, and Revue opening a pull request in the running Neovim that has its branch.

Neovim 0.10 or later, pure Lua, no other dependency (Telescope, fzf-lua and snacks pickers used when present).

Features

  • :Revue / :Revue open: the current branch's pull request in Revue, or its New pull request page (revue --pull-request <dir>).
  • :Revue list: the repository's open pull requests (revue --pulls, with --show, drafts, search, pages) in Revue's sections (This branch, To review, Mine, Others), in a picker when one is installed, else a scratch buffer. <CR> opens the details buffer (revue --pull): review, checks, conflicts, files, conversation, stack; mappings to open in Revue or the browser, yank the link, switch to the branch, create the worktree (--worktree), fetch the branch (--fetch-branch).
  • In buffers: the branch's pull request's changes and pending comments as signs and virtual text (--branch-pull, --pending); :Revue file opens the file in the pull request at the cursor's line; :Revue comment on a visual selection adds a pending comment (--comment, the body typed in a small floating window); :Revue files lists the pull request's files to jump to.
  • A statusline component: the branch's pull request number and state, for lualine and others.
  • require("revue_companion").setup({ path = …, signs = …, keys = … }): the revue executable (empty: PATH, then the install places the JetBrains plugin looks in), no default mappings beyond the buffer-local ones in its own windows.
  • :checkhealth revue_companion: finds revue, reads revue --version's editor <N> line, and says whether Revue is running.

It talks to Revue only through the revue command (docs/command-line.md, "What editors can ask"), run with vim.system so nothing blocks the editor. No tokens enter Neovim.

The way back: Revue reaching a running Neovim

Every Neovim already listens on an RPC socket (v:servername), so it needs no server of its own:

  • The plugin registers itself in the same folder as the VS Code extension: <Revue's data folder>/companions/nvim-<pid>.json with { "kind": "nvim", "pid", "socket": v:servername, "version" }, written at startup and removed on VimLeavePre. Revue ignores a stale file (pid gone, socket refusing).
  • Revue asks over msgpack-RPC, calling the plugin's two functions, matching the JetBrains plugin's requests: require("revue_companion").projects() (cwd and tabs' working directories, each repository's root, branch and remotes, whether the UI is focused) and require("revue_companion").open({ path, repo, branch, file, line }) (:tcd to the folder in a new tab unless one has the branch, then :edit file at the line).
  • Neovim has no window to bring forward itself: when it runs in a terminal, Revue also focuses that terminal (by the pid's parent terminal app on macOS, the window under $WINDOWID or the terminal's process on Linux), and says so when it can't.
  • In Revue: the companions module from the VS Code issue reads these files too, and an nvim client (a small msgpack-RPC call over the socket: Unix socket, or named pipe on Windows) does the two requests. #68's chooser then treats Neovim like any other companion.

Where it lives

A new repository, revue-companion.nvim (the layout plugin managers expect: lua/revue_companion/, plugin/, doc/revue-companion.txt), with a Taskfile: tests with busted or mini.test in headless Neovim against a fake revue printing fixture JSON, stylua and luacheck, and releases as tags (lazy.nvim, packer and vim.pack install from the repository).

Plan

  1. The companions registration in Revue (shared with VS Code) and its nvim RPC client, with tests against a headless Neovim.
  2. The plugin's commands that only call revue: open, list, details, file, comment, files, health.
  3. Signs and virtual text, the statusline component.
  4. Registration and the two RPC functions, then #68 choosing it; focusing the terminal.
  5. Docs: docs/editors.md gets a Neovim section, and :help revue-companion.

Related: #68 (choosing the editor with a companion running), the VS Code companion issue, #66 (answers without the app running).

A Neovim plugin, **revue-companion.nvim**, doing what the JetBrains plugin ([jetbrains-plugins/revue-companion](https://forgejo.cleangame.dev/thatrichan/jetbrains-plugins/src/branch/main/revue-companion)) does, in Neovim's way: commands, a pull request list in a buffer or picker, signs in the gutter, and Revue opening a pull request in the running Neovim that has its branch. Neovim 0.10 or later, pure Lua, no other dependency (Telescope, fzf-lua and snacks pickers used when present). ## Features - `:Revue` / `:Revue open`: the current branch's pull request in Revue, or its New pull request page (`revue --pull-request <dir>`). - `:Revue list`: the repository's open pull requests (`revue --pulls`, with `--show`, drafts, search, pages) in Revue's sections (This branch, To review, Mine, Others), in a picker when one is installed, else a scratch buffer. `<CR>` opens the details buffer (`revue --pull`): review, checks, conflicts, files, conversation, stack; mappings to open in Revue or the browser, yank the link, switch to the branch, create the worktree (`--worktree`), fetch the branch (`--fetch-branch`). - **In buffers:** the branch's pull request's changes and pending comments as signs and virtual text (`--branch-pull`, `--pending`); `:Revue file` opens the file in the pull request at the cursor's line; `:Revue comment` on a visual selection adds a pending comment (`--comment`, the body typed in a small floating window); `:Revue files` lists the pull request's files to jump to. - A `statusline` component: the branch's pull request number and state, for lualine and others. - `require("revue_companion").setup({ path = …, signs = …, keys = … })`: the `revue` executable (empty: PATH, then the install places the JetBrains plugin looks in), no default mappings beyond the buffer-local ones in its own windows. - `:checkhealth revue_companion`: finds `revue`, reads `revue --version`'s `editor <N>` line, and says whether Revue is running. It talks to Revue only through the `revue` command (`docs/command-line.md`, "What editors can ask"), run with `vim.system` so nothing blocks the editor. No tokens enter Neovim. ## The way back: Revue reaching a running Neovim Every Neovim already listens on an RPC socket (`v:servername`), so it needs no server of its own: - **The plugin registers itself** in the same folder as the VS Code extension: `<Revue's data folder>/companions/nvim-<pid>.json` with `{ "kind": "nvim", "pid", "socket": v:servername, "version" }`, written at startup and removed on `VimLeavePre`. Revue ignores a stale file (pid gone, socket refusing). - **Revue asks over msgpack-RPC**, calling the plugin's two functions, matching the JetBrains plugin's requests: `require("revue_companion").projects()` (cwd and tabs' working directories, each repository's root, branch and remotes, whether the UI is focused) and `require("revue_companion").open({ path, repo, branch, file, line })` (`:tcd` to the folder in a new tab unless one has the branch, then `:edit file` at the line). - Neovim has no window to bring forward itself: when it runs in a terminal, Revue also focuses that terminal (by the pid's parent terminal app on macOS, the window under `$WINDOWID` or the terminal's process on Linux), and says so when it can't. - In Revue: the `companions` module from the VS Code issue reads these files too, and an `nvim` client (a small msgpack-RPC call over the socket: Unix socket, or named pipe on Windows) does the two requests. #68's chooser then treats Neovim like any other companion. ## Where it lives A new repository, `revue-companion.nvim` (the layout plugin managers expect: `lua/revue_companion/`, `plugin/`, `doc/revue-companion.txt`), with a Taskfile: tests with `busted` or `mini.test` in headless Neovim against a fake `revue` printing fixture JSON, `stylua` and `luacheck`, and releases as tags (lazy.nvim, packer and vim.pack install from the repository). ## Plan 1. The `companions` registration in Revue (shared with VS Code) and its `nvim` RPC client, with tests against a headless Neovim. 2. The plugin's commands that only call `revue`: open, list, details, file, comment, files, health. 3. Signs and virtual text, the statusline component. 4. Registration and the two RPC functions, then #68 choosing it; focusing the terminal. 5. Docs: `docs/editors.md` gets a Neovim section, and `:help revue-companion`. Related: #68 (choosing the editor with a companion running), the VS Code companion issue, #66 (answers without the app running).
Author
Owner

Moved to thatrichan/revue-companion#2, where the companions live now (nvim/, next to jetbrains/). The Revue side of it (the companions registration folder, the nvim RPC client and the editor chooser) stays here, in #68.

Moved to thatrichan/revue-companion#2, where the companions live now (`nvim/`, next to `jetbrains/`). The Revue side of it (the `companions` registration folder, the `nvim` RPC client and the editor chooser) stays here, in #68.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
thatrichan/revue#70
No description provided.