diff options
Diffstat (limited to 'lua/cmake/capabilities.lua')
-rw-r--r-- | lua/cmake/capabilities.lua | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/lua/cmake/capabilities.lua b/lua/cmake/capabilities.lua index 6a70be2..36bc4b1 100644 --- a/lua/cmake/capabilities.lua +++ b/lua/cmake/capabilities.lua @@ -41,23 +41,25 @@ end -- TODO: make this async Capabilities.setup = function(callback) local lines = {} - vim.fn.jobstart({ config.cmake.cmake_path, "-E", "capabilities" }, { - on_stdout = function(_, data) - if data then - vim.list_extend(lines, data) - end - end, - on_exit = function(_, code, _) - if code == 0 then - Capabilities.json = vim.json.decode(table.concat(lines, "")) - if type(callback) == "function" then - callback() + vim.schedule(function() + vim.fn.jobstart({ config.cmake.cmake_path, "-E", "capabilities" }, { + on_stdout = function(_, data) + if data then + vim.list_extend(lines, data) end - else - vim.notify("error " .. tostring(code) .. ". 'cmake -E capabilities'", vim.log.levels.ERROR) - end - end, - }) + end, + on_exit = function(_, code, _) + if code == 0 then + Capabilities.json = vim.json.decode(table.concat(lines, "")) + if type(callback) == "function" then + callback() + end + else + vim.notify("error " .. tostring(code) .. ". 'cmake -E capabilities'", vim.log.levels.ERROR) + end + end, + }) + end) end return Capabilities |