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

specify pdf viewer for compilation via LSP #436

Closed
islercn opened this issue May 30, 2021 · 7 comments
Closed

specify pdf viewer for compilation via LSP #436

islercn opened this issue May 30, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@islercn
Copy link

islercn commented May 30, 2021

to use SumatraPDF as the PDF previewer, i have to create and modify %USERPROFILE%/.latexmkrc

if i can choose the pdf viewer via LSP, like the option "texlab.forwardSearch.executable" for forward search?

after testing, the option "texlab.forwardSearch.executable" is only for forward search, not to view the pdf file after compilation

@clason
Copy link
Contributor

clason commented May 30, 2021

@islercn
Copy link
Author

islercn commented May 30, 2021

See https://github.com/latex-lsp/texlab/blob/master/docs/previewing.md

it is not so portable, perhaps it ok that the .latexmkrc file can be allowed to be placed in the program directory, but it is not valid

so allowing users to specify pdf viewer via LSP is also a good choice

@islercn islercn changed the title choose pdf viewer by LSP specify pdf viewer via LSP May 30, 2021
@islercn islercn changed the title specify pdf viewer via LSP specify pdf viewer after compilation via LSP May 30, 2021
@islercn islercn changed the title specify pdf viewer after compilation via LSP specify pdf viewer for compilation via LSP May 30, 2021
@pfoerster
Copy link
Member

it is not so portable, perhaps it ok that the .latexmkrc file can be allowed to be placed in the program directory, but it is not valid

At the moment, texlab does not control the PDF viewer. Instead, the build system (e. g. latexmk) is currently responsible for launching the PDF viewer. Thus, the latexmkrc needs to be found by latexmk and not texlab. texlab does not parse (or better execute) this file. I would avoid hard-coding every possible viewer into texlab as there is quite some maintenance effort involved. I don' think it should be portable because every user uses some different kind of PDF viewer.

@clason
Copy link
Contributor

clason commented May 31, 2021

But you already configure the viewer for forward search, don't you? Wouldn't it be possible to add a callback after (successful) compilation to trigger a forward search?

(Or leave it user definable so they can do whatever they want?)

@pfoerster
Copy link
Member

But you already configure the viewer for forward search, don't you?

Yeah, that would be possible. I think I misread the issue a little bit. I thought that we should include the configuration from the documentation inside texlab so the user just specifies texlab.build.viewer: "sumatra" for example. I think adding a texlab.build.viewer.executable setting seems reasonable.

Wouldn't it be possible to add a callback after (successful) compilation to trigger a forward search?

Not exactly. To perform a forward search we need a line number, which is something texlab does not know. In past versions, we tried to guess the value but this approach was pretty much tailored to VSCode and not useful in the general case, which is why I moved it to the extension only. I think this feature is valuable but it needs to implemented correctly.

@pfoerster pfoerster added the enhancement New feature or request label May 31, 2021
@pfoerster
Copy link
Member

Concerning the forward search after building, there is microsoft/language-server-protocol#718, which would make it possible to implement this feature.

@pfoerster
Copy link
Member

texlab 3.2.0 does not rely on a latexmkrc file anymore. Instead, you can use texlab.build.forwardSearchAfter: true to keep the viewer synchronized with the cursor position. The cursor position is guessed by texlab by taking a look at the last edit and completion/hover positions. Note that this may not always be 100% accurate, but for most cases it should suffice. Please take a look at https://github.com/latex-lsp/texlab/blob/master/docs/previewing.md for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants