diff --git a/2025/autorun.lua b/2025/autorun.lua new file mode 100644 index 0000000..9369282 --- /dev/null +++ b/2025/autorun.lua @@ -0,0 +1,22 @@ +-- Use this to get the buffer ID where you want the output +-- echo nvim_get_current_buf() +vim.api.nvim_create_autocmd("BufWritePost", { + group = vim.api.nvim_create_augroup("AutoRunCode", { clear = true }), + pattern = "*.lua", + callback = function() + local bufnr = 21 + vim.fn.jobstart({ "lua", "Day5/Day5.lua" }, { + stdout_buffered = true, + on_stdout = function(_, data) + if data then + vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, data) + end + end, + on_stderr = function(_, data) + if data then + vim.api.nvim_buf_set_lines(bufnr, -1, -1, false, data) + end + end, + }) + end, +})