-
Notifications
You must be signed in to change notification settings - Fork 62
LaTeX
Tip
You can find the type definitions in definitions/renderers/latex.lua.
Options that change how
---@type markview.config.latex
latex = {
enable = true,
blocks = {
enable = true,
hl = "MarkviewCode",
pad_char = " ",
pad_amount = 3,
text = " LaTeX ",
text_hl = "MarkviewCodeInfo"
},
commands = {
enable = true,
["boxed"] = {
condition = function (item)
return #item.args == 1;
end,
on_command = {
conceal = ""
},
on_args = {
{
on_before = function (item)
return {
end_col = item.range[2] + 1,
conceal = "",
virt_text_pos = "inline",
virt_text = {
{ " ", "MarkviewPalette4Fg" },
{ "[", "@punctuation.bracket.latex" }
},
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],
conceal = "",
virt_text_pos = "inline",
virt_text = {
{ "]", "@punctuation.bracket" }
},
hl_mode = "combine"
}
end
}
}
},
["frac"] = {
condition = function (item)
return #item.args == 2;
end,
on_command = {
conceal = ""
},
on_args = {
{
on_before = function (item)
return {
end_col = item.range[2] + 1,
conceal = "",
virt_text_pos = "inline",
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],
conceal = "",
virt_text_pos = "inline",
virt_text = {
{ ")", "@punctuation.bracket" },
{ " ÷ ", "@keyword.function" }
},
hl_mode = "combine"
}
end
},
{
on_before = function (item)
return {
end_col = item.range[2] + 1,
conceal = "",
virt_text_pos = "inline",
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],
conceal = "",
virt_text_pos = "inline",
virt_text = {
{ ")", "@punctuation.bracket" },
},
hl_mode = "combine"
}
end
},
}
},
["vec"] = {
condition = function (item)
return #item.args == 1;
end,
on_command = {
conceal = ""
},
on_args = {
{
on_before = function (item)
return {
end_col = item.range[2] + 1,
conceal = "",
virt_text_pos = "inline",
virt_text = {
{ " ", "MarkviewPalette2Fg" },
{ "(", "@punctuation.bracket.latex" }
},
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],
conceal = "",
virt_text_pos = "inline",
virt_text = {
{ ")", "@punctuation.bracket" }
},
hl_mode = "combine"
}
end
}
}
},
["sin"] = operator("sin"),
["cos"] = operator("cos"),
["tan"] = operator("tan"),
["sinh"] = operator("sinh"),
["cosh"] = operator("cosh"),
["tanh"] = operator("tanh"),
["csc"] = operator("csc"),
["sec"] = operator("sec"),
["cot"] = operator("cot"),
["csch"] = operator("csch"),
["sech"] = operator("sech"),
["coth"] = operator("coth"),
["arcsin"] = operator("arcsin"),
["arccos"] = operator("arccos"),
["arctan"] = operator("arctan"),
["arg"] = operator("arg"),
["deg"] = operator("deg"),
["det"] = operator("det"),
["dim"] = operator("dim"),
["exp"] = operator("exp"),
["gcd"] = operator("gcd"),
["hom"] = operator("hom"),
["inf"] = operator("inf"),
["ker"] = operator("ker"),
["lg"] = operator("lg"),
["lim"] = operator("lim"),
["liminf"] = operator("lim inf", "inline", 7),
["limsup"] = operator("lim sup", "inline", 7),
["ln"] = operator("ln"),
["log"] = operator("log"),
["min"] = operator("min"),
["max"] = operator("max"),
["Pr"] = operator("Pr"),
["sup"] = operator("sup"),
["sqrt"] = function ()
local symbols = require("markview.symbols");
return operator(symbols.entries.sqrt, "inline", 5);
end,
["lvert"] = function ()
local symbols = require("markview.symbols");
return operator(symbols.entries.vert, "inline", 6);
end,
["lVert"] = function ()
local symbols = require("markview.symbols");
return operator(symbols.entries.Vert, "inline", 6);
end,
},
escapes = {
enable = true
},
fonts = {
enable = true,
default = {
enable = true,
hl = "MarkviewSpecial"
},
mathbf = { enable = true },
mathbfit = { enable = true },
mathcal = { enable = true },
mathbfscr = { enable = true },
mathfrak = { enable = true },
mathbb = { enable = true },
mathbffrak = { enable = true },
mathsf = { enable = true },
mathsfbf = { enable = true },
mathsfit = { enable = true },
mathsfbfit = { enable = true },
mathtt = { enable = true },
mathrm = { enable = true },
},
inlines = {
enable = true,
padding_left = " ",
padding_right = " ",
hl = "MarkviewInlineCode"
},
parenthesis = {
enable = true,
},
subscripts = {
enable = true,
hl = "MarkviewSubscript"
},
superscripts = {
enable = true,
hl = "MarkviewSuperscript"
},
symbols = {
enable = true,
hl = "MarkviewComment"
},
texts = {
enable = true
},
},
- type:
boolean
default:true
Enables LaTeX previewing.
Changes how LaTeX blocks are shown.
---@type markview.config.latex.blocks
blocks = {
enable = true,
hl = "MarkviewCode",
pad_amount = 3,
pad_char = " ",
text = " LaTeX ",
text_hl = "MarkviewCodeInfo"
},
- type:
boolean
default:true
Self-explanatory.
- type:
string
default:"MarkviewCode"
Highlight group used as the background.
- type:
integer
default:3
Number of pad_char to add before each line.
- type:
string
default:" "
Character used as padding the lines.
- type:
string
default:" LaTeX "
Text to show on the top right side of the block.
- type:
string
default:" LaTeX "
Highlight group for text.
Changes how LaTeX commands are shown.
Important
operator()
can be found here.
---@type markview.config.latex.commands
commands = {
enable = true,
["boxed"] = {
condition = function (item)
return #item.args == 1;
end,
on_command = {
conceal = ""
},
on_args = {
{
on_before = function (item)
return {
end_col = item.range[2] + 1,
conceal = "",
virt_text_pos = "inline",
virt_text = {
{ " ", "MarkviewPalette4Fg" },
{ "[", "@punctuation.bracket.latex" }
},
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],
conceal = "",
virt_text_pos = "inline",
virt_text = {
{ "]", "@punctuation.bracket" }
},
hl_mode = "combine"
}
end
}
}
},
["frac"] = {
condition = function (item)
return #item.args == 2;
end,
on_command = {
conceal = ""
},
on_args = {
{
on_before = function (item)
return {
end_col = item.range[2] + 1,
conceal = "",
virt_text_pos = "inline",
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],
conceal = "",
virt_text_pos = "inline",
virt_text = {
{ ")", "@punctuation.bracket" },
{ " ÷ ", "@keyword.function" }
},
hl_mode = "combine"
}
end
},
{
on_before = function (item)
return {
end_col = item.range[2] + 1,
conceal = "",
virt_text_pos = "inline",
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],
conceal = "",
virt_text_pos = "inline",
virt_text = {
{ ")", "@punctuation.bracket" },
},
hl_mode = "combine"
}
end
},
}
},
["vec"] = {
condition = function (item)
return #item.args == 1;
end,
on_command = {
conceal = ""
},
on_args = {
{
on_before = function (item)
return {
end_col = item.range[2] + 1,
conceal = "",
virt_text_pos = "inline",
virt_text = {
{ " ", "MarkviewPalette2Fg" },
{ "(", "@punctuation.bracket.latex" }
},
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],
conceal = "",
virt_text_pos = "inline",
virt_text = {
{ ")", "@punctuation.bracket" }
},
hl_mode = "combine"
}
end
}
}
},
["sin"] = operator("sin"),
["cos"] = operator("cos"),
["tan"] = operator("tan"),
["sinh"] = operator("sinh"),
["cosh"] = operator("cosh"),
["tanh"] = operator("tanh"),
["csc"] = operator("csc"),
["sec"] = operator("sec"),
["cot"] = operator("cot"),
["csch"] = operator("csch"),
["sech"] = operator("sech"),
["coth"] = operator("coth"),
["arcsin"] = operator("arcsin"),
["arccos"] = operator("arccos"),
["arctan"] = operator("arctan"),
["arg"] = operator("arg"),
["deg"] = operator("deg"),
["det"] = operator("det"),
["dim"] = operator("dim"),
["exp"] = operator("exp"),
["gcd"] = operator("gcd"),
["hom"] = operator("hom"),
["inf"] = operator("inf"),
["ker"] = operator("ker"),
["lg"] = operator("lg"),
["lim"] = operator("lim"),
["liminf"] = operator("lim inf", "inline", 7),
["limsup"] = operator("lim sup", "inline", 7),
["ln"] = operator("ln"),
["log"] = operator("log"),
["min"] = operator("min"),
["max"] = operator("max"),
["Pr"] = operator("Pr"),
["sup"] = operator("sup"),
["sqrt"] = function ()
local symbols = require("markview.symbols");
return operator(symbols.entries.sqrt, "inline", 5);
end,
["lvert"] = function ()
local symbols = require("markview.symbols");
return operator(symbols.entries.vert, "inline", 6);
end,
["lVert"] = function ()
local symbols = require("markview.symbols");
return operator(symbols.entries.Vert, "inline", 6);
end,
},
- type:
boolean
default:true
Self-explanatory.
Configuration for \string{...}
.
---@type markview.config.latex.commands.opts
["string"] = {
condition = function () return true; end,
command_offset = function (range)
return range;
end,
on_command = {},
on_arge = {},
},
- type:
fun(item: markview.parsed.latex.commands): boolean
See also,
Additional condition(s) for this command(e.g. specific number of arguments).
- type:
fun(range: integer[]): integer[]
See also,
Modifies the range of this command.
- type:
table
Configuration for the extmark added to the command text. See {opts}
in :h nvim_buf_set_extmark()
.
- type:
table[]
Configuration for the extmark added to the each argument. See {opts}
in :h nvim_buf_set_extmark()
.
---@type markview.config.latex.commands.arg_opts[]
on_args = {
{
after_offset = function (range)
return { range[1], range[2], range[3], range[4] - 1 };
end,
before_offset = nil,
content_offset = nil,
condition = nil,
on_after = function (item)
return {
end_col = item.range[4],
conceal = "",
virt_text_pos = "inline",
virt_text = {
{ ")", "@punctuation.bracket" }
},
hl_mode = "combine"
}
end,
on_before = function (item)
return {
end_col = item.range[2] + 1,
conceal = "",
virt_text_pos = "inline",
virt_text = {
{ " ", "MarkviewPalette2Fg" },
{ "(", "@punctuation.bracket.latex" }
},
hl_mode = "combine"
}
end,
on_content = nil,
}
}
- type:
fun(range: markview.parsed.range): markview.parsed.range
Changes the range of }
of an argument.
- type:
fun(range: markview.parsed.range): markview.parsed.range
Changes the range of {
of an argument.
- type:
fun(range: markview.parsed.range): markview.parsed.range
Changes the range of the text between {}
of an argument.
- type:
fun(markview.parsed.latex.commands.arg): boolean
Unused.
- type:
table
Configuration for the extmark added to }
(range is affected by after_offset. See {opts}
in :h nvim_buf_set_extmark()
.
- type:
table
Configuration for the extmark added to {
(range is affected by before_offset. See {opts}
in :h nvim_buf_set_extmark()
.
- type:
table
Configuration for the extmark added to the text of the argument(range is affected by content_offset. See {opts}
in :h nvim_buf_set_extmark()
.
- type:
{ enable: boolean }
Removes \
from escaped characters in previews
- type:
boolean
default:true
Self-explanatory.
Note
You need a modern font(font that support math symbols) for fonts to appear correctly!
Changes how fonts are shown in LaTeX.
---@type markview.config.latex.fonts
fonts = {
enable = true,
default = {
enable = true,
hl = "MarkviewSpecial"
},
mathbf = { enable = true },
mathbfit = { enable = true },
mathcal = { enable = true },
mathbfscr = { enable = true },
mathfrak = { enable = true },
mathbb = { enable = true },
mathbffrak = { enable = true },
mathsf = { enable = true },
mathsfbf = { enable = true },
mathsfit = { enable = true },
mathsfbfit = { enable = true },
mathtt = { enable = true },
mathrm = { enable = true },
},
- type:
{ enable: boolean, hl?: string }
Default configuration for fonts.
- type:
boolean
default:true
Self-explanatory.
- type:
string
default:"MarkviewSpecial"
Highlight group for this font.
- type:
{ enable: boolean, hl?: string }
Configuration for \mathbf{}
. Same as default.
- type:
{ enable: boolean, hl?: string }
Configuration for \mathbfit{}
. Same as default.
- type:
{ enable: boolean, hl?: string }
Configuration for \mathcal{}
. Same as default.
- type:
{ enable: boolean, hl?: string }
Configuration for \mathbfscr{}
. Same as default.
- type:
{ enable: boolean, hl?: string }
Configuration for \mathfrak{}
. Same as default.
- type:
{ enable: boolean, hl?: string }
Configuration for \mathbb{}
. Same as default.
- type:
{ enable: boolean, hl?: string }
Configuration for \mathbffrak{}
. Same as default.
- type:
{ enable: boolean, hl?: string }
Configuration for \mathsf{}
. Same as default.
- type:
{ enable: boolean, hl?: string }
Configuration for \mathsfbf{}
. Same as default.
- type:
{ enable: boolean, hl?: string }
Configuration for \mathsfit{}
. Same as default.
- type:
{ enable: boolean, hl?: string }
Configuration for \mathsfbfit{}
. Same as default.
- type:
{ enable: boolean, hl?: string }
Configuration for \mathtt{}
. Same as default.
- type:
{ enable: boolean, hl?: string }
Configuration for \mathrm{}
. Same as default.
Configuration for inline maths. See how inline elements are configured.
- type:
{ enable: boolean }
Hides {}
.
- type:
boolean
default:true
Self-explanatory.
Configuration for subscripts(_
& _{}
).
---@type markview.config.latex.subscripts
subscripts = {
enable = true,
hl = "MarkviewSubscript"
},
- type:
boolean
default:true
Self-explanatory.
- type:
string
default:"MarkviewSubscript"
Highlight group for subscript text.
Configuration for subscripts(^
& ^{}
). Same as subscripts.
Configuration for math symbols.
---@type markview.config.latex.symbols
symbols = {
enable = true,
hl = "MarkviewComment"
},
- type:
boolean
default:true
Self-explanatory.
- type:
string
default:"MarkviewComment"
Highlight group for symbols.
- type:
{ enable: boolean }
Hides command from \text{}
.
- type:
boolean
default:true
Self-explanatory.