feat(nvim): use render.nvim
This commit is contained in:
parent
639f1a4eac
commit
339840a602
3 changed files with 52 additions and 34 deletions
|
|
@ -1,29 +1,17 @@
|
||||||
-- TODO: move to barrettruth/render.nvim
|
|
||||||
vim.keymap.set('n', '<leader>t', function()
|
vim.keymap.set('n', '<leader>t', function()
|
||||||
if vim.fn.executable('sioyek') ~= 1 then
|
require('render').compile()
|
||||||
return vim.notify('sioyek not found', vim.log.levels.ERROR)
|
vim.api.nvim_create_autocmd('User', {
|
||||||
end
|
pattern = 'RenderCompileSuccess',
|
||||||
if vim.fn.executable('hyprctl') ~= 1 then
|
once = true,
|
||||||
return vim.notify('hyprctl not found', vim.log.levels.ERROR)
|
callback = function(args)
|
||||||
end
|
local pdf = args.data.output
|
||||||
local pdf = vim.fn.expand('%:p:r') .. '.pdf'
|
if not pdf or pdf == '' then
|
||||||
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,
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
if vim.fn.executable('sioyek') ~= 1 then
|
||||||
end
|
return vim.notify('sioyek not found', vim.log.levels.ERROR)
|
||||||
vim.system({ 'sioyek', '--new-instance', pdf })
|
end
|
||||||
|
vim.system({ 'sioyek', '--new-instance', pdf })
|
||||||
|
end,
|
||||||
|
})
|
||||||
end, { buffer = true })
|
end, { buffer = true })
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ local dev_plugins = {
|
||||||
'pending.nvim',
|
'pending.nvim',
|
||||||
'cp.nvim',
|
'cp.nvim',
|
||||||
'diffs.nvim',
|
'diffs.nvim',
|
||||||
|
'render.nvim',
|
||||||
}
|
}
|
||||||
|
|
||||||
local opt_dir = vim.fn.stdpath('data') .. '/site/pack/dev/opt/'
|
local opt_dir = vim.fn.stdpath('data') .. '/site/pack/dev/opt/'
|
||||||
|
|
@ -406,4 +407,42 @@ return {
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
'barrettruth/render.nvim',
|
||||||
|
ft = { 'typst', 'tex' },
|
||||||
|
before = function()
|
||||||
|
vim.g.render = {
|
||||||
|
providers = {
|
||||||
|
typst = {
|
||||||
|
cmd = { 'typst', 'compile' },
|
||||||
|
args = function(ctx)
|
||||||
|
return { ctx.file }
|
||||||
|
end,
|
||||||
|
output = function(ctx)
|
||||||
|
return ctx.file:gsub('%.typ$', '.pdf')
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
latexmk = {
|
||||||
|
cmd = { 'latexmk' },
|
||||||
|
args = function(ctx)
|
||||||
|
return { '-pdf', '-interaction=nonstopmode', ctx.file }
|
||||||
|
end,
|
||||||
|
output = function(ctx)
|
||||||
|
return ctx.file:gsub('%.tex$', '.pdf')
|
||||||
|
end,
|
||||||
|
clean = { 'latexmk', '-c' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
providers_by_ft = {
|
||||||
|
typst = 'typst',
|
||||||
|
tex = 'latexmk',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
keys = {
|
||||||
|
{ '<leader>rr', '<cmd>Render compile<cr>' },
|
||||||
|
{ '<leader>rs', '<cmd>Render stop<cr>' },
|
||||||
|
{ '<leader>rc', '<cmd>Render clean<cr>' },
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,6 @@ vim.pack.add({
|
||||||
'https://github.com/tpope/vim-abolish',
|
'https://github.com/tpope/vim-abolish',
|
||||||
'https://github.com/tpope/vim-sleuth',
|
'https://github.com/tpope/vim-sleuth',
|
||||||
'https://github.com/kylechui/nvim-surround',
|
'https://github.com/kylechui/nvim-surround',
|
||||||
'https://github.com/lervag/vimtex',
|
|
||||||
}, { load = function() end })
|
}, { load = function() end })
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -132,14 +131,6 @@ return {
|
||||||
{ 'i', mode = { 'x', 'o' } },
|
{ 'i', mode = { 'x', 'o' } },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
|
||||||
'lervag/vimtex',
|
|
||||||
ft = { 'latex' },
|
|
||||||
before = function()
|
|
||||||
vim.g.vimtex_view_method = 'sioyek'
|
|
||||||
vim.g.vimtex_quickfix_mode = 0
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
'monaqa/dial.nvim',
|
'monaqa/dial.nvim',
|
||||||
after = function()
|
after = function()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue