diff options
author | Daniil Rozanov <daniilrozzanov@gmail.com> | 2024-04-26 02:09:30 +0300 |
---|---|---|
committer | Daniil Rozanov <daniilrozzanov@gmail.com> | 2024-04-26 02:09:30 +0300 |
commit | 93945a96daad5db8f91b07d1aef65b3ec6f758fb (patch) | |
tree | 92b061bfffcf58515bb4c04ed448364262d67341 /lua/cmake/capabilities.lua | |
parent | 8d05fcaaeb1442c709f148ff934d92900743f051 (diff) |
feat: autocommands to regenerate and reset project
One autocommand generates project after saving CMakeLists.txt, and other sets up all project after saving variants
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 |