Skip to content

Commit 286f4e0

Browse files
committed
plugins/hunk: init
Add support for [hunk.nvim][1], a plugin for splitting diffs. Also add myself as a maintainer for it. [1]: https://github.com/julienvincent/hunk.nvim
1 parent c26f5c2 commit 286f4e0

File tree

3 files changed

+157
-0
lines changed

3 files changed

+157
-0
lines changed

lib/maintainers.nix

+7
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,11 @@
136136
githubId = 85367527;
137137
name = "Po Co";
138138
};
139+
jalil-salame = {
140+
email = "[email protected]";
141+
github = "jalil-salame";
142+
githubId = 60845989;
143+
name = "Jalil David Salamé Messina";
144+
keys = [ { fingerprint = "7D6B 4D8F EBC5 7CBC 09AC 331F DA33 17E7 5BE9 485C"; } ];
145+
};
139146
}

plugins/by-name/hunk/default.nix

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
lib,
3+
helpers,
4+
config,
5+
...
6+
}:
7+
lib.nixvim.plugins.mkNeovimPlugin {
8+
name = "hunk";
9+
packPathName = "hunk.nvim";
10+
package = "hunk-nvim";
11+
12+
description = ''
13+
A tool for splitting diffs in Neovim
14+
15+
Either `plugins.web-devicons` or `plugins.mini`* must be enabled to have icons in the file tree.
16+
17+
*If using `plugins.mini`, you must enable the `icons` module.
18+
'';
19+
20+
maintainers = [ lib.maintainers.jalil-salame ];
21+
22+
extraConfig.plugins.nui.enable = lib.mkDefault true; # required dependency
23+
24+
settingsExample = {
25+
keys.global.quit = [ "x" ];
26+
27+
ui = {
28+
tree = {
29+
mode = "flat";
30+
width = 40;
31+
};
32+
layout = "horizontal";
33+
};
34+
35+
hooks = {
36+
on_tree_mount =
37+
lib.nixvim.nestedLiteralLua # lua
38+
''
39+
---@param _context { buf: number, tree: NuiTree, opts: table }
40+
function(_context) end
41+
'';
42+
on_diff_mount =
43+
lib.nixvim.nestedLiteralLua # lua
44+
''
45+
---@param _context { buf: number, win: number }
46+
function(_context) end
47+
'';
48+
};
49+
};
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
{
2+
empty = {
3+
plugins.hunk.enable = true;
4+
};
5+
6+
with-web-devicons = {
7+
plugins.hunk = {
8+
enable = true;
9+
fileTypeIcons = true;
10+
};
11+
plugins.web-devicons.enable = true;
12+
};
13+
14+
with-mini = {
15+
plugins.hunk = {
16+
enable = true;
17+
fileTypeIcons = true;
18+
};
19+
plugins.mini = {
20+
enable = true;
21+
modules.icons = { };
22+
};
23+
};
24+
25+
example.plugins.hunk = {
26+
enable = true;
27+
settings = {
28+
keys.global.quit = [ "x" ];
29+
30+
ui = {
31+
tree = {
32+
mode = "flat";
33+
width = 40;
34+
};
35+
layout = "horizontal";
36+
};
37+
38+
hooks = {
39+
on_tree_mount.__raw = "function(_context) end";
40+
on_diff_mount.__raw = "function(_context) end";
41+
};
42+
};
43+
};
44+
45+
# Taken directly from the plugin docs: https://github.com/julienvincent/hunk.nvim#configuration
46+
defaults.plugins.hunk = {
47+
enable = true;
48+
settings = {
49+
keys = {
50+
global = {
51+
quit = [ "q" ];
52+
accept = [ "<leader><Cr>" ];
53+
focus_tree = [ "<leader>e" ];
54+
};
55+
56+
tree = {
57+
expand_node = [
58+
"l"
59+
"<Right>"
60+
];
61+
collapse_node = [
62+
"h"
63+
"<Left>"
64+
];
65+
66+
open_file = [ "<Cr>" ];
67+
68+
toggle_file = [ "a" ];
69+
};
70+
71+
diff = {
72+
toggle_line = [ "a" ];
73+
toggle_hunk = [ "A" ];
74+
};
75+
};
76+
77+
ui = {
78+
tree = {
79+
mode = "nested";
80+
width = 35;
81+
};
82+
layout = "vertical";
83+
};
84+
85+
icons = {
86+
selected = "󰡖";
87+
deselected = "";
88+
partially_selected = "󰛲";
89+
90+
folder_open = "";
91+
folder_closed = "";
92+
};
93+
94+
hooks = {
95+
on_tree_mount.__raw = "function(_context) end";
96+
on_diff_mount.__raw = "function(_context) end";
97+
};
98+
};
99+
};
100+
}

0 commit comments

Comments
 (0)