clean stuff up even more

This commit is contained in:
2025-10-18 02:24:05 -03:00
parent a3efd7804b
commit ae9da209e1
7 changed files with 177 additions and 196 deletions

View File

@@ -1,5 +1,7 @@
local M = {}
local float_term = require("util.float").float_terminal
function M.find_cmake()
if vim.g.cmake_path and vim.fn.filereadable(vim.g.cmake_path) == 1 then
return vim.g.cmake_path
@@ -37,5 +39,27 @@ function M.find_cmake()
return "cmake" -- fallback, so termopen still runs even if broken
end
function M.configure_cmake(build_type)
vim.fn.mkdir("build", "p")
float_term(
{ M.find_cmake(), "-DCMAKE_BUILD_TYPE=" .. build_type, "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", ".." },
{ cwd = "build" }
)
end
vim.keymap.set("n", "<leader>cd", function() M.configure_cmake("Debug") end, { desc = "CMake Debug" })
vim.keymap.set("n", "<leader>cr", function() M.configure_cmake("Release") end, { desc = "CMake Release" })
vim.keymap.set("n", "<leader>cp", function() M.configure_cmake("RelWithDebInfo") end, { desc = "CMake RelWithDebInfo" })
vim.api.nvim_create_user_command("Build", function(opts)
local t = opts.args
if t == "" then print("Usage: :Build <target>"); return end
float_term(
{ CMAKE, "--build", "build", "--parallel", "20", "--target", t },
{ height_ratio = 0.8, width_ratio = 0.8, border = "single" }
)
end, { nargs = 1 })
return M