aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/core/fs.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-04-06 00:25:50 +0200
committerGitHub <noreply@github.com>2022-04-06 00:25:50 +0200
commit999476c324b26223aaf409a84497215e18d74499 (patch)
tree323cc5b072471e5e78ee94b273157779bbcb9611 /lua/nvim-lsp-installer/core/fs.lua
parentfix(taplo): use crate distribution (#576) (diff)
downloadmason-999476c324b26223aaf409a84497215e18d74499.tar
mason-999476c324b26223aaf409a84497215e18d74499.tar.gz
mason-999476c324b26223aaf409a84497215e18d74499.tar.bz2
mason-999476c324b26223aaf409a84497215e18d74499.tar.lz
mason-999476c324b26223aaf409a84497215e18d74499.tar.xz
mason-999476c324b26223aaf409a84497215e18d74499.tar.zst
mason-999476c324b26223aaf409a84497215e18d74499.zip
switch majority of installers to async implementation (#574)
Diffstat (limited to 'lua/nvim-lsp-installer/core/fs.lua')
-rw-r--r--lua/nvim-lsp-installer/core/fs.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/lua/nvim-lsp-installer/core/fs.lua b/lua/nvim-lsp-installer/core/fs.lua
index f3db813a..3819bd51 100644
--- a/lua/nvim-lsp-installer/core/fs.lua
+++ b/lua/nvim-lsp-installer/core/fs.lua
@@ -59,10 +59,33 @@ end
---@async
---@param path string
+function M.mkdirp(path)
+ log.debug("fs: mkdirp", path)
+ if vim.in_fast_event() then
+ a.scheduler()
+ end
+ if vim.fn.mkdir(path, "p") ~= 1 then
+ log.debug "fs: mkdirp failed"
+ error(("mkdirp: Could not create directory %q."):format(path))
+ end
+end
+
+---@async
+---@param path string
---@param new_path string
function M.rename(path, new_path)
log.debug("fs: rename", path, new_path)
uv.fs_rename(path, new_path)
end
+---@async
+---@param path string
+---@param contents string
+function M.write_file(path, contents)
+ log.fmt_debug("fs: write_file %s", path)
+ local fd = assert(uv.fs_open(path, "w", 438))
+ uv.fs_write(fd, contents, -1)
+ assert(uv.fs_close(fd))
+end
+
return M