Formatting - rzukic/zed-latex GitHub Wiki
The Zed docs contain generic help for formatting. Formatting is performed by default on save, which can be disabled with:
{
"languages": {
"LaTeX": {
"format_on_save": "off"
}
}
}
Either way, formatting can also be triggered manually from the command palette.
Formatting with latexindent
There are two options for using latexindent
for formatting LaTeX files, either configuring zed to do so directly, or to do so indirectly through texlab
.
directly through zed
{
"languages": {
"LaTeX": {
"formatter": {
"external": {
"command": "latexindent", // or choose specific path
"arguments": ["--modifylinebreaks"] // control behaviour with flags
}
}
}
}
}
[!WARNING] When zed calls formatters, it runs the formatting through STDIN/STDOUT unlike
texlab
. In particular, the--local
flag does not behave as intended this way in older versions of latexindent (consider updating).
via texlab
{
"languages": {
"LaTeX": {
"formatter": "language_server"
}
},
"lsp": {
"texlab": {
"settings": {
"texlab": {
"latexFormatter": "latexindent", // default value (this line not necessary)
"latexindent": {
// instead of explicitly setting CLI args directly, configure behaviour here
"modifyLineBreaks": true,
"local": "path/to/config",
"replacement": null // place for flags like -rr -rv -r
}
}
}
}
}
}
[!WARNING] Via texlab, there is no way to specify a path for the
latexindent
executable to used, it must be on PATH. Consider the previous method.
Formatting with prettier
Alternatively, Zed's inbuilt prettier
can be used with a LaTeX plugin for formatting with the following setting:
{
"languages": {
"LaTeX": {
"formatter": "prettier"
}
}
}
[!NOTE] The formatting with
prettier
is significantly more opinionated thanlatexindent
.