Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Texlab: No (error) diagnostics after Build Error #551

Closed
coxackie opened this issue Jan 7, 2021 · 11 comments
Closed

Texlab: No (error) diagnostics after Build Error #551

coxackie opened this issue Jan 7, 2021 · 11 comments
Labels
bug Something isn't working

Comments

@coxackie
Copy link

coxackie commented Jan 7, 2021

Yet another texlab issue... latest nightly nvim and latest lspconfig, although these do not matter for the issue I am going to describe.

To reproduce, create a minimal (wrong) latex file and save:

\documentclass{article}
\begin{documen}
  blah blah...
\end{document}

Note how "t" is missing from \begin{documen}. Now, :TexlabBuild will report Build Error as it should. But, :lua print(vim.lsp.diagnostic.get_count(0, 'Error')) gives 0, instead of 1.

I search and found this: latex-lsp/texlab#339. It is clearly texlab's issue. But, it says there that "you need to trigger another request or notification for texlab to pick up the changes". Not sure what this entails (evidently, it should parse the previously produced log file for the errors), but the texlab extension of vs-code seems to manage with it. I could not understand what the JS code does.

Would it be possible somehow to "trigger another request or notification for texlab" in case of build error in the build function in order to pick up the errors?

As an aside, it certainly does not help in debugging a tex document that latex.lint.onSave is not set to true in the default configs in texlab.lua, as is done here. At least if this is set, you can see some warnings from the linting side, but of course this is not the same as getting the exact error from building. On the other hand, I understand that chktex can be annoying with all the warnings it produces, and maybe this is why latex.lint.onSave is not defined in texlab.lua.

@coxackie coxackie added the bug Something isn't working label Jan 7, 2021
@mjlbach
Copy link
Contributor

mjlbach commented Jan 7, 2021

Thanks for the report. texlab should report compile errors by reading the log file. Where is the log file located (relative to the tex file)? Note that you need to trigger another request or notification for texlab to pick up the changes. This behavior will be fixed with the next version.

This seems low priority to me given a fix is incoming. The time/complexity to implement a texlab specific workaround for a bug they are fixing just seems like a suboptimal use of time. The error is almost certainly dumped to stderr, not sent via something we have access to via handler, so you'd have to parse the log dumped from all language servers to lsp.log, which is going to be messy, buggy, and something I wouldn't support merging. I don't know what you mean by trigger a request, does typing a comment fix the issue? (sends textDocumentDidChange)

As an aside, it certainly does not help in debugging a tex document that latex.lint.onSave is not set to true in the default configs in texlab.lua, as is done here. At least if this is set, you can see some warnings from the linting side, but of course this is not the same as getting the exact error from building. On the other hand, I understand that chktex can be annoying with all the warnings it produces, and maybe this is why latex.lint.onSave is not defined in texlab.lua.

Maybe @clason has an opinion as to the defaults. I don't know why the defaults are as they are, but it's incredibly easy for users to override them.

@coxackie
Copy link
Author

coxackie commented Jan 7, 2021

This seems low priority to me given a fix is incoming. The time/complexity to implement a texlab specific workaround for a bug they are fixing just seems like a suboptimal use of time. The error is almost certainly dumped to stderr, not sent via something we have access to via handler, so you'd have to parse the log dumped from all language servers to lsp.log, which is going to be messy, buggy, and something I wouldn't support merging. I don't know what you mean by trigger a request, does typing a comment fix the issue? (sends textDocumentDidChange)

I understand it is low priority, but it is also not clear when "the new version" of texlab will appear - could be anything. Also, "trigger a request" was not my wording, but pfoerster's one from latex-lsp/texlab#339. I am also unsure what it means exactly, but we could ask.

As an aside, it certainly does not help in debugging a tex document that latex.lint.onSave is not set to true in the default configs in texlab.lua, as is done here. At least if this is set, you can see some warnings from the linting side, but of course this is not the same as getting the exact error from building. On the other hand, I understand that chktex can be annoying with all the warnings it produces, and maybe this is why latex.lint.onSave is not defined in texlab.lua.

Maybe @clason has an opinion as to the defaults. I don't know why the defaults are as they are, but it's incredibly easy for users to override them.

Certainly, I have overridden it myself, but it could be hard for someone to discover that this could be changed if it does not even appear in the defaults. I only discovered it in https://texlab.netlify.app/docs/reference/configuration.

@mjlbach
Copy link
Contributor

mjlbach commented Jan 7, 2021

I asked, so we'll see what happens. We already link to https://texlab.netlify.app/docs/reference/configuration in CONFIG.md, so I'm not sure what else we can do

@coxackie
Copy link
Author

coxackie commented Jan 7, 2021

Many thanks for being so helpful and proactive. And apologies for not having noticed that https://texlab.netlify.app/docs/reference/configuration appears in CONFIG.md - my bad.

@clason
Copy link
Member

clason commented Jan 7, 2021

My (strong) opinion is that linting should be opt-in; especially for something as opinionated as chktex. (It'll be different if/when texlab implements its own, more targeted, linting: latex-lsp/texlab#323).

(On another note, I don't find the build errors really useful, either, since for more complex documents, they tend to show up miles from where the actual errors are -- this is not texlab's fault, of course, but an issue with how TeX operates. YMMV.)

@coxackie
Copy link
Author

coxackie commented Jan 7, 2021

@clason I agree about chktex. I would not go to such length to say that build errors are not useful - it is certainly better to have them than not when something happens. This is why I am more concerned about those, rather than linting.

@coxackie
Copy link
Author

coxackie commented Jan 7, 2021

Update: if one uses tectonic instead of latexmk, there is in fact error parsing. Not sure what their difference is, but at least this is a workaround for the moment.

@mjlbach
Copy link
Contributor

mjlbach commented Jan 7, 2021

I'm going to close this, as it is an upstream bug, but I have reached out to the texlab people, and if I hear back and there is a convenient workaround I will file a PR.

@mjlbach mjlbach closed this as completed Jan 7, 2021
@coxackie
Copy link
Author

coxackie commented Jan 7, 2021

thanks - as I mentioned, I now use tectonic and all is good. I now have no problem waiting for an update to texlab. Anyway, in case anyone complains about this, just send them here.

@alok
Copy link

alok commented Apr 14, 2021

@coxackie do you have the config for how you set up tectonic?

@coxackie
Copy link
Author

@alok no, I went to lualatex eventually, as I had the whole texlive installed anyway. But, that being, said, I just followed the suggestion of options here (of course, you need to adapt this to lua).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants