@@ -93,21 +93,22 @@ function M.source(source, links)
93
93
end
94
94
95
95
M ._fixed = {} --- @type table<string , string>
96
- --- @param sl string
97
- function M .fix_statusline (sl , statusline_hl )
98
- local bg = vim .api .nvim_get_hl (0 , { name = statusline_hl , link = false })
99
- bg = bg and bg .bg or nil
100
-
101
- return sl :gsub (" %%#(.-)#" , function (hl )
102
- if not M ._fixed [hl ] then
103
- local opts = vim .api .nvim_get_hl (0 , { name = hl , link = false }) or {}
104
- opts .bg = bg
105
- local group = " TroubleStatusline" .. vim .tbl_count (M ._fixed )
106
- vim .api .nvim_set_hl (0 , group , opts )
107
- M ._fixed [hl ] = group
108
- end
109
- return " %#" .. M ._fixed [hl ] .. " #"
110
- end )
96
+ --- @param hl string
97
+ --- @param statusline_hl string ?
98
+ function M .fix_statusline_bg (hl , statusline_hl )
99
+ if not statusline_hl then
100
+ return hl
101
+ end
102
+ local key = hl .. " _" .. statusline_hl
103
+ if not M ._fixed [key ] then
104
+ local opts = vim .api .nvim_get_hl (0 , { name = hl , link = false }) or {}
105
+ local statusline_opts = vim .api .nvim_get_hl (0 , { name = statusline_hl , link = false })
106
+ opts .bg = statusline_opts and statusline_opts .bg or nil
107
+ local group = " TroubleStatusline" .. vim .tbl_count (M ._fixed )
108
+ vim .api .nvim_set_hl (0 , group , opts )
109
+ M ._fixed [key ] = group
110
+ end
111
+ return M ._fixed [key ]
111
112
end
112
113
113
114
return M
0 commit comments