From 339840a60291bbdf4dc72fd6cb46dcdf5eaf7369 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sun, 1 Mar 2026 17:30:15 -0500 Subject: [PATCH] feat(nvim): use render.nvim --- config/nvim/after/ftplugin/typst.lua | 38 ++++++++++----------------- config/nvim/lua/plugins/dev.lua | 39 ++++++++++++++++++++++++++++ config/nvim/lua/plugins/nvim.lua | 9 ------- 3 files changed, 52 insertions(+), 34 deletions(-) diff --git a/config/nvim/after/ftplugin/typst.lua b/config/nvim/after/ftplugin/typst.lua index a5bf478..24f54e5 100644 --- a/config/nvim/after/ftplugin/typst.lua +++ b/config/nvim/after/ftplugin/typst.lua @@ -1,29 +1,17 @@ --- TODO: move to barrettruth/render.nvim vim.keymap.set('n', '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 }) diff --git a/config/nvim/lua/plugins/dev.lua b/config/nvim/lua/plugins/dev.lua index 82a59b9..83bc331 100644 --- a/config/nvim/lua/plugins/dev.lua +++ b/config/nvim/lua/plugins/dev.lua @@ -6,6 +6,7 @@ local dev_plugins = { 'pending.nvim', 'cp.nvim', 'diffs.nvim', + 'render.nvim', } local opt_dir = vim.fn.stdpath('data') .. '/site/pack/dev/opt/' @@ -406,4 +407,42 @@ return { } 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 = { + { 'rr', 'Render compile' }, + { 'rs', 'Render stop' }, + { 'rc', 'Render clean' }, + }, + }, } diff --git a/config/nvim/lua/plugins/nvim.lua b/config/nvim/lua/plugins/nvim.lua index 52d61d0..0677c5f 100644 --- a/config/nvim/lua/plugins/nvim.lua +++ b/config/nvim/lua/plugins/nvim.lua @@ -8,7 +8,6 @@ vim.pack.add({ 'https://github.com/tpope/vim-abolish', 'https://github.com/tpope/vim-sleuth', 'https://github.com/kylechui/nvim-surround', - 'https://github.com/lervag/vimtex', }, { load = function() end }) return { @@ -132,14 +131,6 @@ return { { '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', after = function()