Skip to content

feat(latex): high-performance LaTeX-to-Unicode mathematical engine integration via Rust FFI - #530

Open
KpihX wants to merge 6 commits into
OXY2DEV:mainfrom
kpihx-labs:feat/rust-latex-unicode-ffi
Open

KpihX wants to merge 6 commits into
OXY2DEV:mainfrom
kpihx-labs:feat/rust-latex-unicode-ffi

Conversation

@KpihX

@KpihX KpihX commented Sep 20, 2026

Copy link
Copy Markdown

Description

This PR introduces high-performance LaTeX-to-Unicode mathematical conversion support for markview.nvim via a zero-dependency C-ABI FFI layer backed by latex-to-unicode.

Highlights

  • Converts multi-line and inline LaTeX math blocks (738506...738506 and $...$) into crisp, high-fidelity Unicode representations.
  • Supports 200+ mathematical symbols, nested fractions, roots, subscripts/superscripts, binomials, and 2D multi-line matrices/cases.
  • Leverages direct LuaJIT FFI with zero subprocess overhead, ensuring smooth 60 FPS real-time rendering on large Markdown buffers.

Co-authored-by: Ivann H. KAMDEM POUOKAM (KpihX) kapoivha@gmail.com

Copilot AI lite review requested due to automatic review settings September 20, 2026 11:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The wrapper is not integrated, and library-loading edge cases remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Adds a LuaJIT FFI wrapper for Rust-backed LaTeX-to-Unicode conversion in markview.nvim.

Changes:

  • Declares C-ABI bindings and conversion helpers.
  • Searches shared-library paths with fallback behavior.
  • Adds memory cleanup support, but is not yet connected to the existing LaTeX pipeline.
File Description
lua/​markview/​ffi/​math.lua Adds the FFI-based LaTeX conversion bridge.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread lua/markview/ffi/math.lua
void latex_unicode_free(char* ptr);
]]

local M = {}
Comment thread lua/markview/ffi/math.lua
Comment on lines +14 to +18
local home = os.getenv("HOME")
local candidates = {
home .. "/Labs/KpihX-Labs/latex-to-unicode/target/release/liblatex_to_unicode_c_api.so",
home .. "/.local/lib/liblatex_to_unicode_c_api.so",
"/usr/local/lib/liblatex_to_unicode_c_api.so",
Comment thread lua/markview/ffi/math.lua Outdated
end

function M.init()
if lib then return true end
@OXY2DEV

OXY2DEV commented Sep 20, 2026

Copy link
Copy Markdown
Owner

Please explain to me what is the advantage of using this over any other latex renderers.

People are less likely to use a feature if it requires extra steps to set up, which is the whole point of the plugin, to have everything "just work" out of the box without any extra steps.

Anchor virt_lines on the previous visible row and conceal_lines the
math block so Markview no longer stacks ASCII Unicode on top of raw LaTeX.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants