diff options
Diffstat (limited to 'lua/cmake-explorer/globals.lua')
-rw-r--r-- | lua/cmake-explorer/globals.lua | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lua/cmake-explorer/globals.lua b/lua/cmake-explorer/globals.lua new file mode 100644 index 0000000..759bba4 --- /dev/null +++ b/lua/cmake-explorer/globals.lua @@ -0,0 +1,29 @@ +local config = require("cmake-explorer.config") + +local M = { + capabilities = nil, + generators = {}, +} + +local available_generators = function(capabilities) + local ret = {} + if not capabilities or not capabilities.generators then + return ret + end + for k, v in pairs(capabilities.generators) do + table.insert(ret, v.name) + end + return vim.fn.reverse(ret) +end + +local set_capabilities = function() + local output = vim.fn.system({ config.cmake_cmd, "-E", "capabilities" }) + M.capabilities = vim.json.decode(output) + M.generators = available_generators(M.capabilities) +end + +M.setup = function() + set_capabilities() +end + +return M |