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

Build On Save #502

Closed
Abraxas-Knister opened this issue Nov 1, 2021 · 12 comments · Fixed by #823
Closed

Build On Save #502

Abraxas-Knister opened this issue Nov 1, 2021 · 12 comments · Fixed by #823

Comments

@Abraxas-Knister
Copy link

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?

@Abraxas-Knister
Copy link
Author

docs/options.md still lists "texlab.build.onSave", that's why I tried it.

@pfoerster
Copy link
Member

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?

@Abraxas-Knister
Copy link
Author

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.

@Abraxas-Knister
Copy link
Author

Abraxas-Knister commented Nov 1, 2021

that's just the log of the texlab server when removing that line again, where no build files are present

@pfoerster
Copy link
Member

pfoerster commented Nov 1, 2021

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

@Abraxas-Knister
Copy link
Author

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?

@krobelus
Copy link
Contributor

krobelus commented Nov 5, 2021

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.

@pfoerster
Copy link
Member

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}}}

@krobelus
Copy link
Contributor

krobelus commented Nov 5, 2021

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

@krobelus
Copy link
Contributor

krobelus commented Nov 5, 2021

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.

pfoerster added a commit that referenced this issue Nov 5, 2021
@pfoerster
Copy link
Member

Can you try out 1265f89, please? It fixed the issue with the wrong URI on my machine.

@krobelus
Copy link
Contributor

krobelus commented Nov 6, 2021

Kind of, but after I delete my undefined control sequence and save, the error is sent again (I guess the aux file is stale)

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Apr 27, 2023
## [5.5.0] - 2023-04-16

### Added

- Allow optionally passing cursor position to `textDocument/build` request for use in forward search after building.
  Previously, the server had to guess the cursor position ([#475](latex-lsp/texlab#475))
- Add experimental `texlab.experimental.citationCommands` setting to allow extending the list of citation commands
  ([#832](latex-lsp/texlab#832))
- Add support for escaping placeholders in build arguments similar to forward search
- Allow configuring completion matching algorithm ([#872](latex-lsp/texlab#872))

### Fixed

- Fix regression introduced in `v5.4.2` involving `texlab.cleanArtifacts` command.

## [5.4.2] - 2023-04-11

### Fixed

- Fix memory leak when editing documents over a long time ([#856](latex-lsp/texlab#856))
- Fix parsing parentheses in file paths ([#874](latex-lsp/texlab#874))

## [5.4.1] - 2023-03-26

### Fixed

- Do not return symbols with empty names (e. g. sections without name) ([#870](latex-lsp/texlab#870))
- Repair `textDocument/formatting` request ([#871](latex-lsp/texlab#871))

## [5.4.0] - 2023-03-12

### Added

- Add experimental settings to allow extending the list of special environments:
  - `texlab.experimental.mathEnvironments`
  - `texlab.experimental.enumEnvironments`
  - `texlab.experimental.verbatimEnvironments`
- Add `texlab.changeEnvironment` workspace command ([#849](latex-lsp/texlab#849))
- Add `texlab.showDependencyGraph` workspace command

### Changed

- Do not show caption or section names in label inlay hints ([#858](latex-lsp/texlab#858))
- Include more user-defined commands in command completion

### Fixed

- Parse nested `\iffalse` blocks correctly ([#853](latex-lsp/texlab#853))
- Parse commands with multi-byte characters correctly ([#857](latex-lsp/texlab#857))
- Fix checking whether a document can be a root file

## [5.3.0] - 2023-02-25

### Added

- Allow filtering `textDocument/documentSymbols` using regular expressions specified via
  `texlab.symbols.allowedPatterns` and `texlab.symbols.ignoredPatterns`
  ([#851](latex-lsp/texlab#851))

### Fixed

- Do not use percent-encoded path when searching for PDF files during forward search
  ([#848](latex-lsp/texlab#848))
- Always return an empty list of code actions instead of returning "method not found" ([#850](latex-lsp/texlab#850))

## [5.2.0] - 2023-01-29

### Added

- Include line numbers in build warnings when available ([#840](latex-lsp/texlab#840))
- Add `none` formatter to `texlab.latexFormatter` and `texlab.bibtexFormatter` options
  to allow disabling formatting ([#846](latex-lsp/texlab#846))

### Fixed

- Concatenate more than two lines of maximum length in build diagnostics ([#842](latex-lsp/texlab#842))
- Apply the correct range of references to labels when renaming ([#841](latex-lsp/texlab#841))
- Use `document` environment to detect root file instead of `\documentclass` ([#845](latex-lsp/texlab#845))

## [5.1.0] - 2023-01-21

### Added

- Allow manually overriding the root directory using a `texlabroot`/`.texlabroot` marker file.
  See the wiki for more information.
  ([#826](latex-lsp/texlab#826), [#838](latex-lsp/texlab#838))

### Deprecated

- Deprecate `texlab.rootDirectory` setting in favor of `.texlabroot` files

### Fixed

- Do not use `.git`, `.chktexrc`, `.latexmkrc` files/directories to determine the root directory
  ([#826](latex-lsp/texlab#826))
- Fix building documents without an explicit root directory ([#837](latex-lsp/texlab#837))

## [5.0.0] - 2022-12-29

### Changed

- _BREAKING_: `texlab.rootDirectory` is now used as the folder path from which the compiler is executed
  relative to the main document. By default it is equal to `"."`. For more information, please visit the wiki.
- Improve performance of completion by a huge margin due to a faster filtering method used internally
- Do not discover project files beyond the provided workspace folders
- Try to guess the root directory by checking for files such as `.latexmkrc` or `Tectonic.toml` if `texlab.rootDirectory` is not set

### Fixed

- Update positions of reported build diagnostics when editing the affected line
- Do not treat links to files as bidirectional by default. This prevents issues where `texlab` ends up compiling the wrong file
  in projects with shared files ([#806](latex-lsp/texlab#806), [#757](latex-lsp/texlab#757), [#679](latex-lsp/texlab#679))
- Fix coverage of directories which need to be watched for changes ([#502](latex-lsp/texlab#502), [#491](latex-lsp/texlab#491))
- Resolve links of the `import` package correctly
- Use `filterText` of completion items when filtering internally ([#829](latex-lsp/texlab#829))

## [4.3.2] - 2022-11-20

### Fixed

- Do not try to run the TeX engine on package files and fail the build instead ([#801](latex-lsp/texlab#801))
- Handle URIs with URL-encoded drive letters on Windows ([#802](latex-lsp/texlab#802))
- Parse BibTeX entries with unbalanced quotes correctly ([#809](latex-lsp/texlab#809))
- Provide completion for more acronym commands ([#813](latex-lsp/texlab#813))
- Fix parsing acronym definitions ([#813](latex-lsp/texlab#813))

## [4.3.1] - 2022-10-22

### Fixed

- Do not crash with a stack overflow when trying to load packages with many internal dependencies ([#793](latex-lsp/texlab#793))
- Normalize drive letters of all document URIs
- Fix parsing commands that take file paths as arguments ([#789](latex-lsp/texlab#789))
- Use the correct working directory and command line arguments when calling `latexindent` ([#645](latex-lsp/texlab#645))
- Fix publishing to CTAN

## [4.3.0] - 2022-09-25

### Added

- Add inlay hints for `\label{...}` ([#753](latex-lsp/texlab#753))

### Fixed

- Improve accuracy of the error locations reported by the TeX engine ([#738](latex-lsp/texlab#738))
- Reduce number of false positive errors reported by `texlab` ([#745](latex-lsp/texlab#745))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants