ROCKTAKEY / lsp-latex

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

pdf-tools preview integration #17

Closed HumHongeKamyaab closed 3 years ago

HumHongeKamyaab commented 3 years ago

Can someone share his/her pdftools preview setting with emacs texlab, with forward and backward support.

ROCKTAKEY commented 3 years ago

See texlab documentation and README.

The variable lsp-latex-forward-search-executable corresponds to "latex.forwardSearch.executable", and lsp-latex–forward-search-args corresponds to "latex.forwardSearch.args".

So for example, to use SumatraPDF, mentioned on here:

(custom-set-variables
 '(lsp-latex-forward-search-executable "C:/Program Files/SumatraPDF/SumatraPDF.exe")
 '(lsp-latex-forward-search-args
   '("-reuse-instance"
     "%p"
     "-forward-search"
     "%f"
     "%l")))

or

(setq lsp-latex-forward-search-executable "C:/Program Files/SumatraPDF/SumatraPDF.exe")
(setq lsp-latex-forward-search-args
      '("-reuse-instance"
        "%p"
        "-forward-search"
        "%f"
        "%l"))
HumHongeKamyaab commented 3 years ago

Thanks for the reply. I am looking for pdftools which is inbuilt pdf viewer of emacs. Its setup is not mentioned on texlab website.

ROCKTAKEY commented 3 years ago

I got it, so you would like to preview pdf on Emacs with forward/backward search, right? Then, unfortunately, that is not supported now.

But if auctex has such a function, it might be possible to use inbuild pdf viewer on Emacs with for/backward search, with texlab.

HumHongeKamyaab commented 3 years ago

I use it with Auctex, I think it should be possible with texlab with right config.

ROCKTAKEY commented 3 years ago

OK, I'm going to investigate and to try to integrate. Thanks for your information.

ROCKTAKEY commented 3 years ago

@HumHongeKamyaab I couldn't find forward/inverse research functions with Emacs PDF viewer, on AUCTeX. Could you tell me the functions (and setting for use with Emacs PDF viewer, if needed)?

rosensymmetri commented 3 years ago

I stumbled upon this thread while trying to figure out how to use pdf-tools with lsp-latex. From AUCTeX documentation (https://www.gnu.org/software/auctex/manual/auctex/I_002fO-Correlation.html):

Forward search happens automatically upon calling the viewer, e.g. by typing C-c C-v (TeX-view). This will open the viewer or bring it to front and display the output page corresponding to the position of point in the source file. AUCTeX will automatically pass the necessary command line options to the viewer for this to happen.

Upon opening the viewer you will be asked if you want to start a server process (Gnuserv or Emacs server) which is necessary for inverse search. This happens only if there is no server running already. You can customize the variable TeX-source-correlate-start-server to inhibit the question and always or never start the server respectively.

The command TeX-view is defined in the following file: https://github.com/emacsmirror/auctex/blob/master/tex-buf.el

ROCKTAKEY commented 3 years ago

@rosensymmetri Thank you so much!!! I cannot find any package named pdftools, so I was looking for pdf tools in a general sense. I use Windows mainly, so it is a little difficult to use pdf-tools, but I'll try to integrate it to lsp-latex ;)

ROCKTAKEY commented 3 years ago

@HumHongeKamyaab @rosensymmetri Now lsp-latex.el can be used with pdf-tools. See here. If it is unable or difficult, please reopen and comment here.