diff options
Diffstat (limited to 'lua/cmake/fileapi.lua')
-rw-r--r-- | lua/cmake/fileapi.lua | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lua/cmake/fileapi.lua b/lua/cmake/fileapi.lua index d33d477..1aa7de6 100644 --- a/lua/cmake/fileapi.lua +++ b/lua/cmake/fileapi.lua @@ -2,7 +2,6 @@ local capabilities = require("cmake.capabilities") local Path = require("plenary.path") local scan = require("plenary.scandir") local utils = require("cmake.utils") -local uv = vim.uv or vim.loop local query_path_suffix = { ".cmake", "api", "v1", "query", "client-cmake", "query.json" } local reply_dir_suffix = { ".cmake", "api", "v1", "reply" } @@ -15,7 +14,6 @@ function FileApi.create(path, callback) if not exists then if capabilities.json.fileApi then vim.schedule(function() - --TODO: change to async vim.fn.mkdir(Path:new(vim.fs.dirname(query)):absolute(), "p") utils.write_file(query, vim.json.encode(capabilities.json.fileApi), callback) end) @@ -35,6 +33,7 @@ function FileApi.read_reply(path, callback) return end local ret = { targets = {} } + --TODO: replace with uv scandir scan.scan_dir_async(reply_dir, { search_pattern = "index*", on_exit = function(results) @@ -47,8 +46,10 @@ function FileApi.read_reply(path, callback) if object.kind == "codemodel" then utils.read_file(Path:new(reply_dir, object.jsonFile):absolute(), function(codemodel_data) local codemodel = vim.json.decode(codemodel_data) - --FIX: this loop does not read all files if codemodel contains many targets. This is because libuv (or some external settings) forbids to open files - -- in async mode more than some limit number. Seems like the solution is to queue these calls and limit max number for opened files per time + --FIX: this loop does not read all files if codemodel contains many targets (is will crash actually). + --This is because libuv (or some external settings) forbids to open files + -- in async mode more than some limit number. Seems like the solution is + -- to queue these calls and limit max number for opened files per time for _, target in ipairs(codemodel.configurations[1].targets) do utils.read_file( Path:new(reply_dir, target.jsonFile):absolute(), |