-- 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, })