Skip to content

Commit e58c87d

Browse files
committed
Add user command for kit scanning
1 parent 4481b50 commit e58c87d

3 files changed

Lines changed: 33 additions & 0 deletions

File tree

lua/cmake-tools/init.lua

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,29 @@ function cmake.select_build_type(callback)
746746
)
747747
end
748748

749+
function cmake.scan_for_kits(callback)
750+
callback = type(callback) == "function" and callback
751+
or function(result)
752+
if result:is_ok() then
753+
cmake.generate({ bang = false, fargs = {} }, nil)
754+
end
755+
end
756+
if check_active_job_and_notify(callback) then
757+
return
758+
end
759+
760+
if get_cmake_configuration_or_notify(callback) == nil then
761+
return
762+
end
763+
764+
local kits = scanner.scan_for_kits()
765+
if kits then
766+
callback(Result:new(Types.SUCCESS, nil, nil))
767+
else
768+
callback(Result:new_error(Types.CANNOT_FIND_CMAKE_KITS, "Cannot find CMakeKits file"))
769+
end
770+
end
771+
749772
function cmake.select_kit(callback)
750773
callback = type(callback) == "function" and callback
751774
or function(result)

lua/cmake-tools/types.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ local Types = {
1818
"ANOTHER_JOB_RUNNING",
1919
"CMAKE_RUN_FAILED",
2020
"SETTINGS_ALREADY_OPENED",
21+
"CANNOT_FIND_CMAKE_KITS",
2122
}
2223

2324
Types[0] = "SUCCESS"

plugin/cmake-tools.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,15 @@ vim.api.nvim_create_user_command(
186186
desc = "CMake select cmake kit",
187187
}
188188
)
189+
--- CMake scan for kits
190+
vim.api.nvim_create_user_command(
191+
"CMakeScanForKits", -- name
192+
cmake_tools.scan_for_kits, -- command
193+
{ -- opts
194+
nargs = 0,
195+
desc = "CMake scan for cmake kits",
196+
}
197+
)
189198

190199
--- CMake select configure preset
191200
vim.api.nvim_create_user_command(

0 commit comments

Comments
 (0)