From 02958158c0c979fcce5b57918de6af20e98f599c Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Tue, 3 Mar 2026 17:50:36 -0500 Subject: [PATCH 1/2] fix(compiler): check output exists before opening from long-running process Problem: for long-running processes (typst watch), M.compile() calls the opener immediately after vim.system() returns, before the process has produced any output. On first run the output file does not exist yet, so the opener is called on a nonexistent path. Solution: guard the open block with vim.uv.fs_stat so it only fires if the output file already exists at spawn time. --- lua/preview/compiler.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/preview/compiler.lua b/lua/preview/compiler.lua index e19cbf0..9498d70 100644 --- a/lua/preview/compiler.lua +++ b/lua/preview/compiler.lua @@ -144,7 +144,7 @@ function M.compile(bufnr, name, provider, ctx) end) ) - if provider.open and not opened[bufnr] and output_file ~= '' then + if provider.open and not opened[bufnr] and output_file ~= '' and vim.uv.fs_stat(output_file) then if provider.open == true then vim.ui.open(output_file) elseif type(provider.open) == 'table' then From c12891f7ea97e79ec2fb8a12bcc035ee3c994bb6 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Wed, 4 Mar 2026 00:20:10 -0500 Subject: [PATCH 2/2] style(compiler): reformat long condition for stylua --- lua/preview/compiler.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/preview/compiler.lua b/lua/preview/compiler.lua index 29ffcaf..8555881 100644 --- a/lua/preview/compiler.lua +++ b/lua/preview/compiler.lua @@ -147,7 +147,12 @@ function M.compile(bufnr, name, provider, ctx) end) ) - if provider.open and not opened[bufnr] and output_file ~= '' and vim.uv.fs_stat(output_file) then + if + provider.open + and not opened[bufnr] + and output_file ~= '' + and vim.uv.fs_stat(output_file) + then if provider.open == true then vim.ui.open(output_file) elseif type(provider.open) == 'table' then