diff --git a/doc/markview.nvim-latex.txt b/doc/markview.nvim-latex.txt index 269e4f43..30219691 100644 --- a/doc/markview.nvim-latex.txt +++ b/doc/markview.nvim-latex.txt @@ -82,61 +82,61 @@ Demo {img:2} ---@param cmd_hl? string Highlight group for the command. ---@return markview.config.latex.commands.opts local operator = function (name, text_pos, cmd_conceal, cmd_hl) - return { - condition = function (item) - return #item.args == 1; - end, - - on_command = function (item) - local symbols = require("markview.symbols"); - - return { - end_col = item.range[2] + (cmd_conceal or 1), - conceal = "", - - virt_text_pos = text_pos or "overlay", - virt_text = { - { symbols.tostring("default", name), cmd_hl or "@keyword.function" } - }, - - hl_mode = "combine" - } - end, - - on_args = { - { - on_before = function (item) - return { - end_col = item.range[2] + 1, - - virt_text_pos = "overlay", - virt_text = { - { "(", "@punctuation.bracket" } - }, - - hl_mode = "combine" - } - end, - - after_offset = function (range) - return { range[1], range[2], range[3], range[4] - 1 }; - end, - - on_after = function (item) - return { - end_col = item.range[4], - - virt_text_pos = "overlay", - virt_text = { - { ")", "@punctuation.bracket" } - }, - - hl_mode = "combine" - } - end - } - } - }; + return { + condition = function (item) + return #item.args == 1; + end, + + on_command = function (item) + local symbols = require("markview.symbols"); + + return { + end_col = item.range[2] + (cmd_conceal or 1), + conceal = "", + + virt_text_pos = text_pos or "overlay", + virt_text = { + { symbols.tostring("default", name), cmd_hl or "@keyword.function" } + }, + + hl_mode = "combine" + } + end, + + on_args = { + { + on_before = function (item) + return { + end_col = item.range[2] + 1, + + virt_text_pos = "overlay", + virt_text = { + { "(", "@punctuation.bracket" } + }, + + hl_mode = "combine" + } + end, + + after_offset = function (range) + return { range[1], range[2], range[3], range[4] - 1 }; + end, + + on_after = function (item) + return { + end_col = item.range[4], + + virt_text_pos = "overlay", + virt_text = { + { ")", "@punctuation.bracket" } + }, + + hl_mode = "combine" + } + end + } + } + }; end commands = { @@ -428,6 +428,7 @@ Demo {img:3} mathbf = { enable = true }, mathbfit = { enable = true }, mathcal = { enable = true }, + mathscr = { enable = true }, mathbfscr = { enable = true }, mathfrak = { enable = true }, mathbb = { enable = true }, diff --git a/lua/markview/config/latex.lua b/lua/markview/config/latex.lua index cf16b893..23bc465e 100644 --- a/lua/markview/config/latex.lua +++ b/lua/markview/config/latex.lua @@ -318,6 +318,7 @@ return { mathbf = { enable = true }, mathbfit = { enable = true }, mathcal = { enable = true }, + mathscr = { enable = true }, mathbfscr = { enable = true }, mathfrak = { enable = true }, mathbb = { enable = true }, diff --git a/lua/markview/symbols.lua b/lua/markview/symbols.lua index 8135811e..c8c46271 100644 --- a/lua/markview/symbols.lua +++ b/lua/markview/symbols.lua @@ -4299,6 +4299,37 @@ symbols.entries = { ["ggcurly"] = "⪼", ["Top"] = "⫪", ["Bot"] = "⫫", + + -- LaTeX2e/amsmath/amssymb commands without a unicode-math name. + ["bigcirc"] = "○", + ["circlearrowleft"] = "↺", + ["circlearrowright"] = "↻", + ["circledS"] = "Ⓢ", + ["dotsb"] = "⋯", + ["dotsc"] = "…", + ["dotsi"] = "⋯", + ["dotsm"] = "⋯", + ["dotso"] = "…", + ["emptyset"] = "∅", + ["enspace"] = " ", + ["gvertneqq"] = "≩︀", + ["hbar"] = "ħ", + ["iff"] = "⟺", + ["impliedby"] = "⟸", + ["implies"] = "⟹", + ["land"] = "∧", + ["ldots"] = "…", + ["lor"] = "∨", + ["lvertneqq"] = "≨︀", + ["nleqslant"] = "⩽̸", + ["nsubseteqq"] = "⫅̸", + ["nsupseteqq"] = "⫆̸", + ["qquad"] = " ", + ["quad"] = " ", + ["thickspace"] = " ", + ["thinspace"] = " ", + ["varsubsetneqq"] = "⊊︀", + ["varsupsetneq"] = "⊋︀", }; --- Maps typst symbol names to the symbol. @@ -6325,6 +6356,10 @@ symbols.fonts = { } } +-- Unicode has a single script alphabet; `\mathscr` & `\mathcal` +-- use the same characters. +symbols.fonts.mathscr = symbols.fonts.mathcal; + ---@param font string ---@param text string ---@return string diff --git a/test/latex.md b/test/latex.md index 3d4ac46b..a8a686c0 100644 --- a/test/latex.md +++ b/test/latex.md @@ -31,6 +31,7 @@ Hello LaTeX! \mathbffrak{Hello LaTeX!} \mathbb{Hello LaTeX!} \mathbfscr{Hello LaTeX!} +\mathscr{Hello LaTeX!} \mathrm{Hello LaTeX!} $$