8000 GitHub - kareigu/hunk.nvim: A tool for splitting diffs in Neovim
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

A tool for splitting diffs in Neovim

License

Notifications You must be signed in to change notification settings

kareigu/hunk.nvim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hunk.nvim

A tool for splitting diffs in Neovim

This is a Neovim tool for splitting/editing diffs. It operates over a left and right directory, producing a diff of the two which can subsequently be inspected and modified. The DiffEditor allows selecting changes by file, hunk or individual line to produce a new partial diff.

This was primarily built to be used with jujutsu as an alternative diff-editor to it's :builtin option, but it's designed generically enough that it can be used for other use cases.

To use it you need to give it two to three directories: a left, a right, and optionally a output directory. These directories will then be read in and used to produce a set of diffs between the two directories. You will then be presented with the left and right side of each file and can select the lines from each diff hunk you would like to keep.

When you are happy with your selection you can accept changes and the diff editor will modify the output directory (or the right directory if no output is provided) to match your selection.

preview

Installation

{
  "julienvincent/hunk.nvim",
  cmd = { "DiffEditor" },
  config = function()
    require("hunk").setup()
  end,
}

Dependencies

If you want file type icons in the file tree then you should have one of either mini.icons or nvim-web-devicons installed. Otherwise, neither are required.

Configuration

local hunk = require("hunk")
hunk.setup({
  keys = {
    global = {
      quit = { "q" },
      accept = { "<leader><Cr>" },
      focus_tree = { "<leader>e" },
    },

    tree = {
      expand_node = { "l", "<Right>" },
      collapse_node = { "h", "<Left>" },

      open_file = { "<Cr>" },

      toggle_file = { "a" },
    },

    diff = {
      toggle_line = { "a" },
      toggle_hunk = { "A" },
    },
  },

  ui = {
    tree = {
      -- Mode can either be `nested` or `flat`
      mode = "nested",
      width = 35,
    },
  },

  icons = {
    selected = "󰡖",
    deselected = "",

    folder_open = "",
    folder_closed = "",
  },
})

Using with Jujutsu

Jujutsu is an alternative VCS that has a focus on working with individual commits and their diffs.

A lot of commands in jujutsu allow you to select parts of a diff. The tool used to select the diff can be configured via their ui.diff-editor config option. To use hunk.nvim add the following to your jujutsu config.toml:

[ui]
diff-editor = ["nvim", "-c", "DiffEditor $left $right $output"]

You can find more info on this config in the jujutsu docs.

About

A tool for splitting diffs in Neovim

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 94.6%
  • Just 5.2%
  • Vim Script 0.2%
0