Skip to content

Instantly share code, notes, and snippets.

@kha-dinh
Last active September 14, 2025 16:40
Show Gist options
  • Save kha-dinh/c8540052854f3c6954b047abd506b799 to your computer and use it in GitHub Desktop.
Save kha-dinh/c8540052854f3c6954b047abd506b799 to your computer and use it in GitHub Desktop.
Lunarvim/Neovim+Sioyek+Synctex

This took me some time to figure out. Works like a charm, VimtexInverseSearch as well as texlab did not work for me. I use Lunarvim so I haven't try it on vanilla Neovim.

You first need to install the package neovim-remote on your platform.

Then, use the following configuration in your Packer declaration where vimtex is declared:

 {
        'lervag/vimtex',
        ft = { 'tex', 'bib' }, -- for lazy loading
        config = function()
          vim.cmd("syntax enable")
          vim.cmd("let g:vimtex_view_general_viewer='sioyek'")
          -- %1: file, %2: line number
          local options =
              string.format(
                  '--reuse-window --inverse-search="nvr --servername %s +%%2 %%1" --forward-search-file @tex --forward-search-line @line @pdf',
                  vim.v.servername)

          local command = string.format(
                  "let g:vimtex_view_general_options='%s'",
                  options)
          vim.cmd(command)
          vim.cmd("let g:vimtex_compiler_progname='nvr'")
        end,
    },

Forward search

You can bind vimtex command VimtexView to a key for forward search. It should jump to the line location in the pdf document.

Backward search

For backward search, you need to turn on Synctex in Sioyek (I haven't found a way to enable it automatically), e.g., running turn_on_synctex. After, just right clicking the document will jumps to its source code location.

@peterjumper
Copy link

thanks!

@anandkumar89
Copy link

I was facing same problem and came across this and later lervag/vimtex#2323 (comment). What was needed was to set callback path. Linked solution is simpler and works for me.

quoted here

Btw.; could it be possible to control VimR from regular neovim? It should be easy to test: Just do the same as above, but now use nvim --headless -c "VimtexInverseSearch 100 'main.tex'" in the terminal.

Still haven't heard back in qvacua/vimr#902, but I figured out that your previous suggestion to manually use nvim --headless -c "VimtexInverseSearch 100 'main.tex'" does actually work, as long as I start vimr from the console instead of the Finder. Probably because of some environment variable issues mentioned by @clason above.

Anyway, with this, I now use

let g:vimtex_view_method = 'sioyek'
let g:vimtex_callback_progpath ='/usr/local/bin/nvim'

to configure sioyek on my system and it works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment