diff --git a/README.md b/README.md index b5666b4..348d22c 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,14 @@ hunk.setup({ folder_open = "", folder_closed = "", }, + + -- Called right after each window and buffer are created. + hooks = { + ---@param _context { buf: number, tree: NuiTree, opts: table } + on_tree_mount = function(_context) end, + ---@param _context { buf: number, win: number } + on_diff_mount = function(_context) end, + }, }) ``` diff --git a/lua/hunk/config.lua b/lua/hunk/config.lua index babe8ab..600c69b 100644 --- a/lua/hunk/config.lua +++ b/lua/hunk/config.lua @@ -41,8 +41,10 @@ local M = { }, hooks = { - on_tree_mount = function() end, - on_diff_mount = function() end, + ---@param _context { buf: number, tree: NuiTree, opts: table } + on_tree_mount = function(_context) end, + ---@param _context { buf: number, win: number } + on_diff_mount = function(_context) end, }, } diff --git a/lua/hunk/ui/file.lua b/lua/hunk/ui/file.lua index 12dc909..e718ee6 100644 --- a/lua/hunk/ui/file.lua +++ b/lua/hunk/ui/file.lua @@ -65,6 +65,8 @@ function M.create(window, params) end, { buffer = buf }) end + config.hooks.on_diff_mount({ buf = buf, win = window }) + local function apply_signs() api.signs.clear_signs(buf) diff --git a/lua/hunk/ui/tree.lua b/lua/hunk/ui/tree.lua index 27535c0..d03d584 100644 --- a/lua/hunk/ui/tree.lua +++ b/lua/hunk/ui/tree.lua @@ -263,6 +263,8 @@ function M.create(opts) end, { buffer = buf }) end + config.hooks.on_tree_mount({ buf = buf, tree = tree, opts = opts }) + local file_tree if config.ui.tree.mode == "nested" then file_tree = build_file_tree(opts.changeset)