From 968d3bfb02a5bac7b72e083e1d76c7fe01382e37 Mon Sep 17 00:00:00 2001 From: DarthMooMancer <107283522+DarthMooMancer@users.noreply.github.com> Date: Mon, 7 Apr 2025 11:30:22 -0400 Subject: [PATCH] Changes to cpp.lua --- lua/Polydev/cpp.lua | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/lua/Polydev/cpp.lua b/lua/Polydev/cpp.lua index fc6496d..ec528f1 100644 --- a/lua/Polydev/cpp.lua +++ b/lua/Polydev/cpp.lua @@ -180,8 +180,24 @@ function M.build() vim.api.nvim_buf_set_option(term_buf, "modifiable", true) local output = vim.fn.system(cmd) local success = vim.v.shell_error == 0 - vim.api.nvim_buf_set_lines(term_buf, 0, -1, false, vim.list_extend({ success and "Compilation successful!" or "Error during compilation:" }, vim.split(output, "\n", { trimempty = true }))) - vim.api.nvim_buf_set_option(term_buf, "modifiable", false) + -- Check if the output contains "ninja: no work to do." + local suppress_ninja_output = false + for _, line in ipairs(vim.split(output, "\n", { trimempty = true })) do + if line:match("ninja: no work to do.") then + suppress_ninja_output = true + break + end + end + + -- Prepare the final output message + local status_message = success and "Compilation successful!" or "Error during compilation:" + + -- If there's no work to do, suppress Ninja output + if suppress_ninja_output then + vim.api.nvim_buf_set_lines(term_buf, 0, -1, false, { status_message }) + else + vim.api.nvim_buf_set_lines(term_buf, 0, -1, false, vim.list_extend({ status_message }, vim.split(output, "\n", { trimempty = true }))) + end end function M.run()