@@ -128,6 +128,12 @@ function Window:open()
128
128
local win_opts = self :window_options ()
129
129
self .win_id = vim .api .nvim_open_win (self .buf_id , true , win_opts )
130
130
131
+ -- Set window highlights
132
+ self :set_highlight (" NormalFloat" , " GrappleNormal" )
133
+ self :set_highlight (" FloatBorder" , " GrappleBorder" )
134
+ self :set_highlight (" FloatTitle" , " GrappleTitle" )
135
+ self :set_highlight (" FloatFooter" , " GrappleFooter" )
136
+
131
137
-- Setup window to conceal line IDs
132
138
vim .api .nvim_set_option_value (" concealcursor" , " nvic" , { win = self .win_id })
133
139
vim .api .nvim_set_option_value (" conceallevel" , 3 , { win = self .win_id })
@@ -607,4 +613,20 @@ function Window:alternate_path()
607
613
return Path .fs_absolute (alt_name )
608
614
end
609
615
616
+ --- Replaces a highlight group in the window
617
+ --- @param new_from string
618
+ --- @param new_to string
619
+ function Window :set_highlight (new_from , new_to )
620
+ local new_entry = new_from .. " :" .. new_to
621
+ local replace_pattern = string.format (" (%s:[^,]*)" , vim .pesc (new_from ))
622
+ local new_winhighlight , n_replace = vim .wo [self .win_id ].winhighlight :gsub (replace_pattern , new_entry )
623
+ if n_replace == 0 then
624
+ new_winhighlight = new_winhighlight .. " ," .. new_entry
625
+ end
626
+
627
+ pcall (function ()
628
+ vim .wo [self .win_id ].winhighlight = new_winhighlight
629
+ end )
630
+ end
631
+
610
632
return Window
0 commit comments