Skip to content

plugins/hunk: init #3293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/maintainers.nix
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,11 @@
githubId = 85367527;
name = "Po Co";
};
jalil-salame = {
email = "[email protected]";
github = "jalil-salame";
githubId = 60845989;
name = "Jalil David Salamé Messina";
keys = [ { fingerprint = "7D6B 4D8F EBC5 7CBC 09AC 331F DA33 17E7 5BE9 485C"; } ];
};
}
50 changes: 50 additions & 0 deletions plugins/by-name/hunk/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
lib,
helpers,
config,
...
}:
lib.nixvim.plugins.mkNeovimPlugin {
name = "hunk";
packPathName = "hunk.nvim";
package = "hunk-nvim";

description = ''
A tool for splitting diffs in Neovim.

If you wish to display icons in the file tree you should enable either
`plugins.web-devicons` or `plugins.mini`. If using `plugins.mini`, you
must enable the `icons` module.
'';

maintainers = [ lib.maintainers.jalil-salame ];

extraConfig.plugins.nui.enable = lib.mkDefault true; # required dependency

settingsExample = {
keys.global.quit = [ "x" ];

ui = {
tree = {
mode = "flat";
width = 40;
};
layout = "horizontal";
};

hooks = {
on_tree_mount =
lib.nixvim.nestedLiteralLua # lua
''
---@param _context { buf: number, tree: NuiTree, opts: table }
function(_context) end
'';
on_diff_mount =
lib.nixvim.nestedLiteralLua # lua
''
---@param _context { buf: number, win: number }
function(_context) end
'';
};
};
}
94 changes: 94 additions & 0 deletions tests/test-sources/plugins/by-name/hunk/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
empty = {
plugins.hunk.enable = true;
};

with-web-devicons = {
plugins.hunk.enable = true;
plugins.web-devicons.enable = true;
};

with-mini = {
plugins.hunk.enable = true;
plugins.mini = {
enable = true;
modules.icons = { };
};
};

example.plugins.hunk = {
enable = true;
settings = {
keys.global.quit = [ "x" ];

ui = {
tree = {
mode = "flat";
width = 40;
};
layout = "horizontal";
};

hooks = {
on_tree_mount.__raw = "function(_context) end";
on_diff_mount.__raw = "function(_context) end";
};
};
};

# Taken directly from the plugin docs: https://github.com/julienvincent/hunk.nvim#configuration
defaults.plugins.hunk = {
enable = true;
settings = {
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 = "nested";
width = 35;
};
layout = "vertical";
};

icons = {
selected = "󰡖";
deselected = "";
partially_selected = "󰛲";

folder_open = "";
folder_closed = "";
};

hooks = {
on_tree_mount.__raw = "function(_context) end";
on_diff_mount.__raw = "function(_context) end";
};
};
};
}