docs: document PreviewWatchingStopped event and update SyncTeX recipes

Problem: the new `PreviewWatchingStopped` event was undocumented, and
the SyncTeX recipes never cleared `synctex_pdf` on watch stop.

Solution: add the event to the events section and update the shared
SyncTeX setup block to clear `synctex_pdf[bufnr]` on stop.
This commit is contained in:
Barrett Ruth 2026-03-15 13:36:23 -04:00
parent 199ccf030c
commit 85dfdeacf7
Signed by: barrett
GPG key ID: A6C96C9349D2FC81

View file

@ -293,6 +293,9 @@ preview.nvim fires User autocmds with structured data:
`PreviewCompileFailed` Compilation failed (non-zero exit). `PreviewCompileFailed` Compilation failed (non-zero exit).
data: `{ bufnr, provider, code, stderr }` data: `{ bufnr, provider, code, stderr }`
`PreviewWatchingStopped` Watching stopped (toggle off or buffer delete).
data: `{ bufnr, provider }`
Example: >lua Example: >lua
vim.api.nvim_create_autocmd('User', { vim.api.nvim_create_autocmd('User', {
pattern = 'PreviewCompileSuccess', pattern = 'PreviewCompileSuccess',
@ -354,6 +357,12 @@ The following configs leverage the below basic setup: ~
synctex_pdf[args.data.bufnr] = args.data.output synctex_pdf[args.data.bufnr] = args.data.output
end, end,
}) })
vim.api.nvim_create_autocmd('User', {
pattern = 'PreviewWatchingStopped',
callback = function(args)
synctex_pdf[args.data.bufnr] = nil
end,
})
< <
The recipes below bind `<leader>s` for forward search. To scroll the PDF The recipes below bind `<leader>s` for forward search. To scroll the PDF