Skip to content

Commit 12fdb6f

Browse files
fix: only create foreground when inversing highlight group
## Details Issue: #154 When creating an inverse highlight group for borders we currently swap both the foreground and background. However there's never really a need to do this since all we care about is applying the original background as the new foreground. Be removing the background property we should avoid issues where users set a foreground as well but expect the result to blend in with the overall background. This also more closely mirrors the goal of the logic.
1 parent 2f9d4f0 commit 12fdb6f

File tree

5 files changed

+6
-9
lines changed

5 files changed

+6
-9
lines changed

Diff for: doc/render-markdown.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For 0.10.0 Last change: 2024 September 01
1+
*render-markdown.txt* For 0.10.0 Last change: 2024 September 08
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*

Diff for: lua/render-markdown/colors.lua

+1-4
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,12 @@ end
8080

8181
---@param highlight string
8282
---@return string
83-
function M.inverse(highlight)
83+
function M.inverse_bg(highlight)
8484
local name = string.format('%s_Inverse_%s', M.prefix, highlight)
8585
if not vim.tbl_contains(cache, name) then
8686
local hl = M.get_hl(highlight)
8787
vim.api.nvim_set_hl(0, name, {
8888
fg = hl.bg,
89-
bg = hl.fg,
90-
---@diagnostic disable-next-line: undefined-field
91-
ctermbg = hl.ctermfg,
9289
---@diagnostic disable-next-line: undefined-field
9390
ctermfg = hl.ctermbg,
9491
})

Diff for: lua/render-markdown/health.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local M = {}
55

66
---@private
77
---@type string
8-
M.version = '6.3.2'
8+
M.version = '6.3.3'
99

1010
function M.check()
1111
vim.health.start('render-markdown.nvim [version]')

Diff for: lua/render-markdown/render/code.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,14 @@ function Render:background(icon_added)
139139
local border_width = width - self.data.col
140140
if not icon_added and self.context:hidden(self.data.code_info) and self:delim_hidden(self.data.start_row) then
141141
self.marks:add(true, self.data.start_row, self.data.col, {
142-
virt_text = { { self.code.above:rep(border_width), colors.inverse(self.code.highlight) } },
142+
virt_text = { { self.code.above:rep(border_width), colors.inverse_bg(self.code.highlight) } },
143143
virt_text_pos = 'overlay',
144144
})
145145
self.data.start_row = self.data.start_row + 1
146146
end
147147
if self:delim_hidden(self.data.end_row - 1) then
148148
self.marks:add(true, self.data.end_row - 1, self.data.col, {
149-
virt_text = { { self.code.below:rep(border_width), colors.inverse(self.code.highlight) } },
149+
virt_text = { { self.code.below:rep(border_width), colors.inverse_bg(self.code.highlight) } },
150150
virt_text_pos = 'overlay',
151151
})
152152
self.data.end_row = self.data.end_row - 1

Diff for: lua/render-markdown/render/heading.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ function Render:border(width)
166166
return
167167
end
168168

169-
local background = colors.inverse(self.data.background)
169+
local background = colors.inverse_bg(self.data.background)
170170
local prefix = self.heading.border_prefix and self.data.level or 0
171171

172172
local line_above = {

0 commit comments

Comments
 (0)