Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
111 changes: 56 additions & 55 deletions doc/markview.nvim-latex.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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 },
Expand Down
1 change: 1 addition & 0 deletions lua/markview/config/latex.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
35 changes: 35 additions & 0 deletions lua/markview/symbols.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/latex.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Hello LaTeX!
\mathbffrak{Hello LaTeX!}
\mathbb{Hello LaTeX!}
\mathbfscr{Hello LaTeX!}
\mathscr{Hello LaTeX!}
\mathrm{Hello LaTeX!}
$$

Expand Down
Loading