Skip to content

Commit dcb7751

Browse files
feat: add snacks.nvim image as conflict if latex is enabled
Double rendering latex in markdown files is probably never the correct thing to do. Add a check on the snacks.nvim image component when detecting conflicts. Minor other changes: - Add a language enum (@alias) used in health checks - Use multi-line strings when providing advice rather than string[]
1 parent 629eb95 commit dcb7751

3 files changed

Lines changed: 62 additions & 18 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
- ability to not conceal wikilink destination when there is an alias [d67113f](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/d67113f11384c0dad96fced2f7b91f1fc811e97f)
1010
- configurable code block background inset [#643](https://github.com/MeanderingProgrammer/render-markdown.nvim/issues/643)
1111
[3f3eea9](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/3f3eea97b80839f629c951ca660ffd125bfa5b34)
12+
- allow rendering when window is in diff mode [#645](https://github.com/MeanderingProgrammer/render-markdown.nvim/issues/645)
13+
[629eb95](https://github.com/MeanderingProgrammer/render-markdown.nvim/commit/629eb9533ec989d9d5c6cab8f3ad5372422c24e0)
1214

1315
### Bug Fixes
1416

doc/render-markdown.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
*render-markdown.txt* Improve viewing Markdown in Neovim
2-
For NVIM v0.12.2 Last change: 2026 May 07
2+
For NVIM v0.12.2 Last change: 2026 May 24
33

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

lua/render-markdown/health.lua

Lines changed: 59 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@ local env = require('render-markdown.lib.env')
22
local icons = require('render-markdown.lib.icons')
33
local state = require('render-markdown.state')
44

5+
---@alias render.md.health.Language
6+
---| 'html'
7+
---| 'latex'
8+
---| 'markdown'
9+
---| 'markdown_inline'
10+
---| 'yaml'
11+
512
---@class render.md.Health
613
local M = {}
714

815
---@private
9-
M.version = '8.12.15'
16+
M.version = '8.12.16'
1017

1118
function M.check()
1219
M.start('versions')
@@ -49,13 +56,15 @@ function M.check()
4956
vim.health.warn('none installed')
5057
end
5158

59+
local latex_works = false
5260
if latex.enabled then
5361
M.start('latex')
5462
local cmds = env.commands(latex.converter)
5563
if #cmds == 0 then
5664
local message = 'none installed: ' .. vim.inspect(latex.converter)
5765
vim.health.warn(message, M.disable('latex'))
5866
else
67+
latex_works = true
5968
vim.health.ok('using: ' .. vim.inspect(cmds))
6069
end
6170
end
@@ -68,13 +77,37 @@ function M.check()
6877
local client = Obsidian or obsidian.get_client()
6978
if client.opts.ui.enable == false then
7079
return nil
71-
else
72-
return {
73-
'Disable the UI in your obsidian.nvim config',
74-
"require('obsidian').setup({ ui = { enable = false } })",
75-
}
7680
end
81+
return [[
82+
disable the ui in your obsidian.nvim config
83+
require("obsidian").setup({
84+
ui = { enable = false },
85+
})
86+
]]
7787
end)
88+
if latex_works then
89+
M.plugin('snacks', function(snacks)
90+
local image = snacks.config.image
91+
if not image or not image.enabled then
92+
return nil
93+
end
94+
if image.doc and image.doc.enabled == false then
95+
return nil
96+
end
97+
if image.math and image.math.enabled == false then
98+
return nil
99+
end
100+
return [[
101+
disable latex math rendering in your snacks.nvim config
102+
require("snacks").setup({
103+
image = {
104+
enabled = true,
105+
math = { enabled = false },
106+
},
107+
})
108+
]]
109+
end)
110+
end
78111
end
79112

80113
---@private
@@ -97,7 +130,7 @@ function M.neovim(min, rec)
97130
end
98131

99132
---@private
100-
---@param language string
133+
---@param language render.md.health.Language
101134
---@param required boolean
102135
---@param active boolean
103136
function M.ts_info(language, required, active)
@@ -149,15 +182,15 @@ function M.ts_info(language, required, active)
149182
vim.health.ok('highlighter: enabled')
150183
else
151184
vim.health.error('highlighter: not enabled', {
152-
('call vim.treesitter.start on %s buffers'):format(language),
185+
('call vim.treesitter.start() on %s buffers'):format(language),
153186
})
154187
end
155188
end
156189
end
157190

158191
---@private
159192
---@param name string
160-
---@param validate? fun(plugin: any): string[]?
193+
---@param validate? fun(plugin: any): string?
161194
function M.plugin(name, validate)
162195
local has_plugin, plugin = pcall(require, name) ---@type boolean, any
163196
if not has_plugin then
@@ -167,22 +200,31 @@ function M.plugin(name, validate)
167200
else
168201
local advice = validate(plugin)
169202
if advice then
170-
vim.health.error(name .. ': installed', advice)
203+
vim.health.error(name .. ': installed', M.trim(advice))
171204
else
172205
vim.health.ok(name .. ': installed but should not conflict')
173206
end
174207
end
175208
end
176209

177210
---@private
178-
---@param language string
179-
---@return string[]
211+
---@param language render.md.health.Language
212+
---@return string
180213
function M.disable(language)
181-
local setup = "require('render-markdown').setup"
182-
return {
183-
('disable %s support to avoid this warning'):format(language),
184-
('%s({ %s = { enabled = false } })'):format(setup, language),
185-
}
214+
local format = [[
215+
disable %s support to avoid this warning
216+
require("render-markdown").setup({
217+
%s = { enabled = false },
218+
})
219+
]]
220+
return M.trim(format:format(language, language))
221+
end
222+
223+
---@private
224+
---@param s string
225+
---@return string
226+
function M.trim(s)
227+
return (s:gsub('%s+$', ''))
186228
end
187229

188230
return M

0 commit comments

Comments
 (0)