From e4a2926712e1f682f869bf9e89e2de54d0c5d47f Mon Sep 17 00:00:00 2001 From: William Boman Date: Sun, 15 Aug 2021 01:54:41 +0200 Subject: fs: use native vim.fns --- lua/nvim-lsp-installer/fs.lua | 9 ++++----- lua/nvim-lsp-installer/server.lua | 4 +++- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'lua') diff --git a/lua/nvim-lsp-installer/fs.lua b/lua/nvim-lsp-installer/fs.lua index d9c4ac93..55809767 100644 --- a/lua/nvim-lsp-installer/fs.lua +++ b/lua/nvim-lsp-installer/fs.lua @@ -2,8 +2,8 @@ local uv = vim.loop local M = {} function M.mkdirp(path) - if os.execute(("mkdir -p %q"):format(path)) ~= 0 then - error(("mkdirp: Could not create directory %q"):format(path)) + if vim.fn.mkdir(path, "p") ~= 1 then + error(("mkdirp: Could not create directory %q."):format(path)) end end @@ -29,9 +29,8 @@ function M.fstat(path) end function M.rmrf(path) - -- giggity - if os.execute(("rm -rf %q"):format(path)) ~= 0 then - error(("rmrf: Could not remove directory %q"):format(path)) + if vim.fn.delete(path, "rf") ~= 0 then + error(("rmrf: Could not remove directory %q."):format(path)) end end diff --git a/lua/nvim-lsp-installer/server.lua b/lua/nvim-lsp-installer/server.lua index 95797e10..5e3c9e87 100644 --- a/lua/nvim-lsp-installer/server.lua +++ b/lua/nvim-lsp-installer/server.lua @@ -79,7 +79,9 @@ function M.Server:install() end function M.Server:uninstall() - fs.rmrf(self._root_dir) + if fs.dir_exists(self._root_dir) then + fs.rmrf(self._root_dir) + end end return M -- cgit v1.2.3-70-g09d2