]> Git — Sourcephile - julm/julm-nix.git/blob - home-manager/profiles/nvim/lua/plugins/hunk.lua
neovim: configure, using ghostty and tmux
[julm/julm-nix.git] / home-manager / profiles / nvim / lua / plugins / hunk.lua
1 -- A tool for splitting diffs in Neovim
2 -- A lot of commands in jujutsu allow you to select parts of a diff.
3 -- The tool used to select the diff can be configured via their ui.diff-editor config option.
4 -- To use hunk.nvim add the following to your jujutsu config.toml:
5 --
6 -- [ui]
7 -- diff-editor = ["nvim", "-c", "DiffEditor $left $right $output"]
8 --
9 -- https://github.com/julienvincent/hunk.nvim
10 return {
11 "hunk.nvim",
12 lazy = false,
13 after = function()
14 require("hunk").setup({
15 keys = {
16 global = {
17 quit = { "q" },
18 accept = { "<leader><Cr>" },
19 focus_tree = { "<leader>e" },
20 },
21
22 tree = {
23 expand_node = { "l", "<Right>" },
24 collapse_node = { "h", "<Left>" },
25
26 open_file = { "<Cr>" },
27
28 toggle_file = { "a" },
29 },
30
31 diff = {
32 toggle_hunk = { "A" },
33 toggle_line = { "a" },
34 -- This is like toggle_line but it will also toggle the line on the other
35 -- 'side' of the diff.
36 toggle_line_pair = { "s" },
37
38 prev_hunk = { "[h" },
39 next_hunk = { "]h" },
40
41 -- Jump between the left and right diff view
42 toggle_focus = { "<Tab>" },
43 },
44 },
45
46 ui = {
47 tree = {
48 -- Mode can either be `nested` or `flat`
49 mode = "nested",
50 width = 35,
51 },
52 --- Can be either `vertical` or `horizontal`
53 layout = "vertical",
54 },
55
56 icons = {
57 selected = "󰡖",
58 deselected = "",
59 partially_selected = "󰛲",
60
61 folder_open = "",
62 folder_closed = "",
63 },
64
65 -- Called right after each window and buffer are created.
66 hooks = {
67 ---@param _context { buf: number, tree: NuiTree, opts: table }
68 on_tree_mount = function(_context) end,
69 ---@param _context { buf: number, win: number }
70 on_diff_mount = function(_context) end,
71 },
72 })
73 end,
74 }