@@ -32,36 +32,14 @@ function M:set_opfunc(opfunc)
32
32
end
33
33
34
34
--- @param opts ? { inactive_win ?: boolean , callbacks ?: boolean }
35
- --- @return { winhl : table<string , string> , hl : table<string , table> }
35
+ --- @return { winhl : { current : table<string , string> , noncurrent : table<string , string> } , hl : table<string , table> }
36
36
function M :gen (opts )
37
37
local State = require ' reactive.state'
38
38
39
- self .snapshot = { winhl = {}, hl = {} }
40
-
41
- -- if we're leaving a window, then we just color that window with `inactive` colors, if presented
42
- if opts and opts .inactive_win then
43
- State :iterate_presets (function (preset )
44
- local constraints = {}
45
-
46
- if
47
- preset .static
48
- and not vim .tbl_isempty (preset .static )
49
- and not self :process_constraints (preset .skip , constraints )
50
- then
51
- self :form {
52
- preset_name = preset .name ,
53
- highlights = {
54
- winhl = preset .static .winhl and preset .static .winhl .inactive ,
55
- hl = preset .static .hl ,
56
- },
57
- scope = ' @static.inactive' ,
58
- constraints = constraints ,
59
- }
60
- end
61
- end )
62
-
63
- return self .snapshot
64
- end
39
+ self .snapshot = {
40
+ winhl = { current = {}, noncurrent = {} },
41
+ hl = {},
42
+ }
65
43
66
44
local mode = self .to
67
45
local mode_len = # mode
@@ -196,9 +174,22 @@ function M:gen(opts)
196
174
if preset .static and not vim .tbl_isempty (preset .static ) then
197
175
self :form {
198
176
preset_name = preset .name ,
199
- highlights = { winhl = preset .static .winhl and preset .static .winhl .active , hl = preset .static .hl },
200
- scope = ' @static.active' ,
177
+ highlights = {
178
+ winhl = preset .static .winhl and preset .static .winhl .active ,
179
+ hl = preset .static .hl ,
180
+ },
181
+ scope = ' @static.current' ,
182
+ constraints = scope [preset .name ] and scope [preset .name ].constraints or {},
183
+ }
184
+
185
+ self :form {
186
+ preset_name = preset .name ,
187
+ highlights = {
188
+ winhl = preset .static .winhl and preset .static .winhl .inactive ,
189
+ },
190
+ scope = ' @static.noncurrent' ,
201
191
constraints = scope [preset .name ] and scope [preset .name ].constraints or {},
192
+ window_scope = ' noncurrent' ,
202
193
}
203
194
end
204
195
@@ -278,7 +269,7 @@ local merge_handlers = {
278
269
Util .each (highlights , function (hl_group , hl_val )
279
270
-- if a group is already applied, then we won't overwrite it
280
271
-- meaning that it had a higher priority
281
- if M .snapshot .winhl [hl_group ] then
272
+ if M .snapshot .winhl [opts . window_scope ][ hl_group ] then
282
273
return
283
274
end
284
275
@@ -297,9 +288,9 @@ local merge_handlers = {
297
288
M .cache .transformed_winhl [key ] = rhs
298
289
end
299
290
300
- M .snapshot .winhl [hl_group ] = rhs
291
+ M .snapshot .winhl [opts . window_scope ][ hl_group ] = rhs
301
292
else
302
- M .snapshot .winhl [hl_group ] = cached_hl
293
+ M .snapshot .winhl [opts . window_scope ][ hl_group ] = cached_hl
303
294
end
304
295
end )
305
296
end ,
@@ -315,11 +306,12 @@ local merge_handlers = {
315
306
end ,
316
307
}
317
308
318
- --- @param opts { preset_name : string , highlights : table<string , table | fun (): table> , scope : string , constraints : TriggerConstraints }
309
+ --- @param opts { preset_name : string , highlights : table<string , table | fun (): table> , scope : string , constraints : TriggerConstraints , window_scope ?: ' current ' | ' noncurrent ' }
319
310
function M :form (opts )
320
311
local handler_options = {
321
312
scope = string.format (' @preset.%s.%s' , opts .preset_name , opts .scope ),
322
313
preset_name = opts .preset_name ,
314
+ window_scope = opts .window_scope or ' current' ,
323
315
}
324
316
325
317
Util .each (merge_handlers , function (value )
0 commit comments