diff --git a/lua/Polydev/cpp.lua b/lua/Polydev/cpp.lua index ec528f1..079cbf1 100644 --- a/lua/Polydev/cpp.lua +++ b/lua/Polydev/cpp.lua @@ -174,13 +174,11 @@ function M.build() local root = M.get_project_root() if not root then return print("Error: Project root not found.") end local build_dir = root .. "/build" - local cmd = "cd " .. build_dir .. " && cmake .. --preset default" .. " && cmake --build ." local term_buf = M.open_float_terminal(cmd) vim.api.nvim_buf_set_option(term_buf, "modifiable", true) local output = vim.fn.system(cmd) local success = vim.v.shell_error == 0 - -- 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 @@ -189,15 +187,9 @@ function M.build() 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 + 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()