fix(nvim): simplify preview.nvim config
This commit is contained in:
parent
f6199af390
commit
1e3d0fa577
2 changed files with 117 additions and 0 deletions
37
spec/synctex_zathura.lua
Normal file
37
spec/synctex_zathura.lua
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue