ROCKTAKEY / lsp-latex

Emacs lsp-mode client for LaTeX, on texlab.
GNU General Public License v3.0
66 stars 4 forks source link

Debug lsp-latex-forward search behaviour #36

Closed onekk closed 1 year ago

onekk commented 1 year ago

lsp-latex forward search stopped working.

I'm using emacs 28.2 from arch Linux distribution.

texlab.log file it very big to post but it correctly show:

DEBUG - < {"jsonrpc":"2.0","id":0,"result":[{"rootDirectory":".","build":{"executable":"arara","args":["-v","%f"],"outputDirectory":".","forwardSearchAfter":false,"onSave":false},"forwardSearch":{"executable":"zathura","args":["--synctex-forward","%l:1:%f","%p"]},"chktex":{"onEdit":false,"onOpenAndSave":false},"diagnosticsDelay":300,"diagnostics":{"allowedPatterns":[],"ignoredPatterns":[]},"formatterLineLength":80,"bibtexFormatter":"texlab","latexFormatter":"texlab"}]}

And if I launch a correct line on the command line the forward search is good.

I've tried even to launch using M-x ls-latex-forward-search by hand but not luck.

What I could do to debug if the command is issued?

TIA and Regards

Carlo D.

ROCKTAKEY commented 1 year ago

You can search "textDocument/forwardSearch" in the texlab.log. lsp-latex send the "textDocument/forwardSearch" message by lsp-latex-forward-search (see https://github.com/ROCKTAKEY/lsp-latex/blob/master/lsp-latex.el#L651-L657).

You can attach texlab.log if you need more help.

onekk commented 1 year ago

Thanks for the answer, the message is sent, but probably something is not working, as the action is not performed:

Here are the relevant line of texlab.log.

DEBUG - < {"jsonrpc":"2.0","method":"textDocument/forwardSearch","params":{"textDocument":{"uri":"file:///home/common/Remote/Scripting_FreeCAD/It/cap/ba.tex"},"position":{"line":327,"character":19}},"id":4015}

DEBUG - > {"jsonrpc":"2.0","id":4015,"result":{"status":1}}
{"jsonrpc":"2.0","id":4015,"result":{"status":1}}
DEBUG - < {"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///home/common/Remote/Scripting_FreeCAD/It/cap/ba.tex"}},"id":4016}

DEBUG - < {"jsonrpc":"2.0","method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///home/common/Remote/Scripting_FreeCAD/It/cap/ba.tex"},"position":{"line":327,"character":19}},"id":4017}

DEBUG - > {"jsonrpc":"2.0","id":4016,"result":[]}
DEBUG - > {"jsonrpc":"2.0","id":4017,"result":null}
DEBUG - < {"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///home/common/Remote/Scripting_FreeCAD/It/cap/ba.tex"}},"id":4018}

DEBUG - < {"jsonrpc":"2.0","method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///home/common/Remote/Scripting_FreeCAD/It/cap/ba.tex"},"position":{"line":327,"character":19}},"id":4019}

DEBUG - > {"jsonrpc":"2.0","id":4018,"result":[]}
DEBUG - > {"jsonrpc":"2.0","id":4019,"result":null}
DEBUG - < {"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///home/common/Remote/Scripting_FreeCAD/It/cap/ba.tex"}},"id":4020}

DEBUG - < {"jsonrpc":"2.0","method":"textDocument/documentHighlight","params":{"textDocument":{"uri":"file:///home/common/Remote/Scripting_FreeCAD/It/cap/ba.tex"},"position":{"line":323,"character":81}},"id":4021}

DEBUG - < {"jsonrpc":"2.0","method":"textDocument/hover","params":{"textDocument":{"uri":"file:///home/common/Remote/Scripting_FreeCAD/It/cap/ba.tex"},"position":{"line":323,"character":81}},"id":4022}

DEBUG - > {"jsonrpc":"2.0","id":4020,"result":[]}

The other way round works, i.e clicking in zathura will highlight correctly the line in Emacs.

Regards

Carlo D.

ROCKTAKEY commented 1 year ago

Returned status is 1, which means "The previewer process executed the command with errors." (See https://github.com/latex-lsp/texlab/blob/master/docs/custom_messages.md#forward-search-request)

Texlab replaces in zathura --synctex-forward %l:1:%f %p according to:

https://github.com/latex-lsp/texlab/blob/master/docs/options.md#texlabforwardsearchargs %f: The path of the current TeX file. %p: The path of the current PDF file. %l: The current line number.

and then call it. So you can replace and call it manually to confirm that the command called by texlab is valid.

The other way round works, i.e clicking in zathura will highlight correctly the line in Emacs.

It is inverse search, not forward search. The variable to set is separated (See https://github.com/ROCKTAKEY/lsp-latex#zathura). So it is not very absolute information to debug forward search.

onekk commented 1 year ago

I know that backward and forward search have separated, settings, and for backward search the settings have to be done in zathura.

But if backward search is working synctex is working correctly if zathura could pass the correct "point" to Emacs.

Take in account that I have a multifile document and it open in Emacs the correct file, so it is not a plain tex file.

Two little additions:

1) I have tried to replicate with command line the code sent by lsp-latex-forward-search, as set in my config file:


(setq lsp-latex-forward-search-executable "zathura")
(setq lsp-latex-forward-search-args '("--synctex-forward" "%l:1:%f" "%p"))

And it work correctly but it opens another zathura window, but as the original session is not launched from the shell I think that is a intended behaviour.

2) I have noted that reusing the "view pdf button" it highlight the phrase were the cursor reside doing a sort of automatic "forward search" , reusing the existing zathura window.

View Pdf settings are from AUCTEX I think. defined here in my init.el.

(setq TeX-view-program-selection
  '(((output-dvi has-no-display-manager) "dvi2tty")
       ((output-dvi style-pstricks) "dvips and gv")
       (output-dvi "xdvi")
       (output-pdf "Zathura")
       (output-html "xdg-open")
  )
)

If it is a correct behaviour, I could be satisfied of this behaviour.

Best Regards

Carlo D.

ROCKTAKEY commented 1 year ago

And it work correctly

Then, texlab seems to call wrong command, since your log said that zathura exited abnormally. We should make issue on texlab. Could you do it, @onekk ?

but it opens another zathura window,

It is also strange but I have no idea. Zathura should reuse existing window. Texlab document authors and we overlook some option to zathura.

onekk commented 1 year ago

And it work correctly

Then, texlab seems to call wrong command, since your log said that zathura exited abnormally. We should make issue on texlab. Could you do it, @onekk ?

I will try to make an error report, to texlab, let's see if this lead to something.

but it opens another zathura window,

It is also strange but I have no idea. Zathura should reuse existing window. Texlab document authors and we overlook some option to zathura.

Yes it reuse the existing windos, but if you call a "new instance" from the command line there is not an "existing window" as the "existing window" is created by another "program" (In this case texlab (or AUCTEX as the "view PDF" is a AUCTEX command?)), so it is not strange IMHO.

ROCKTAKEY commented 1 year ago

Thanks, I subscribed it!

Yes it reuse the existing windos, but if you call a "new instance" from the command line there is not an "existing window" as the "existing window" is created by another "program" (In this case texlab (or AUCTEX as the "view PDF" is a AUCTEX command?)), so it is not strange IMHO.

All the arguments like --synctex-forward %l:1:%f %p are passed as command line arguments. So new instance is called with each command. Zathura should forward the command to existing instance but it does not.

ROCKTAKEY commented 1 year ago

Solved according to https://github.com/latex-lsp/texlab/issues/791#issuecomment-1298231822