From 7ddf129c0f7ad648435c1cf3471fc2a5f88b1f0a Mon Sep 17 00:00:00 2001 From: Ben Lubas Date: Mon, 27 May 2024 16:36:07 -0400 Subject: [PATCH 1/4] ref!(math-renderer): modularize image generation to make way for typst --- lua/neorg/modules/core/highlights/module.lua | 6 +- .../modules/core/latex/renderer/module.lua | 11 +- .../core/math/renderer/latex/module.lua | 135 +++++ .../modules/core/math/renderer/module.lua | 511 ++++++++++++++++++ 4 files changed, 655 insertions(+), 8 deletions(-) create mode 100644 lua/neorg/modules/core/math/renderer/latex/module.lua create mode 100644 lua/neorg/modules/core/math/renderer/module.lua diff --git a/lua/neorg/modules/core/highlights/module.lua b/lua/neorg/modules/core/highlights/module.lua index a7e52ec87..14eb84e1a 100644 --- a/lua/neorg/modules/core/highlights/module.lua +++ b/lua/neorg/modules/core/highlights/module.lua @@ -368,10 +368,10 @@ module.config.public = { escape = "+@type", }, - -- Rendered Latex, this will dictate the foreground color of latex images rendered via - -- core.latex.renderer + -- Rendered Latex, this will dictate the foreground color of math images rendered via + -- core.math.renderer rendered = { - latex = "+Normal", + math = "+Normal", }, }, diff --git a/lua/neorg/modules/core/latex/renderer/module.lua b/lua/neorg/modules/core/latex/renderer/module.lua index 8a7a8b53d..a5f811607 100644 --- a/lua/neorg/modules/core/latex/renderer/module.lua +++ b/lua/neorg/modules/core/latex/renderer/module.lua @@ -20,6 +20,7 @@ Requires: There's a highlight group that controls the foreground color of the rendered latex: `@norg.rendered.latex`, configurable in `core.highlights` --]] + local nio local neorg = require("neorg.core") local module = neorg.modules.create("core.latex.renderer") @@ -173,11 +174,11 @@ module.public = { module.private.cleared_at_cursor = {} module.required["core.integrations.treesitter"].execute_query( [[ - ( - (inline_math) @latex - (#offset! @latex 0 1 0 -1) - ) - ]], + ( + (inline_math) @latex + (#offset! @latex 0 1 0 -1) + ) + ]], function(query, id, node) if query.captures[id] ~= "latex" then return diff --git a/lua/neorg/modules/core/math/renderer/latex/module.lua b/lua/neorg/modules/core/math/renderer/latex/module.lua new file mode 100644 index 000000000..093fc3f72 --- /dev/null +++ b/lua/neorg/modules/core/math/renderer/latex/module.lua @@ -0,0 +1,135 @@ +--[[ + file: Core-Math-Renderer-LaTeX + title: Convert LaTeX snippets into image files + summary: A module that provides images of LaTeX for `core.math.renderer` + --- + +The module is used by `core.math.renderer` to render math blocks as LaTeX. + +Requires: +- `latex` executable in path with the following packages: + - standalone + - amsmath + - amssymb + - graphicx +- `dvipng` executable in path (normally comes with LaTeX) + +A highlight group that controls the foreground color of the rendered math: `@norg.rendered.latex`, +configurable in `core.highlights`. It links to `Normal` by default + +Note, when `'concealcursor'` contains `"n"` This plugin will fail for the time being. +--]] +local nio +local neorg = require("neorg.core") +local module = neorg.modules.create("core.math.renderer.latex") + +assert(vim.re ~= nil, "Neovim 0.10.0+ is required for the `core.math.renderer.latex` module!") + +module.load = function() + nio = require("nio") +end + +module.config.public = { + -- "Dots Per Inch" increasing this value will result in crisper images at the expense of + -- performance + dpi = 350, +} + +module.private = {} + +---@type MathImageGenerator +module.public = { + ---Returns a filepath where the rendered image sits + ---@async + ---@param snippet string the full latex snippet to convert to an image + ---@param foreground_color { r: number, g: number, b: number } + ---@return string | nil + async_generate_image = function(snippet, foreground_color) + local document_name = module.private.async_create_latex_document(snippet) + + if not document_name then + return + end + + local cwd = nio.fn.fnamemodify(document_name, ":h") + local create_dvi = nio.process.run({ + cmd = "latex", + args = { + "--interaction=nonstopmode", + "--output-format=dvi", + document_name, + }, + cwd = cwd, + }) + if not create_dvi or type(create_dvi) == "string" then + return + end + local res = create_dvi.result() + if res ~= 0 then + return + end + + local png_result = nio.fn.tempname() + png_result = ("%s.png"):format(png_result) + + local fg = module.private.format_color(foreground_color) + local dvipng = nio.process.run({ + cmd = "dvipng", + args = { + "-D", + module.config.public.dpi, + "-T", + "tight", + "-bg", + "Transparent", + "-fg", + fg, + "-o", + png_result, + document_name .. ".dvi", + }, + }) + + if not dvipng or type(dvipng) == "string" then + return + end + res = dvipng.result() + if res ~= 0 then + return + end + + return png_result + end, +} + +---Writes a latex snippet to a file and wraps it with latex headers so it will render nicely +---@async +---@param snippet string latex snippet (if it's math it should include the surrounding $$) +---@return string temp file path +module.private.async_create_latex_document = function(snippet) + local tempname = nio.fn.tempname() + local tempfile = nio.file.open(tempname, "w") + + local content = table.concat({ + "\\documentclass[6pt]{standalone}", + "\\usepackage{amsmath}", + "\\usepackage{amssymb}", + "\\usepackage{graphicx}", + "\\begin{document}", + snippet, + "\\end{document}", + }, "\n") + + tempfile.write(content) + tempfile.close() + + return tempname +end + +---Format the foreground color information into something that can be passed to the dvipng command +---@param foreground_color {r: number, g: number, b: number} +module.private.format_color = function(foreground_color) + return ("rgb %s %s %s"):format(foreground_color.r, foreground_color.g, foreground_color.b) +end + +return module diff --git a/lua/neorg/modules/core/math/renderer/module.lua b/lua/neorg/modules/core/math/renderer/module.lua new file mode 100644 index 000000000..144dc49e9 --- /dev/null +++ b/lua/neorg/modules/core/math/renderer/module.lua @@ -0,0 +1,511 @@ +--[[ + file: Core-Math-Renderer + title: Conceal Math ranges with their rendered versions + summary: An experimental module for rendering inline math blocks + --- + +> [!WARNING] +> This is an experimental module. It's also a module that can potentially render a large number of +> images to your terminal. Terminal images, are inherently pretty slow, so be careful activating this +> plugin in files that contains excessive amounts of inline math blocks. + +It renders math snippets as images making use of the image.nvim +plugin. By default, images are only rendered after running the command: `:Neorg render-math`. + +Requires: +- [image.nvim](https://github.com/3rd/image.nvim) + +## Commands +- `:Neorg render-math enable` +- `:Neorg render-math disable` +- `:Neorg render-math toggle` + +## Highlights +- `@neorg.rendered.math` - highlight group that controls the foreground color of the rendered math + - Configurable in `core.highlights` + - Links to `:h hi-Normal` by default +--]] +local nio +local neorg = require("neorg.core") +local module = neorg.modules.create("core.math.renderer") +local modules = neorg.modules + +assert(vim.re ~= nil, "Neovim 0.10.0+ is required to run the `core.math.renderer` module!") + +module.setup = function() + return { + requires = { + "core.integrations.image", + "core.integrations.treesitter", + "core.autocommands", + "core.neorgcmd", + "core.highlights", + }, + wants = { + "core.math.renderer.latex", + }, + } +end + +module.config.public = { + -- When true, images of rendered LaTeX will cover the source LaTeX they were produced from. + -- Setting this value to false creates more lag, and can be buggy with large numbers of images. + conceal = true, + + -- When true, images will render when a `.norg` buffer is entered + render_on_enter = false, + + -- Module that renders the images. "core.integrations.image" makes use of image.nvim and is + -- currently the only option + image_renderer = "core.integrations.image", + + -- The module which provides a function which takes a cleaned math string and creates a temp + -- file containing the rendered image data, and returns that data. + -- + -- There is currently one option: "core.math.renderer.latex" + image_generator = "core.math.renderer.latex", + + -- Don't re-render anything until 200ms after the buffer has stopped changing. Lowering will + -- lead to a more seamless experience but will cause more temporary images to be created + debounce_ms = 200, + + -- Only render math snippets that are longer than this many chars. Escaped chars are removed + -- spaces are counted, `$` and `$|`/`|$` are not (ie. `$\\int$` counts as 4 chars) + min_length = 3, + + -- Make the images larger or smaller by adjusting the scale. Will not pad images with virtual + -- text when `conceal = true`, so they can overlap text. Images will not be blown up larger than + -- their true size, so images may still render one line tall. + scale = 1, +} + +---@class Image +---@field path string +-- and many other fields that I don't necessarily need + +---@class MathRange +---@field image Image our limited representation of an image +---@field range Range4 last range of the math block. Updated based on the extmark +---@field snippet string cleaned math snippet +---@field extmark_id number? when rendered, the extmark_id that belongs to this image +---@field real boolean tag ranges that are confirmed to still exist by TS + +---Compute the foreground color +---@return { r: number, g: number, b: number } #each value is a number between 0 and 1 +local function compute_foreground() + local neorg_hi = neorg.modules.get_module("core.highlights") + assert(neorg_hi, "Failed to load core.highlights") + local hi = vim.api.nvim_get_hl(0, { name = "@neorg.rendered.math", link = false }) + if not vim.tbl_isempty(hi) then + local r, g, b = neorg_hi.hex_to_rgb(("%06x"):format(hi.fg)) + return { r = r / 255, g = g / 255, b = b / 255 } + end + + return { r = 0.5, g = 0.5, b = 0.5 } -- grey +end + +---@class MathImageGenerator +---@field async_generate_image function () + +module.load = function() + local success, image_api = pcall(neorg.modules.get_module, module.config.public.image_renderer) + assert(success, "Unable to load image_renderer module") + local ok, math_image_generator = pcall(neorg.modules.get_module, module.config.public.image_generator) + assert(ok, "Unable to load image_generator module") + + nio = require("nio") + + -- compute the foreground color in rgb + module.private.foreground = compute_foreground() + + ---@type string[] ids + module.private.cleared_at_cursor = {} + + ---Image cache. math snippet to file path + ---@type table + module.private.image_paths = {} + + ---@type table> + module.private.math_images = {} + + module.private.image_api = image_api + module.private.math_image_generator = math_image_generator + module.private.extmark_ns = vim.api.nvim_create_namespace("neorg-math-concealer") + + module.private.do_render = module.config.public.render_on_enter + + module.required["core.autocommands"].enable_autocommand("BufWinEnter") + module.required["core.autocommands"].enable_autocommand("CursorMoved") + module.required["core.autocommands"].enable_autocommand("TextChanged") + module.required["core.autocommands"].enable_autocommand("TextChangedI") + + modules.await("core.neorgcmd", function(neorgcmd) + neorgcmd.add_commands_from_table({ + ["render-math"] = { + name = "math.render.render", + min_args = 0, + max_args = 1, + subcommands = { + enable = { + args = 0, + name = "math.render.enable", + }, + disable = { + args = 0, + name = "math.render.disable", + }, + toggle = { + args = 0, + name = "math.render.toggle", + }, + }, + condition = "norg", + }, + }) + end) +end + +---Get the key for a given range +---@param range Range4 +module.private.get_key = function(range) + return ("%d:%d"):format(range[1], range[2]) +end + +module.public = { + ---@async + ---@param buf number + async_math_renderer = function(buf) + -- Update all the limage keys to their new extmark locations + ---@type table + local new_limages = {} + for _, limage in pairs(module.private.math_images[buf] or {}) do + if limage.extmark_id then + local extmark = + nio.api.nvim_buf_get_extmark_by_id(buf, module.private.extmark_ns, limage.extmark_id, {}) + local new_key = module.private.get_key({ extmark[1], extmark[2] }) + limage.real = false + new_limages[new_key] = limage + end + end + module.private.cleared_at_cursor = {} + module.required["core.integrations.treesitter"].execute_query( + [[ + ( + (inline_math) @math + (#offset! @math 0 1 0 -1) + ) + ]], + function(query, id, node) + if query.captures[id] ~= "math" then + return + end + + local original_snippet = + module.required["core.integrations.treesitter"].get_node_text(node, nio.api.nvim_get_current_buf()) + local clean_snippet = string.gsub(original_snippet, "^%$|", "$") + clean_snippet = string.gsub(clean_snippet, "|%$$", "$") + if clean_snippet == original_snippet then + -- this is a normal math block, we need to remove leading `\` chars + -- TODO: test that this regex is actually correct + clean_snippet = string.gsub(clean_snippet, "\\(.)", "%1") + end + -- `- 2` for the two `$`s + if string.len(clean_snippet) - 2 < module.config.public.min_length then + return + end + + local png_location = module.private.image_paths[clean_snippet] + or module.private.math_image_generator.async_generate_image( + clean_snippet, + module.private.foreground + ) + if not png_location then + return + end + module.private.image_paths[clean_snippet] = png_location + local range = { node:range() } + local key = module.private.get_key(range) + + -- If there's already an image at this location and it's the same snippet, don't do + -- anything + if new_limages[key] then + if new_limages[key].snippet == clean_snippet then + new_limages[key].range = range + new_limages[key].real = true + return + end + end + + local img = module.private.image_api.new_image( + buf, + png_location, + module.required["core.integrations.treesitter"].get_node_range(node), + nio.api.nvim_get_current_win(), + module.config.public.scale, + not module.config.public.conceal + ) + local existing_ext_id = new_limages[key] and new_limages[key].extmark_id + new_limages[key] = { + image = img, + range = range, + snippet = clean_snippet, + real = true, + extmark_id = existing_ext_id, + } + end, + buf + ) + + nio.scheduler() + + for key, limage in pairs(new_limages) do + if not limage.real then + module.private.image_api.clear({ [key] = limage }) + if limage.extmark_id then + nio.api.nvim_buf_del_extmark(0, module.private.extmark_ns, limage.extmark_id) + end + new_limages[key] = nil + end + end + module.private.math_images[buf] = new_limages + end, + + ---Actually renders the images (along with any extmarks it needs) + ---@param images table + render_inline_math = function(images, buffer) + local conceallevel = vim.api.nvim_get_option_value("conceallevel", { win = 0 }) + local concealcursor = vim.api.nvim_get_option_value("concealcursor", { win = 0 }) + local mode = vim.api.nvim_get_mode().mode + -- account for concealcursor, ie. don't un-render images when conceal cursor contains "n" unless + -- we're in insert mode. + local cc_n = concealcursor:match("n") and mode == "n" + local cursor_row = vim.api.nvim_win_get_cursor(0)[1] + local conceal_on = conceallevel >= 2 and module.config.public.conceal + -- Create all extmarks before rendering images b/c these extmarks will change the + -- position of the images + for _, limage in pairs(images) do + local range = limage.range + + local ext_opts = { + end_col = range[4], + strict = false, + invalidate = true, + undo_restore = false, + id = limage.extmark_id, -- if it exists, update it, else this is nil so it will create a new one + } + + if module.config.public.conceal then + local image = limage.image + local predicted_image_dimensions = + module.private.image_api.image_size(image, { height = module.config.public.scale }) + if range[1] ~= cursor_row - 1 or cc_n then + ext_opts.virt_text = { { (" "):rep(predicted_image_dimensions.width) } } + ext_opts.virt_text_pos = "inline" + end + end + + if conceal_on and (range[1] ~= cursor_row - 1 or cc_n) then + ext_opts.conceal = "" + end + + limage.extmark_id = + vim.api.nvim_buf_set_extmark(buffer, module.private.extmark_ns, range[1], range[2], ext_opts) + end + + for key, limage in pairs(images) do + local range = limage.range + if conceal_on and (range[1] == cursor_row - 1 and not cc_n) then + table.insert(module.private.cleared_at_cursor, key) + module.private.image_api.clear({ limage }) + if limage.extmark_id then + vim.api.nvim_buf_set_extmark(buffer, module.private.extmark_ns, range[1], range[2], { + virt_text = { { "" } }, + }) + end + goto continue + end + module.private.image_api.render({ limage }) + ::continue:: + end + end, +} + +local running_proc = nil +local render_timer = nil +local function render_math() + local buf = vim.api.nvim_get_current_buf() + if not module.private.do_render then + if render_timer then + render_timer:stop() + render_timer:close() + render_timer = nil + end + return + end + + if not render_timer then + render_timer = vim.uv.new_timer() + end + + render_timer:start(module.config.public.debounce_ms, 0, function() + render_timer:stop() + render_timer:close() + render_timer = nil + + if not running_proc then + running_proc = nio.run(function() + nio.scheduler() + module.public.async_math_renderer(buf) + end, function() + module.public.render_inline_math(module.private.math_images[buf] or {}, buf) + running_proc = nil + end) + end + end) +end + +local function clear_at_cursor() + local buf = vim.api.nvim_get_current_buf() + if not module.private.do_render or render_timer then + return + end + + local concealcursor = vim.api.nvim_get_option_value("concealcursor", { win = 0 }) + local mode = vim.api.nvim_get_mode().mode + -- account for concealcursor, ie. don't un-render images when conceal cursor contains "n" unless + -- we're in insert mode. + local cc_and_insert = (concealcursor:match("n") and mode == "i") or not concealcursor:match("n") + + if module.config.public.conceal and cc_and_insert and module.private.math_images[buf] ~= nil then + local cleared = module.private.image_api.clear_at_cursor( + module.private.math_images[buf], + vim.api.nvim_win_get_cursor(0)[1] - 1 + ) + for _, id in ipairs(cleared) do + local limage = module.private.math_images[buf][id] + if limage.extmark_id then + vim.api.nvim_buf_set_extmark(0, module.private.extmark_ns, limage.range[1], limage.range[2], { + id = limage.extmark_id, + end_col = limage.range[4], + conceal = "", + virt_text = { { "", "" } }, + strict = false, + }) + end + end + local to_render = {} + for _, key in ipairs(module.private.cleared_at_cursor) do + if not vim.tbl_contains(cleared, key) then + -- this image was cleared b/c it was at our cursor, and now it should be rendered again + to_render[key] = module.private.math_images[buf][key] + end + end + + local updated_positions = {} + for _, limage in pairs(to_render) do + if limage.extmark_id then + local extmark = vim.api.nvim_buf_get_extmark_by_id( + buf, + module.private.extmark_ns, + limage.extmark_id, + { details = true } + ) + local range = { extmark[1], extmark[2], extmark[3].end_row, extmark[3].end_col } + local new_key = module.private.get_key(range) + updated_positions[new_key] = limage + updated_positions[new_key].range = range + end + end + module.public.render_inline_math(updated_positions, buf) + module.private.cleared_at_cursor = cleared + end +end + +local function enable_rendering() + module.private.do_render = true + render_math() +end + +local function disable_rendering() + module.private.do_render = false + for buf, images in pairs(module.private.math_images) do + module.private.image_api.clear(images) + vim.api.nvim_buf_clear_namespace(buf, module.private.extmark_ns, 0, -1) + end + module.private.math_images = {} +end + +local function toggle_rendering() + if module.private.do_render then + disable_rendering() + else + enable_rendering() + end +end + +local function show_hidden() + local buf = vim.api.nvim_get_current_buf() + if not module.private.do_render then + return + end + + module.private.image_api.render(module.private.math_images[buf] or {}) +end + +local function colorscheme_change() + module.private.image_paths = {} + if module.private.do_render then + disable_rendering() + module.private.math_images = {} + vim.schedule(function() + module.private.foreground = compute_foreground() + enable_rendering() + end) + else + vim.schedule(function() + module.private.foreground = compute_foreground() + end) + end +end + +local event_handlers = { + ["core.neorgcmd.events.math.render.render"] = enable_rendering, + ["core.neorgcmd.events.math.render.enable"] = enable_rendering, + ["core.neorgcmd.events.math.render.disable"] = disable_rendering, + ["core.neorgcmd.events.math.render.toggle"] = toggle_rendering, + ["core.autocommands.events.bufreadpost"] = render_math, + ["core.autocommands.events.bufwinenter"] = show_hidden, + ["core.autocommands.events.cursormoved"] = clear_at_cursor, + ["core.autocommands.events.textchanged"] = render_math, + ["core.autocommands.events.insertleave"] = render_math, + ["core.autocommands.events.insertenter"] = vim.schedule_wrap(clear_at_cursor), + ["core.autocommands.events.colorscheme"] = colorscheme_change, +} + +module.on_event = function(event) + if event.referrer == "core.autocommands" and vim.bo[event.buffer].ft ~= "norg" then + return + end + + return event_handlers[event.type]() +end + +module.events.subscribed = { + ["core.autocommands"] = { + bufreadpost = module.config.public.render_on_enter, + bufwinenter = true, + cursormoved = true, + textchanged = true, + -- textchangedi = true, + insertleave = true, + insertenter = true, + colorscheme = true, + }, + ["core.neorgcmd"] = { + ["math.render.render"] = true, + ["math.render.enable"] = true, + ["math.render.disable"] = true, + ["math.render.toggle"] = true, + }, +} +return module From 487fb9f1f41076057dd9e1127c0d6ae31737191b Mon Sep 17 00:00:00 2001 From: Ben Lubas Date: Mon, 8 Jul 2024 15:27:49 -0400 Subject: [PATCH 2/4] fix(math-renderer): remove `want` table from requirements --- lua/neorg/modules/core/math/renderer/module.lua | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lua/neorg/modules/core/math/renderer/module.lua b/lua/neorg/modules/core/math/renderer/module.lua index 144dc49e9..fb91920f5 100644 --- a/lua/neorg/modules/core/math/renderer/module.lua +++ b/lua/neorg/modules/core/math/renderer/module.lua @@ -41,9 +41,6 @@ module.setup = function() "core.neorgcmd", "core.highlights", }, - wants = { - "core.math.renderer.latex", - }, } end @@ -110,8 +107,9 @@ end module.load = function() local success, image_api = pcall(neorg.modules.get_module, module.config.public.image_renderer) assert(success, "Unable to load image_renderer module") - local ok, math_image_generator = pcall(neorg.modules.get_module, module.config.public.image_generator) + local ok = neorg.modules.load_module(module.config.public.image_generator) assert(ok, "Unable to load image_generator module") + local math_image_generator = neorg.modules.get_module(module.config.public.image_generator) nio = require("nio") From aa41796038f9c795e17caab3bfa97cd70e8c9a39 Mon Sep 17 00:00:00 2001 From: Ben Lubas Date: Mon, 8 Jul 2024 15:27:49 -0400 Subject: [PATCH 3/4] fix(math-renderer): use buffer local timers --- .../modules/core/math/renderer/module.lua | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/lua/neorg/modules/core/math/renderer/module.lua b/lua/neorg/modules/core/math/renderer/module.lua index fb91920f5..585e9f32a 100644 --- a/lua/neorg/modules/core/math/renderer/module.lua +++ b/lua/neorg/modules/core/math/renderer/module.lua @@ -328,35 +328,35 @@ module.public = { end, } -local running_proc = nil -local render_timer = nil +local running_proc = {} +local render_timer = {} local function render_math() local buf = vim.api.nvim_get_current_buf() if not module.private.do_render then - if render_timer then - render_timer:stop() - render_timer:close() - render_timer = nil + if render_timer[buf] then + render_timer[buf]:stop() + render_timer[buf]:close() + render_timer[buf] = nil end return end - if not render_timer then - render_timer = vim.uv.new_timer() + if not render_timer[buf] then + render_timer[buf] = vim.uv.new_timer() end - render_timer:start(module.config.public.debounce_ms, 0, function() - render_timer:stop() - render_timer:close() - render_timer = nil + render_timer[buf]:start(module.config.public.debounce_ms, 0, function() + render_timer[buf]:stop() + render_timer[buf]:close() + render_timer[buf] = nil - if not running_proc then - running_proc = nio.run(function() + if not running_proc[buf] then + running_proc[buf] = nio.run(function() nio.scheduler() module.public.async_math_renderer(buf) end, function() module.public.render_inline_math(module.private.math_images[buf] or {}, buf) - running_proc = nil + running_proc[buf] = nil end) end end) @@ -364,7 +364,7 @@ end local function clear_at_cursor() local buf = vim.api.nvim_get_current_buf() - if not module.private.do_render or render_timer then + if not module.private.do_render or render_timer[buf] then return end From 3fc936cc0d791f8fefacd500f6fde5fc027e3249 Mon Sep 17 00:00:00 2001 From: Ben Lubas Date: Mon, 8 Jul 2024 15:27:49 -0400 Subject: [PATCH 4/4] chore(math-renderer): fix highlight group name + remove nvim version check --- lua/neorg/modules/core/math/renderer/latex/module.lua | 6 ++---- lua/neorg/modules/core/math/renderer/module.lua | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lua/neorg/modules/core/math/renderer/latex/module.lua b/lua/neorg/modules/core/math/renderer/latex/module.lua index 093fc3f72..1c4ae5a8d 100644 --- a/lua/neorg/modules/core/math/renderer/latex/module.lua +++ b/lua/neorg/modules/core/math/renderer/latex/module.lua @@ -1,5 +1,5 @@ --[[ - file: Core-Math-Renderer-LaTeX + file: Math-Renderer-LaTeX title: Convert LaTeX snippets into image files summary: A module that provides images of LaTeX for `core.math.renderer` --- @@ -14,7 +14,7 @@ Requires: - graphicx - `dvipng` executable in path (normally comes with LaTeX) -A highlight group that controls the foreground color of the rendered math: `@norg.rendered.latex`, +A highlight group that controls the foreground color of the rendered math: `@neorg.rendered.math`, configurable in `core.highlights`. It links to `Normal` by default Note, when `'concealcursor'` contains `"n"` This plugin will fail for the time being. @@ -23,8 +23,6 @@ local nio local neorg = require("neorg.core") local module = neorg.modules.create("core.math.renderer.latex") -assert(vim.re ~= nil, "Neovim 0.10.0+ is required for the `core.math.renderer.latex` module!") - module.load = function() nio = require("nio") end diff --git a/lua/neorg/modules/core/math/renderer/module.lua b/lua/neorg/modules/core/math/renderer/module.lua index 585e9f32a..7bf779672 100644 --- a/lua/neorg/modules/core/math/renderer/module.lua +++ b/lua/neorg/modules/core/math/renderer/module.lua @@ -1,5 +1,5 @@ --[[ - file: Core-Math-Renderer + file: Math-Renderer title: Conceal Math ranges with their rendered versions summary: An experimental module for rendering inline math blocks ---