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 does not build on save #2758

Closed
cinerea0 opened this issue Jun 13, 2022 · 4 comments
Closed

Texlab does not build on save #2758

cinerea0 opened this issue Jun 13, 2022 · 4 comments
Labels
C-bug Category: This is a bug

Comments

@cinerea0
Copy link
Contributor

Summary

I'm attempting to build and view compiled Latex documents when I save them. However, despite passing what I believe are identical options to texlab in helix as I use in neovim, documents are not built when using helix.

Reproduction Steps

asciinema recording: https://asciinema.org/a/q9zCJIBH6HUujHKsLfjuqBqfe

The recording doesn't show it, but the document was not compiled and built after writing.

My configurations for neovim and helix are listed below. I used #2063 (comment) as a template for my helix configuration. I did some searching and found latex-lsp/texlab#502 (comment) containing the right way to set these parameters in TOML for kakoune according to the texlab developers, but I'm unsure how to adapt this for helix.

Lua for Neovim
texlab = {
  build = {
    forwardSearchAfter = true,
    onSave = true
  },
  chktex = {
    onEdit = true,
  },
  forwardSearch = {
    executable = 'zathura',
    args = { '--synctex-forward', '%l:1:%f', '%p' }
  },
}
TOML for Helix
[[language]]
name = "latex"

[language.config]
build.forwardSearchAfter = true
build.onSave = true
forwardSearch.executable = "zathura"
forwardSearch.args = [ "--synctex-forward", "%l:1:%f", "%p" ]
chktex.onEdit = true

Helix log

~/.cache/helix/helix.log
2022-06-12T23:47:41.250 helix_lsp::client [INFO] Using custom LSP config: {"build":{"forwardSearchAfter":true,"onSave":true},"chktex":{"onEdit":true},"forwardSearch":{"args":["--synctex-forward","%l:1:%f","%p"],"executable":"zathura"}}
2022-06-12T23:47:41.251 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":false},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"publishDiagnostics":{},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":false}},"window":{"workDoneProgress":true},"workspace":{"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"workspaceFolders":true}},"initializationOptions":{"build":{"forwardSearchAfter":true,"onSave":true},"chktex":{"onEdit":true},"forwardSearch":{"args":["--synctex-forward","%l:1:%f","%p"],"executable":"zathura"}},"processId":11911,"rootUri":null,"workspaceFolders":[]},"id":0}
2022-06-12T23:47:41.253 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"completionProvider":{"resolveProvider":true,"triggerCharacters":["\\","{","}","@","/"," "]},"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentSymbolProvider":true,"executeCommandProvider":{"commands":["texlab.cleanAuxiliary","texlab.cleanArtifacts"]},"foldingRangeProvider":true,"hoverProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"textDocumentSync":{"change":2,"openClose":true,"save":{"includeText":false}},"workspaceSymbolProvider":true},"serverInfo":{"name":"TexLab","version":"4.1.0"}}}
2022-06-12T23:47:41.253 helix_lsp::transport [INFO] <- {"capabilities":{"completionProvider":{"resolveProvider":true,"triggerCharacters":["\\","{","}","@","/"," "]},"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentSymbolProvider":true,"executeCommandProvider":{"commands":["texlab.cleanAuxiliary","texlab.cleanArtifacts"]},"foldingRangeProvider":true,"hoverProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"textDocumentSync":{"change":2,"openClose":true,"save":{"includeText":false}},"workspaceSymbolProvider":true},"serverInfo":{"name":"TexLab","version":"4.1.0"}}
2022-06-12T23:47:41.253 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2022-06-12T23:47:41.253 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"build":{"forwardSearchAfter":true,"onSave":true},"chktex":{"onEdit":true},"forwardSearch":{"args":["--synctex-forward","%l:1:%f","%p"],"executable":"zathura"}}}}
2022-06-12T23:47:41.253 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"tex","text":"\\documentclass[11pt]{article}\n\\usepackage[T1]{fontenc}\n\\usepackage{newpxtext,newpxmath}\n\\usepackage[margin=0.75in]{geometry}\n\n\\begin{document}\n\n\\section{Test}\n\nLorem ipsum yada yada yada.\n\n\\end{document}\n","uri":"file:///home/nemesis/tmp/test.tex","version":0}}}
2022-06-12T23:47:41.253 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"method":"workspace/configuration","params":{"items":[{"section":"texlab"}]}}
2022-06-12T23:47:41.254 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":1,"method":"workspace/configuration","params":{"items":[{"section":"texlab"}]}}
2022-06-12T23:47:41.254 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","result":[null],"id":0}
2022-06-12T23:47:41.254 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","result":[null],"id":1}
2022-06-12T23:47:41.554 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///home/nemesis/tmp/test.tex"}}
2022-06-12T23:47:41.661 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///home/nemesis/tmp/test.tex"}}
2022-06-12T23:47:41.665 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///home/nemesis/tmp/test.tex"}}
2022-06-12T23:47:41.665 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///home/nemesis/tmp/test.tex"}}
2022-06-12T23:47:43.981 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didSave","params":{"textDocument":{"uri":"file:///home/nemesis/tmp/test.tex"}}}
2022-06-12T23:47:45.586 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"shutdown","params":null,"id":1}
2022-06-12T23:47:45.586 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":1,"result":null}
2022-06-12T23:47:45.587 helix_lsp::transport [INFO] <- null
2022-06-12T23:47:45.587 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"exit","params":null}

Platform

Linux

Terminal Emulator

foot 1.12.1

Helix Version

helix 22.05

@cinerea0 cinerea0 added the C-bug Category: This is a bug label Jun 13, 2022
@the-mikedavis
Copy link
Member

It's odd that the kak-lsp config is so different from nvim's. Maybe nvim is using a plugin to do the building?

Kak-lsp's

[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

translated to helix's config:

# ~/.config/helix/languages.toml
[[language]]
name = "latex"

[language.config.build]
executable = "latexmk"
args = ["-pdf", "-interaction=nonstopmode", "-synctex=1", "%f"]
onSave = true

[language.config.chktex]
onOpenAndSave = true
onEdit = true

Could you give that a try and see if it invokes latexmk?

@cinerea0
Copy link
Contributor Author

cinerea0 commented Jun 13, 2022

Just tried it, and it does not invoke latexmk. Based on helix's log output it looks like the values are being deserialized and passed to texlab in the form it wants, but for whatever reason it's not running external commands. Could this be a texlab bug?

@Triton171
Copy link
Contributor

I use Helix with TexLab and build-on-save works for me. I think you need to replace language.config.build with language.config.texlab.build, since TexLab only seems to search that section of the config. Here's my config:

[[language]]
name = "latex"
scope = "source.tex"
injection-regex = "tex"
file-types = ["tex"]
roots = []
comment-token = "%"
language-server = { command = "texlab" }
config = { texlab = { build = { onSave = true } } }
indent = { tab-width = 4, unit = "\t" }

I think most of it is redundant with the default languages.toml, just ignore that.

@cinerea0
Copy link
Contributor Author

@Triton171, thank you so much! Using your configuration as a guide, I was able to set my configuration to match what I have in neovim. It's a bit awkward, but that's TOML's fault, not helix's.

[[language]]
name = "latex"
config = { texlab = { build = { onSave = true, forwardSearchAfter = true }, forwardSearch = { executable = "zathura", args = [ "--synctex-forward", "%l:1:%f", "%p" ] }, chktex = { onEdit = true } } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

3 participants