From 54c147c88537a682e5f926ea391c14ae31c80f82 Mon Sep 17 00:00:00 2001 From: Daniil Rozanov Date: Thu, 2 May 2024 00:15:28 +0300 Subject: feat: new commands and some refactoring --- lua/cmake/capabilities.lua | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) (limited to 'lua/cmake/capabilities.lua') 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 -- cgit v1.2.3