diff --git a/lua/overseer/template/user/cmake/build.lua b/lua/overseer/template/user/cmake/build.lua index 0de82db..a43b3be 100644 --- a/lua/overseer/template/user/cmake/build.lua +++ b/lua/overseer/template/user/cmake/build.lua @@ -9,4 +9,15 @@ return { cwd = 'build_nvim', } end, + condition = { + callback = function(opts) + if vim.fn.executable("cmake") == 0 then + return false, 'Command "cmake" not found' + end + if vim.fn.findfile("CMakeLists.txt", opts.dir .. ";") == "" then + return false, "No CMakeLists.txt found" + end + return true + end, + }, } diff --git a/lua/overseer/template/user/cmake/clean.lua b/lua/overseer/template/user/cmake/clean.lua index 37d9ad2..5b8a28d 100644 --- a/lua/overseer/template/user/cmake/clean.lua +++ b/lua/overseer/template/user/cmake/clean.lua @@ -9,4 +9,15 @@ return { cwd = 'build_nvim', } end, + condition = { + callback = function(opts) + if vim.fn.executable("cmake") == 0 then + return false, 'Command "cmake" not found' + end + if vim.fn.findfile("CMakeLists.txt", opts.dir .. ";") == "" then + return false, "No CMakeLists.txt found" + end + return true + end, + }, } diff --git a/lua/overseer/template/user/cmake/cmake.lua b/lua/overseer/template/user/cmake/cmake.lua index d6dba2c..45215d9 100644 --- a/lua/overseer/template/user/cmake/cmake.lua +++ b/lua/overseer/template/user/cmake/cmake.lua @@ -1,4 +1,5 @@ return { +'builtin', 'user.cmake.configure', 'user.cmake.build', 'user.cmake.clean'} diff --git a/lua/overseer/template/user/cmake/configure.lua b/lua/overseer/template/user/cmake/configure.lua index a963c7d..6075f5c 100644 --- a/lua/overseer/template/user/cmake/configure.lua +++ b/lua/overseer/template/user/cmake/configure.lua @@ -10,4 +10,15 @@ return { cwd = build_nvim, } end, + condition = { + callback = function(opts) + if vim.fn.executable("cmake") == 0 then + return false, 'Command "cmake" not found' + end + if vim.fn.findfile("CMakeLists.txt", opts.dir .. ";") == "" then + return false, "No CMakeLists.txt found" + end + return true + end, + }, }