diff options
author | Daniil Rozanov <daniilrozzanov@gmail.com> | 2024-05-02 00:15:28 +0300 |
---|---|---|
committer | Daniil Rozanov <daniilrozzanov@gmail.com> | 2024-05-02 00:15:28 +0300 |
commit | 54c147c88537a682e5f926ea391c14ae31c80f82 (patch) | |
tree | e03a5befb6eb31f95f0748840386eb7eac360051 /lua/cmake/capabilities.lua | |
parent | ebf15bdda1a1c53f4ce91681b1244e2159654ff4 (diff) |
feat: new commands and some refactoring
Diffstat (limited to 'lua/cmake/capabilities.lua')
-rw-r--r-- | lua/cmake/capabilities.lua | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/lua/cmake/capabilities.lua b/lua/cmake/capabilities.lua index 36bc4b1..0b76fc0 100644 --- a/lua/cmake/capabilities.lua +++ b/lua/cmake/capabilities.lua @@ -38,27 +38,18 @@ function Capabilities.has_fileapi() return vim.tbl_get(Capabilities.json, "fileApi") ~= nil end --- TODO: make this async Capabilities.setup = function(callback) - local lines = {} vim.schedule(function() - vim.fn.jobstart({ config.cmake.cmake_path, "-E", "capabilities" }, { - on_stdout = function(_, data) - if data then - vim.list_extend(lines, data) + vim.system({ config.cmake.cmake_path, "-E", "capabilities" }, { text = true }, function(obj) + if obj.code == 0 then + Capabilities.json = vim.json.decode(obj.stdout) + if type(callback) == "function" then + callback() 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, - }) + else + vim.notify("error " .. tostring(obj.code) .. ". 'cmake -E capabilities'", vim.log.levels.ERROR) + end + end) end) end |