texlab
texlab copied to clipboard
Build On Save
I've found this https://gitanswer.com/build-on-save-not-working-in-version-3-0-0-897906002
and I'm experiencing that setting "texlab.build.onSave" = true
in kak-lsp
doesn't cause an automatic build.
Is build on save deprecated and might it be reintroduced?
docs/options.md still lists "texlab.build.onSave", that's why I tried it.
Thanks for the report. The setting texlab.build.onSave
is already reintroduced (see the Changelog for more information). Can you share your full texlab
config and a log file (texlab -vvvv --log-file /some/path/texlab.log
) please to help diagnose the issue?
I'm using texlab in kakoune via the kak-lsp plugin.
I added the keys
[language.latex]
filetypes = ["latex"]
roots = [".tex",".git", ".hg"]
command = "texlab"
settings_section = "texlab"
[language.latex.settings.texlab]
"texlab.build.executable" = "latexmk"
"texlab.build.args" = ["-pdf", "-interaction=nonstopmode", "-synctex=1", "%f"]
"texlab.build.onSave" = true
"texlab.chktex.onOpenAndSave" = true
"texlab.chktex.onEdit" = true
to the config file ~/.config/kak-lsp/kak-lsp.toml
and added the necessary config to enable LSP features and linting from texlab to the config for kakoune. As that might very well be a kak-lsp only issue I understand if this is closing or I am redirected.
As I'm starting texlab by means of kak-lsp, kak-lsp is responsible for logging and produced a log like that on an example file
\documentclass{scrartcl}
\begin{document}
\def\x{\relax}
\dfkj
\end{document}
where an empty line is added before the erroneous macro before saving. On startup, latexmk output files already existed.
that's just the log of the texlab server when removing that line again, where no build files are present
Thanks for the logs. I think that texlab
cannot deserialize the configuration response of kak-lsp
correctly. For example, instead of [{"texlab.build.onSave": true}]
, it expects [{"build": {"onSave": true}}]
.
It should work if you change your kak-lsp
configuration:
[language.latex]
filetypes = ["latex"]
roots = [".tex",".git", ".hg"]
command = "texlab"
settings_section = "texlab"
[language.latex.settings.texlab.build]
executable = "latexmk"
args = ["-pdf", "-interaction=nonstopmode", "-synctex=1", "%f"]
onSave = true
[language.latex.settings.texlab.chktex]
onOpenAndSave = true
onEdit = true
Thanks a lot, automatic building works now. However curiously linting on open and diagnostics by latex (as opposed to chktex) doesn't work. Checking the log, that isn't expected though, as the diagnostics are being sent. I suppose the error is at kak-lsp's side there?
The chktex
output is sent via window/logMessage
, which probably means that the user has to open some kind of log buffer in their editor. I guess a faithful conversion to real diagnostics with precise locations is hard because the output is complex. Though maybe there should some kind of indicator of chktex
found errors, I'm not sure.
The chktex output is sent via window/logMessage
The window/logMessage
notifications are from the TeX engine (via latexmk
) and not chktex
. We send those notifications to keep the user updated because the TeX engine can take a long time. After the compilation is done, texlab
sends a list of diagnostics containing the errors in the log file.
The raw chktex
output is not shown to the user. texlab
parses the chktex
output by supplying a custom format to the command line arguments. Looking at this part of the texlab
log file, we can see that the diagnostics originating from chktex
are sent to the client (although there is one redundant notification in between).
DEBUG - < {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"text":"\\documentclass{scrartcl}\n\\begin{document}\n \\def\\x{\\relax}\n \n \\dfkj\n\\end{document}\n"}],"textDocument":{"uri":"file:///home/gtca/a.tex","version":3}}}
DEBUG - (Re)Loading document: file:///home/gtca/a.tex
DEBUG - > {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///home/gtca/a.tex"}}
DEBUG - > {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"1","message":"Command terminated with space.","range":{"end":{"character":10,"line":4},"start":{"character":9,"line":4}},"severity":2,"source":"chktex"}],"uri":"file:///home/gtca/a.tex"}}
DEBUG - < {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"text":"\\documentclass{scrartcl}\n\\begin{document}\n \\def\\x{\\relax}\n\n \\dfkj\n\\end{document}\n"}],"textDocument":{"uri":"file:///home/gtca/a.tex","version":4}}}
yeah, the "Command terminated with space" diagnostic is shown just fine
However, the "Undefined control sequence" isn't, because it stems from the aux file (see the uri field)
Nov 05 19:01:55.822 DEBG From server: {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"message":"Undefined control sequence.","range":{"end":{"character":0,"line":5},"start":{"character":0,"line":5}},"severity":1,"source":"latex"}],"uri":"file:///home/johannes/git/kak-lsp/t/test.aux"}}, module: kak_lsp::language_server_transport:151
Nov 05 19:01:55.822 DEBG From server: {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///home/johannes/git/kak-lsp/t/test.log"}}, module: kak_lsp::language_server_transport:151
Nov 05 19:01:55.822 DEBG From server: {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"1","message":"Command terminated with space.","range":{"end":{"character":6,"line":6},"start":{"character":5,"line":6}},"severity":2,"source":"chktex"}],"uri":"file:///home/johannes/git/kak-lsp/t/test.tex"}}, module: kak_lsp::language_server_transport:151
The window/logMessage notifications are from the TeX engine (via latexmk) and not chktex
got it. The chktex diagnostics work fine already
However, the "Undefined control sequence" isn't, because it stems from the aux file
so when you open the aux file, you'll see the diagnostics. Haven't tested with other editors yet.
Can you try out 1265f89, please? It fixed the issue with the wrong URI on my machine.
Kind of, but after I delete my undefined control sequence and save, the error is sent again (I guess the aux file is stale)