feat(nvim): use render.nvim

This commit is contained in:
Barrett Ruth 2026-03-01 17:30:15 -05:00
parent 639f1a4eac
commit 339840a602
Signed by: barrett
GPG key ID: A6C96C9349D2FC81
3 changed files with 52 additions and 34 deletions

View file

@ -1,29 +1,17 @@
-- TODO: move to barrettruth/render.nvim
vim.keymap.set('n', '<leader>t', function()
if vim.fn.executable('sioyek') ~= 1 then
return vim.notify('sioyek not found', vim.log.levels.ERROR)
end
if vim.fn.executable('hyprctl') ~= 1 then
return vim.notify('hyprctl not found', vim.log.levels.ERROR)
end
local pdf = vim.fn.expand('%:p:r') .. '.pdf'
local basename = vim.fn.fnamemodify(pdf, ':t')
local ret = vim.system({ 'hyprctl', 'clients', '-j' }):wait()
if ret.code == 0 then
for _, c in ipairs(vim.json.decode(ret.stdout)) do
if
(c.class or ''):lower():find('sioyek')
and (c.title or ''):find(basename, 1, true)
then
vim.system({
'hyprctl',
'dispatch',
'closewindow',
'address:' .. c.address,
})
require('render').compile()
vim.api.nvim_create_autocmd('User', {
pattern = 'RenderCompileSuccess',
once = true,
callback = function(args)
local pdf = args.data.output
if not pdf or pdf == '' then
return
end
end
end
vim.system({ 'sioyek', '--new-instance', pdf })
if vim.fn.executable('sioyek') ~= 1 then
return vim.notify('sioyek not found', vim.log.levels.ERROR)
end
vim.system({ 'sioyek', '--new-instance', pdf })
end,
})
end, { buffer = true })