An neovim plugin for LaTeX, written in Lua. Although it's simple now, I want to make it as powerful as VimTeX one day.
-- lazy.nvim
{"dirichy/latex.nvim",
ft="tex",
config=function()
require("latex").setup()
end
}
treesitter for conceal and snip.
(Not finished)LuaSnip for snip.
(Not finished)nvim-cmp for display desc of snip.
plenary.nvim for compile.
(now only support arara)arara
or latexmk
for compile.
You can config this plugin by
require("latex").setup(opts)
By now, there is only one field opts.conceal.conceal_tbl
can be set manmully.
You can set it as
opts={
conceal={
conceal_tbl={
--To conceal generic_command in math
--highlight is the hightgroup, should begin with "@".
--condition function(Node,source) -> boolean, onlly match afterwards keys when conditon is true.
myfirst_conceal_group = {
{highlight="@mygroup",condition=require("latex.conditions.query").in_math},
["\\test"]="T",
["\\Alpha"]="A",
["\\mathbb{A}"]="A",
}
--To conceal other group, you need to provide query by yourself
--If you don't set highlight, the default highlight is same as group name
--condition=nil means no condition.
--conceal-table and latexconceal are functions defined in latex/conceal/init.lua to do conceal easily.
script = {
{highlight=nil--equal to highlight="@script"
query='((script) @script (#conceal-table? @script)(#latexconceal! @script "script")',
condition=nil}
["_1"]="₁",
}
--There are some condition in require("latex.conditions.query"), and you can set condition mamully.
--you can put query in a file, too.
delim = {
{
highlight="@conceal",
query_file="delete"--will load runtimepath/queries/latex/conceal_delete.scm
}
}
}
}
}
I don't like let my finger leave the main field of keyboard, so I use autosnip construct by pure alphabet. For now I didn't add my LuaSnips in this plugin, but I will add them later.
Almost all of the low-hanging fruit is done as far as concealing;
hard things like using tree-sitter for \'e
to é
are not a priority.
Currently the conceals provided are:
- Greek: things like
\sigma
toσ
- Math: things like
\amalg
to⨿
- Script: superscripts and subscripts
- Delim: things like
\left
and many instances of curly braces. - Font: things like
\mathbb{Z}
toℤ
We can use different colors for different conceal, which make our tex file more readable.
You can add your own concealed commands to the conceal.conceal_tbl
table, see Configuration