Skip to content

Commit

Permalink
Add README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jecaro committed Nov 15, 2024
1 parent c561358 commit ad449d8
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# fugitive-difftool.nvim

[![CI][status-png]][status]

`fugitive-difftool.nvim` is a `neovim` plugin that complete `fugitive`
`difftool` integration. It allows you to compare two revisions of a repository
using the quickfix list. This is useful for code reviews.

![demo](./demo.gif)

## Installation

Install the plugin with your favorite plugin manager. For nixos users, [the
flake file](flake.nix) contains an overlay that will add
`fugitive-difftool-nvim` to the `vimPlugins` attribute set.

## Usage

The plugin exposes lua functions that you can use to browse the quickfix list
filled up by `fugitive` `difftool`.

For example, one can create user commands to call them:

```lua
-- Jump to the first quickfix entry
vim.api.nvim_create_user_command('Gcfir', require('fugitive-difftool').git_cfir, {})
-- To the last
vim.api.nvim_create_user_command('Gcla', require('fugitive-difftool').git_cla, {})
-- To the next
vim.api.nvim_create_user_command('Gcn', require('fugitive-difftool').git_cn, {})
-- To the previous
vim.api.nvim_create_user_command('Gcp', require('fugitive-difftool').git_cp, {})
-- To the currently selected
vim.api.nvim_create_user_command('Gcc', require('fugitive-difftool').git_cc, {})
```

Then if you work on a feature in a branch with many commits and you want to see
all the changes from `master`. One can do:

```
:Git! difftool --name-status master...my-feature
```

Notes about this command:
- `!` will not jump on the first entry in the quickfix list
- by default `difftool` outputs one entry per hunk, `--name-status` will output
only one entry per file which is better in this use case

Once the call to `difftool` is done, the quickfix list contains all the
changes. One can navigate through it with the created user commands.

## Notes

This worked is heavily based on code and comments found in [this issue][issue].

[issue]: https://github.com/tpope/vim-fugitive/issues/132
[status-png]: https://github.com/jecaro/fugitive-difftool.nvim/workflows/CI/badge.svg
[status]: https://github.com/jecaro/fugitive-difftool.nvim/actions

Binary file added demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ad449d8

Please sign in to comment.