]> Git — Sourcephile - julm/julm-nix.git/blob - home-manager/profiles/nvim/lua/plugins/hunk.lua
maint/update(git): use settings
[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 load = function(name)
14 vim.cmd.packadd(name)
15 vim.cmd.packadd("nui.nvim")
16 end,
17 after = function()
18 require("hunk").setup({
19 keys = {
20 global = {
21 quit = { "q" },
22 accept = { "<leader><Cr>" },
23 focus_tree = { "<leader>e" },
24 },
25
26 tree = {
27 expand_node = { "l", "<Right>" },
28 collapse_node = { "h", "<Left>" },
29
30 open_file = { "<Cr>" },
31
32 toggle_file = { "a" },
33 },
34
35 diff = {
36 toggle_hunk = { "A" },
37 toggle_line = { "a" },
38 -- This is like toggle_line but it will also toggle the line on the other
39 -- 'side' of the diff.
40 toggle_line_pair = { "s" },
41
42 prev_hunk = { "[h" },
43 next_hunk = { "]h" },
44
45 -- Jump between the left and right diff view
46 toggle_focus = { "<Tab>" },
47 },
48 },
49
50 ui = {
51 tree = {
52 -- Mode can either be `nested` or `flat`
53 mode = "nested",
54 width = 35,
55 },
56 --- Can be either `vertical` or `horizontal`
57 layout = "vertical",
58 },
59
60 icons = {
61 selected = "󰡖",
62 deselected = "",
63 partially_selected = "󰛲",
64
65 folder_open = "",
66 folder_closed = "",
67 },
68
69 -- Called right after each window and buffer are created.
70 hooks = {
71 ---@param _context { buf: number, tree: NuiTree, opts: table }
72 on_tree_mount = function(_context) end,
73 ---@param _context { buf: number, win: number }
74 on_diff_mount = function(_context) end,
75 },
76 })
77 end,
78 }