https://github.com/h3pei/trace-pr.nvim
Neovim plugin for effortless Pull Request tracing.
https://github.com/h3pei/trace-pr.nvim
github lua neovim neovim-plugin pull-request
Last synced: 5 months ago
JSON representation
Neovim plugin for effortless Pull Request tracing.
- Host: GitHub
- URL: https://github.com/h3pei/trace-pr.nvim
- Owner: h3pei
- License: mit
- Created: 2025-01-22T12:21:20.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-12T14:47:16.000Z (8 months ago)
- Last Synced: 2025-07-23T10:38:13.174Z (6 months ago)
- Topics: github, lua, neovim, neovim-plugin, pull-request
- Language: Lua
- Homepage:
- Size: 31.3 KB
- Stars: 9
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# trace-pr.nvim
https://github.com/user-attachments/assets/74fadf13-fcbd-40de-b549-6c2a630f732e
**trace-pr.nvim** is a Neovim plugin designed to make it easier for developers to trace the Git history of the current line in their code. With this plugin, you can instantly open the nearest Pull Request (PR) on GitHub associated with the line you're working on. If no Pull Request is found, the plugin will open the commit hash instead, streamlining your workflow and saving you precious time.
## Features
- **Locate the nearest Pull Request**: Quickly find the GitHub Pull Request linked to the current line, regardless of whether it was merged using the `Create a merge commit` method or the `Squash and merge` method.
- **Fallback to commit view**: If no PR is found, open the commit hash on GitHub for detailed context. This behavior is configurable.
## Requirements
- `git` must be installed and available in your `PATH`
- [`gh`](https://github.com/cli/cli#installation) must be installed and available in your `PATH`
- A GitHub repository with remote access set up
## Installation
Install the plugin with your package manager:
[lazy.nvim](https://github.com/folke/lazy.nvim):
```lua
{ "h3pei/trace-pr.nvim", config = true }
```
## Usage
Then, you can use the following commands.
|Command|Description|
|:--|:--|
|`:TracePR`|Traces the most recent Pull Request for the current line and opens it with the [`gh browse`](https://cli.github.com/manual/gh_browse) command|
## Configuration
`trace-pr.nvim` works out of the box with default settings, but you can customize it to suit your needs. Here is an example configuration:
```lua
require('trace-pr').setup({
-- Whether to trace on commit if Pull Request is not found, e.g. if it is committed directly.
-- If false, the tracking is terminated with an warning message.
-- Default: true
trace_by_commit_hash_when_pr_not_found = true,
})
```
## How It Works
1. The plugin checks the Git blame information for the current line to identify the commit hash.
2. It queries the GitHub API (via `gh` CLI if available) to locate the associated Pull Request.
3. If a PR is found, the plugin opens it by `gh browse` command. If not, it opens the commit hash view on GitHub.