itsfernn/vimtex-follow

github github
programming-languages-supportmarkdown-and-latex
stars 20
issues 0
subscribers 0
forks 2
CREATED

UPDATED


vimtex-follow

Toggleable "follow PDF" for VimTeX: while active, the PDF viewer follows the line your cursor is on.

How it works

  • Each sync runs silent! VimtexView, but only if the line actually changed and is not blank, to try and avoid redundant forward searches.
  • By default a CursorMoved autocmd is used with a short trailing debounce. This can be more resource intensive, but feels more snappy. (works best with a light weight viewer like zathura)
  • The alternative trigger = 'hold' uses CursorHold, which means the PDF only syncs after staying on a line for a while, so it is synced less often (e.g. during rapid scrolling). Less snappy but more efficient. CursorHold fires after updatetime ms of idling, so lower updatetime yourself (e.g. set updatetime=150) to make it snappier.

Requirements

  • Neovim >= 0.10
  • vimtex with a configured vim.g.vimtex_view_method (e.g. 'sioyek')

Installation (lazy.nvim)

{
  'itsfernn/vimtex-follow',
  dependencies = { 'lervag/vimtex' },
  lazy = false,
  config = function()
    require('vimtex-follow').setup()
  end,
}

The plugin only needs to be active when you use the toggle; it does nothing until you enable it for a buffer.

Usage

  • <leader>lf toggles follow mode for the current buffer (default keymap, disabled with setup({ keymap = false })).
  • :VimtexFollowToggle, :VimtexFollowEnable, :VimtexFollowDisable
  • :VimtexFollowSync runs VimtexView once at the current line.

Options

require('vimtex-follow').setup({
  keymap = '<leader>lf', -- toggle keymap, or `false` to disable
  trigger = 'moved',     -- 'moved' (CursorMoved, debounced) or 'hold' (CursorHold)
  debounce = 50,         -- ms cursor must stay on a line before syncing ('moved'); 0 = every line
  notify = true,         -- notifications on toggle
})

See :help vimtex-follow for details.