Skip to content

saadndm/mathlive.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mathlive.nvim

Live math previews as images inside Neovim.

Features

  • Replaces source math with rendered images seamlessly inside Neovim.
  • Low latency preview that updates live while typing.
  • Supports Typst in markdown with $inline$ or $$display$$ blocks.

Table of Contents

Requirements

  • Neovim >= 0.11
  • Typst
  • Tree-sitter with markdown, markdown_inline, and latex parsers

Supported Terminals

Unsupported Terminals

Installation

mathlive.nvim auto-initializes with sensible defaults. No setup() call is required unless you want to change the default configuration.

vim.pack

vim.pack.add({
  "https://github.com/saadndm/mathlive.nvim",
})

lazy.nvim

return {
  "saadndm/mathlive.nvim",
  lazy = false, -- the plugin lazy-loads itself
};

Configuration

require("mathlive").setup({
  -- Filetypes where mathlive should attach.
  -- Set to {} to disable automatic attachment.
  filetypes = { "markdown" },

  -- Formula foreground color.
  -- If empty, falls back to the highlight groups:
  -- @markup.math.latex, Special or Normal, in that order.
  color_hex = "", -- Example: "#ffffff"

  -- Pixel density used when Typst renders PNGs.
  ppi = 300,

  -- Typst code inserted before each formula.
  -- Use this to customize how Typst renders math.
  preamble = [[]],

  -- Multiplier for formula size relative to terminal cell height.
  -- 1.0 makes rendered text roughly match Neovim's text size.
  text_scale = 1.0,
})

Compatibility

require("markview").setup({
  preview = {
    enable_hybrid_mode = true,
    linewise_hybrid_mode = false,
    debounce = 1,
    modes = { "n", "i", "v", "c" },
    hybrid_modes = { "n", "i", "v", "c" },
    callbacks = {
      on_enable = function (_, win)
        vim.wo[win].conceallevel = 3
        vim.wo[win].concealcursor = "nvic"
      end,
      on_mode_change = function (_, win)
        vim.wo[win].conceallevel = 3
        vim.wo[win].concealcursor = "nvic"
      end,
      on_hybrid_enable = function (_, win)
        vim.wo[win].conceallevel = 3
        vim.wo[win].concealcursor = "nvic"
      end
    }
  },
  typst = {
    math_blocks = { enable = false },
    math_spans = { enable = false },
    symbols = { enable = false },
    code_blocks = { enable = false },
    superscripts = { enable = false },
    subscripts = { enable = false },
  },
  latex = {
    blocks = { enable = false },
    inlines = { enable = false },
    symbols = { enable = false },
    superscripts = { enable = false },
    subscripts = { enable = false },
    commands = { enable = false },
    fonts = { enable = false },
  },
  })
require("render-markdown").setup({
  win_options = {
    concealcursor = { rendered = "nvic" }
  },
  latex = { enabled = false }
})

WIP

Acknowledgements

About

Live math previews as images inside Neovim.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors