fix(nvim): simplify preview.nvim config

This commit is contained in:
Barrett Ruth 2026-03-05 22:29:30 -05:00
parent f6199af390
commit 1e3d0fa577
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
2 changed files with 117 additions and 0 deletions

37
spec/synctex_zathura.lua Normal file
View file

@ -0,0 +1,37 @@
vim.cmd([[set runtimepath=$VIMRUNTIME]])
vim.opt.runtimepath:append('.')
vim.opt.packpath = {}
vim.opt.loadplugins = false
require('preview.commands').setup()
vim.fn.serverstart('/tmp/nvim-preview.sock')
local synctex_pdf = {}
vim.api.nvim_create_autocmd('User', {
pattern = 'PreviewCompileSuccess',
callback = function(args)
synctex_pdf[args.data.bufnr] = args.data.output
end,
})
vim.g.preview = {
latex = {
open = {
'zathura',
'--synctex-editor-command',
'nvim --server /tmp/nvim-preview.sock'
.. [[ --remote-expr "execute('b +%{line} %{input}')"]],
},
},
}
vim.keymap.set('n', '<leader>s', function()
local pdf = synctex_pdf[vim.api.nvim_get_current_buf()]
if pdf then
vim.fn.jobstart({
'zathura', '--synctex-forward',
vim.fn.line('.') .. ':0:' .. vim.fn.expand('%:p'), pdf,
})
end
end)