mirror of
https://github.com/folke/snacks.nvim
synced 2025-07-07 21:25:11 +00:00
feat(image): allow disabling math rendering. Closes #1247
This commit is contained in:
parent
956fe69df3
commit
1543a063fb
2 changed files with 15 additions and 6 deletions
|
@ -1,6 +1,9 @@
|
|||
---@class snacks.image.doc
|
||||
local M = {}
|
||||
|
||||
---@alias TSMatch {node:TSNode, meta:vim.treesitter.query.TSMetadata}
|
||||
---@alias snacks.image.transform fun(match: snacks.image.match, ctx: snacks.image.ctx)
|
||||
|
||||
---@class snacks.image.Hover
|
||||
---@field img snacks.image.Placement
|
||||
---@field win snacks.win
|
||||
|
@ -14,9 +17,13 @@ local M = {}
|
|||
---@field src? TSMatch
|
||||
---@field content? TSMatch
|
||||
|
||||
---@alias TSMatch {node:TSNode, meta:vim.treesitter.query.TSMetadata}
|
||||
---@alias snacks.image.match {id: string, pos: snacks.image.Pos, src?: string, content?: string, ext?: string, range?:Range4}
|
||||
---@alias snacks.image.transform fun(match: snacks.image.match, ctx: snacks.image.ctx)
|
||||
---@class snacks.image.match
|
||||
---@field id string
|
||||
---@field pos snacks.image.Pos
|
||||
---@field src? string
|
||||
---@field content? string
|
||||
---@field ext? string
|
||||
---@field range? Range4
|
||||
|
||||
local META_EXT = "image.ext"
|
||||
local META_SRC = "image.src"
|
||||
|
@ -226,6 +233,9 @@ function M._img(ctx)
|
|||
if img.src then
|
||||
img.src = M.resolve(ctx.buf, img.src)
|
||||
end
|
||||
if not Snacks.image.config.doc.math and img.ext and img.ext:find("math") then
|
||||
return
|
||||
end
|
||||
if img.content and not img.src then
|
||||
local root = Snacks.image.config.cache
|
||||
vim.fn.mkdir(root, "p")
|
||||
|
|
|
@ -67,8 +67,8 @@ local defaults = {
|
|||
doc = {
|
||||
-- enable image viewer for documents
|
||||
-- a treesitter parser must be available for the enabled languages.
|
||||
-- supported language injections: markdown, html
|
||||
enabled = true,
|
||||
math = true, -- enable math expression rendering
|
||||
-- render the image inline in the buffer
|
||||
-- if your env doesn't support unicode placeholders, this will be disabled
|
||||
-- takes precedence over `opts.float` on supported terminals
|
||||
|
@ -79,8 +79,7 @@ local defaults = {
|
|||
max_width = 80,
|
||||
max_height = 40,
|
||||
-- Set to `true`, to conceal the image text when rendering inline.
|
||||
-- (experimental)
|
||||
conceal = false,
|
||||
conceal = false, -- (experimental)
|
||||
},
|
||||
img_dirs = { "img", "images", "assets", "static", "public", "media", "attachments" },
|
||||
-- window options applied to windows displaying image buffers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue