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

How to set preview in nvim #40

Closed
jkunlin opened this issue Jul 12, 2019 · 7 comments
Closed

How to set preview in nvim #40

jkunlin opened this issue Jul 12, 2019 · 7 comments
Labels
question Further information is requested

Comments

@jkunlin
Copy link

jkunlin commented Jul 12, 2019

Does it possible to set up the previewing and build on save in nvim just like vimtex?
I see the document here https://texlab.netlify.com/docs/installation/previewing. But have no idea how to configure in nvim.

@jkunlin
Copy link
Author

jkunlin commented Jul 12, 2019

I am using coc as the LSP client in nvim

@pfoerster
Copy link
Member

Building on save is turned off by default.
However, you can enable it by setting latex.build.onSave to true.
As far as I know, the language server can be configured using :CocConfig (see https://github.com/neoclide/coc.nvim/wiki/Using-the-configuration-file#configuration-file-resolve). Then you can paste the following snippet:

{
    "latex.build.onSave": true
}

and save the file. Now, TexLab should build your documents using latexmk
every time you save a document. latexmk is responsible for calling your PDF viewer.
See https://texlab.netlify.com/docs/installation/previewing for more instructions. Additional settings can be found on our website.

@pfoerster pfoerster added the question Further information is requested label Jul 12, 2019
@jkunlin
Copy link
Author

jkunlin commented Jul 13, 2019

I add the following line to my ~/.latexmkrc file: $pdf_previewer = 'start okular --unique';
And the coc-setting as follow
"latex.build.args": [ "-pdf", "-interaction=nonstopmode", "-synctex=1", "-pv" ], "latex.build.onSave": true, "latex.forwardSearch.executable": "okular", "latex.forwardSearch.args": [ "--unique", "file:%p#src:%l%f" ],
But the forward search does not work.

@efoerster
Copy link
Member

The problem is that forward search can be only implemented with a custom LSP request that the client has to implement. For Vim, there is the coc-texlab extension that will hopefully implement it soon, see issue #2 on their repo.

@oblitum
Copy link

oblitum commented Jul 16, 2019

No forward search yet but my current setup for preview with coc-texlab (:CocCommand latex.Build) is:

.vimrc

  call coc#config('latex', {
  \   'lint.onChange': v:true,
  \   'forwardSearch.executable': 'zathura',
  \   'forwardSearch.args': ['--synctex-forward', '%l:1:%f', '%p'],
  \   'build.args': ['-pdf', '-interaction=nonstopmode', '-synctex=1', '-pvc']
  \ })

Important flag with zathure is -pvc, as the example in the wiki uses -pv, which launches a new zathura instance on every build, -pvc will launch continuous build and just a single instance is launched and updated on write. Not sure about a way to stop though.

@fannheyward
Copy link
Contributor

coc-texlab has added latex.ForwardSearch, give it a try.

@jkunlin
Copy link
Author

jkunlin commented Jul 17, 2019

Thanks very much! It works with okular.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants