feat(user_commands): add :Cmake command

This commit is contained in:
2024-09-09 04:09:59 +02:00
parent c199909c25
commit 1bd0e6b464
+20
View File
@@ -20,3 +20,23 @@ end, {
desc = "Update lazy plugins, treesitter parsers and mason language servers", desc = "Update lazy plugins, treesitter parsers and mason language servers",
force = false, force = false,
}) })
vim.api.nvim_create_user_command("Cmake", function(ctx)
local args = ctx.fargs
if vim.tbl_isempty(args) then
args = { "--build", "build" }
end
local mp = vim.o.makeprg
vim.o.makeprg = "cmake"
local ok, res = pcall(vim.cmd.make, { args = args, bang = ctx.bang })
vim.o.makeprg = mp
if not ok then
utils.err(res)
end
end, {
desc = "Like :make, but for CMake",
force = false,
nargs = "*",
})