@@ -31,6 +31,9 @@ function M.undo(opts)
3131 local api = require (" undo-glow.api" )
3232 api .emit (" command_executed" , { command = " undo" , opts = opts })
3333
34+ -- Call pre_highlight hook to allow modifications
35+ api .call_hook (" pre_highlight" , opts )
36+
3437 -- Always trigger hooks by calling highlight_region_enhanced
3538 -- This ensures all hooks fire even if there are no text changes to highlight
3639 require (" undo-glow.api" ).highlight_region_enhanced (
@@ -69,6 +72,9 @@ function M.redo(opts)
6972 local api = require (" undo-glow.api" )
7073 api .emit (" command_executed" , { command = " redo" , opts = opts })
7174
75+ -- Call pre_highlight hook to allow modifications
76+ api .call_hook (" pre_highlight" , opts )
77+
7278 -- Always trigger hooks by calling highlight_region_enhanced
7379 -- This ensures all hooks fire even if there are no text changes to highlight
7480 require (" undo-glow.api" ).highlight_region_enhanced (
@@ -106,6 +112,9 @@ function M.yank(opts)
106112 opts = require (" undo-glow.utils" ).merge_command_opts (" UgYank" , opts )
107113 opts .operation = " yank"
108114
115+ -- Call pre_highlight hook to allow modifications
116+ api .call_hook (" pre_highlight" , opts )
117+
109118 -- Always trigger hooks by calling highlight_region directly
110119 require (" undo-glow.api" ).highlight_region_enhanced (
111120 vim .tbl_extend (" force" , opts , {
@@ -149,6 +158,9 @@ function M.paste_below(opts)
149158 local api = require (" undo-glow.api" )
150159 api .emit (" command_executed" , { command = " paste_below" , opts = opts })
151160
161+ -- Call pre_highlight hook to allow modifications
162+ api .call_hook (" pre_highlight" , opts )
163+
152164 -- Always trigger hooks by calling highlight_region directly
153165 require (" undo-glow.api" ).highlight_region_enhanced (
154166 vim .tbl_extend (" force" , opts , {
@@ -186,6 +198,9 @@ function M.paste_above(opts)
186198 local api = require (" undo-glow.api" )
187199 api .emit (" command_executed" , { command = " paste_above" , opts = opts })
188200
201+ -- Call pre_highlight hook to allow modifications
202+ api .call_hook (" pre_highlight" , opts )
203+
189204 -- Always trigger hooks by calling highlight_region directly
190205 require (" undo-glow.api" ).highlight_region_enhanced (
191206 vim .tbl_extend (" force" , opts , {
@@ -229,6 +244,10 @@ function M.search_cmd(opts)
229244 opts = require (" undo-glow.utils" ).merge_command_opts (" UgSearch" , opts )
230245 opts .operation = " search_cmd"
231246
247+ local api = require (" undo-glow.api" )
248+ -- Call pre_highlight hook to allow modifications
249+ api .call_hook (" pre_highlight" , opts )
250+
232251 local region = require (" undo-glow.utils" ).get_current_cursor_row ()
233252
234253 require (" undo-glow.api" ).highlight_region_enhanced (
@@ -270,6 +289,9 @@ function M.search_next(opts)
270289 local api = require (" undo-glow.api" )
271290 api .emit (" command_executed" , { command = " search_next" , opts = opts })
272291
292+ -- Call pre_highlight hook to allow modifications
293+ api .call_hook (" pre_highlight" , opts )
294+
273295 require (" undo-glow.api" ).highlight_region_enhanced (
274296 vim .tbl_extend (" force" , opts , {
275297 s_row = region .s_row ,
@@ -303,6 +325,9 @@ function M.search_prev(opts)
303325 local api = require (" undo-glow.api" )
304326 api .emit (" command_executed" , { command = " search_prev" , opts = opts })
305327
328+ -- Call pre_highlight hook to allow modifications
329+ api .call_hook (" pre_highlight" , opts )
330+
306331 require (" undo-glow.api" ).highlight_region_enhanced (
307332 vim .tbl_extend (" force" , opts , {
308333 s_row = region .s_row ,
@@ -336,6 +361,9 @@ function M.search_star(opts)
336361 local api = require (" undo-glow.api" )
337362 api .emit (" command_executed" , { command = " search_star" , opts = opts })
338363
364+ -- Call pre_highlight hook to allow modifications
365+ api .call_hook (" pre_highlight" , opts )
366+
339367 require (" undo-glow.api" ).highlight_region_enhanced (
340368 vim .tbl_extend (" force" , opts , {
341369 s_row = region .s_row ,
@@ -369,6 +397,9 @@ function M.search_hash(opts)
369397 local api = require (" undo-glow.api" )
370398 api .emit (" command_executed" , { command = " search_hash" , opts = opts })
371399
400+ -- Call pre_highlight hook to allow modifications
401+ api .call_hook (" pre_highlight" , opts )
402+
372403 require (" undo-glow.api" ).highlight_region_enhanced (
373404 vim .tbl_extend (" force" , opts , {
374405 s_row = region .s_row ,
@@ -449,6 +480,10 @@ function M.cursor_moved(opts, cursor_moved_opts)
449480 opts = require (" undo-glow.utils" ).merge_command_opts (" UgCursor" , opts )
450481 opts .operation = " cursor_moved"
451482
483+ local api = require (" undo-glow.api" )
484+ -- Call pre_highlight hook to allow modifications
485+ api .call_hook (" pre_highlight" , opts )
486+
452487 cursor_moved_opts = vim .tbl_deep_extend (" force" , {
453488 ignored_ft = {},
454489 steps_to_trigger = 10 ,
0 commit comments