From 90eff7db4499ac78cc99965ead93f97e35e026ef Mon Sep 17 00:00:00 2001 From: Naxdy Date: Mon, 17 Nov 2025 11:37:45 +0100 Subject: [PATCH] feat: execute latex compile in directory of file --- naxdy/latexcompile.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/naxdy/latexcompile.lua b/naxdy/latexcompile.lua index 7f40cfb..1f76de9 100644 --- a/naxdy/latexcompile.lua +++ b/naxdy/latexcompile.lua @@ -18,12 +18,14 @@ M.compile = function(options) return end - local filename = vim.fn.bufname(bufnr) + local filename = vim.api.nvim_buf_get_name(bufnr) if filename:sub(- #".tex") == ".tex" then M.compiling_buffers[bufnr] = true + local start_idx, _ = filename:find("/[%w%-_%.]+%.tex") + local path = filename:sub(1, start_idx - 1) - vim.system({ "pdflatex", filename }, {}, function() + vim.system({ "pdflatex", filename }, { cwd = path }, function() M.compiling_buffers[bufnr] = nil end) end