aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua/cmake/actions.lua5
-rw-r--r--lua/cmake/fileapi.lua4
-rw-r--r--lua/cmake/project.lua21
3 files changed, 16 insertions, 14 deletions
diff --git a/lua/cmake/actions.lua b/lua/cmake/actions.lua
index 972e07e..9f16bf5 100644
--- a/lua/cmake/actions.lua
+++ b/lua/cmake/actions.lua
@@ -83,10 +83,9 @@ local _generate = function(option, opts)
end)
end
if opts.fresh then
- pr.clear_cache(main_path)
- else
- main_path()
+ pr.clear_cache()
end
+ main_path()
end
local _for_current_generate_option = function(func)
diff --git a/lua/cmake/fileapi.lua b/lua/cmake/fileapi.lua
index 1aa7de6..213fab3 100644
--- a/lua/cmake/fileapi.lua
+++ b/lua/cmake/fileapi.lua
@@ -9,12 +9,12 @@ local reply_dir_suffix = { ".cmake", "api", "v1", "reply" }
local FileApi = {}
function FileApi.create(path, callback)
- local query = Path:new(path, unpack(query_path_suffix)):normalize()
+ local query = vim.fs.joinpath(path, unpack(query_path_suffix))
utils.file_exists(query, function(exists)
if not exists then
if capabilities.json.fileApi then
vim.schedule(function()
- vim.fn.mkdir(Path:new(vim.fs.dirname(query)):absolute(), "p")
+ vim.fn.mkdir(vim.fs.dirname(query), "p")
utils.write_file(query, vim.json.encode(capabilities.json.fileApi), callback)
end)
else
diff --git a/lua/cmake/project.lua b/lua/cmake/project.lua
index a5d6cdd..36e2645 100644
--- a/lua/cmake/project.lua
+++ b/lua/cmake/project.lua
@@ -82,15 +82,18 @@ function Project.from_variants(variants)
init_fileapis()
end
---NOTE: Neovim craches on this code
-function Project.clear_cache(callback)
- uv.fs_unlink(vim.fs.joinpath(Project.current_directory(), "CMakeCache.txt"), function(f_err)
- assert(f_err, f_err)
- uv.fs_unlink(vim.fs.joinpath(Project.current_directory(), "CMakeFiles"), function(d_err)
- assert(d_err, d_err)
- callback()
- end)
- end)
+function Project.clear_cache()
+ local cd = Project.current_directory()
+ local Path = require("plenary.path")
+ Path:new(vim.fs.joinpath(cd, "CMakeCache.txt")):rm()
+ Path:new(vim.fs.joinpath(cd, "CMakeFiles")):rm({ recursive = true })
+ -- uv.fs_unlink(vim.fs.joinpath(Project.current_directory(), "CMakeCache.txt"), function(f_err, _)
+ -- assert(f_err, f_err)
+ -- uv.fs_unlink(vim.fs.joinpath(Project.current_directory(), "CMakeFiles"), function(d_err)
+ -- assert(d_err, d_err)
+ -- callback()
+ -- end)
+ -- end)
end
function Project.generate_options(opts)