@@ -357,9 +357,17 @@ is either labeled (C) or not (B).
357357 (when aot ?
358358 (resolve - conflicts targets )))))
359359
360-
361- (fn light - up - beacons [targets ?start ?end ]
362- (for [i (or ?start 1 ) (or ?end (length targets ))]
360+ (fn with - highlight - chores [opts ... ]
361+ (do (local opts (or opts {}))
362+ (hl:cleanup opts.hl - affected - windows )
363+ (hl:apply - backdrop (or opts.backdrop - ranges []))
364+ (do ... )
365+ (hl:highlight - cursor )
366+ (vim.cmd :redraw)))
367+
368+ (fn light - up - beacons [targets opts ]
369+ (local opts (or opts {}))
370+ (for [i (or opts.start 1 ) (or opts.end (length targets ))]
363371 (local target (. targets i ))
364372 (case target.beacon
365373 [offset virttext ]
@@ -486,13 +494,29 @@ is either labeled (C) or not (B).
486494 (when vars.errmsg (echo vars.errmsg ))
487495 (exit )))
488496
489- (macro with - highlight - chores [... ]
490- `(do (hl:cleanup hl - affected - windows )
491- (when-not count
492- (hl:apply - backdrop backward ? ?target - windows ))
493- (do ,... )
494- (hl:highlight - cursor )
495- (vim.cmd :redraw)))
497+ (local backdrop - ranges [])
498+ (when (and (pcall api.nvim_get_hl_by_name hl.group.backdrop false ) (not count ))
499+ (if ?target - windows
500+ (each [_ winid (ipairs ?target - windows )]
501+ (local wininfo (. (vim.fn.getwininfo winid ) 1 ))
502+ (local range {:bufnr wininfo.bufnr
503+ :startrow (dec wininfo.topline )
504+ :startcol 0
505+ :endrow (dec wininfo.botline )
506+ :endcol -1 })
507+ (table . insert backdrop - ranges range ))
508+ (let [[curline curcol ] (map dec [(vim.fn.line "." ) (vim.fn.col "." )])
509+ [win - top win - bot ] [(dec (vim.fn.line "w0" )) (dec (vim.fn.line "w$" ))]
510+ [startrow startcol endrow endcol ] (if backward ?
511+ [win - top 0 curline curcol ]
512+ [curline (inc curcol ) win - bot -1 ])]
513+ (local wininfo (. (vim.fn.getwininfo 0 ) 1 ))
514+ (local range {:bufnr wininfo.bufnr
515+ :startrow startrow
516+ :startcol startcol
517+ :endrow endrow
518+ :endcol endcol })
519+ (table . insert backdrop - ranges range ))))
496520
497521 ; Helper functions ///
498522
@@ -644,7 +668,7 @@ is either labeled (C) or not (B).
644668 (values start end ))))
645669
646670 (fn get - first - pattern - input []
647- (with - highlight - chores (echo "" )) ; clean up the command line
671+ (with - highlight - chores { : backdrop - ranges : hl - affected - windows } (echo "" )) ; clean up the command line
648672 (case (get - input - by - keymap prompt )
649673 ; Here we can handle any other modifier key as "zeroth" input,
650674 ; if the need arises.
@@ -663,7 +687,7 @@ is either labeled (C) or not (B).
663687 ; char<enter> partial input (but it implies not needing
664688 ; to show beacons).
665689 (not count ))
666- (with - highlight - chores (light - up - beacons targets )))
690+ (with - highlight - chores { : backdrop - ranges : hl - affected - windows } (light - up - beacons targets )))
667691 (get - input - by - keymap prompt ))
668692
669693 (fn get - full - pattern - input []
@@ -685,9 +709,8 @@ is either labeled (C) or not (B).
685709 (when targets.label -set
686710 (set- label - states targets {: group - offset }))
687711 (set- beacons targets {:aot? vars.aot ? : no - labels ? : user - given - targets ?})
688- (with - highlight - chores
689- (local (start end ) (get - highlighted - idx - range targets no - labels ?))
690- (light - up - beacons targets start end )))
712+ (local (start end ) (get - highlighted - idx - range targets no - labels ?))
713+ (with - highlight - chores {: backdrop - ranges : hl - affected - windows } (light - up - beacons targets {: start : end })))
691714 ; ---
692715 (fn loop [group - offset first - invoc ?]
693716 (display group - offset )
@@ -751,9 +774,8 @@ is either labeled (C) or not (B).
751774 ; ---
752775 (fn display []
753776 (set- beacons targets {: no - labels ? :aot? vars.aot ? : user - given - targets ?})
754- (with - highlight - chores
755- (local (start end ) (get - highlighted - idx - range targets no - labels ?))
756- (light - up - beacons targets start end )))
777+ (local (start end ) (get - highlighted - idx - range targets no - labels ?))
778+ (with - highlight - chores {: backdrop - ranges : hl - affected - windows } (light - up - beacons targets {: start : end })))
757779 ; ---
758780 (fn get - new - idx [idx in ]
759781 (if (contains ? spec - keys.next_target in ) (min (inc idx ) (length targets ))
@@ -865,7 +887,7 @@ is either labeled (C) or not (B).
865887 targets **
866888 ; The action callback should expect a list in this case.
867889 ; It might also get user input, so keep the beacons highlighted.
868- (do (with - highlight - chores (light - up - beacons targets ** ))
890+ (do (with - highlight - chores { : backdrop - ranges : hl - affected - windows } (light - up - beacons targets ** ))
869891 (do- action targets ** )))
870892 (exit ))
871893
0 commit comments