diff options
| author | William Boman <william@redwill.se> | 2021-10-17 22:47:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-17 22:47:11 +0200 |
| commit | 5679a8bd21c25c33f4fb971ed09241e327f9fa76 (patch) | |
| tree | fc48ea4ef39e23548a837ca3d64732fda74285ca /lua/nvim-lsp-installer/installers/std.lua | |
| parent | add powershell_es (#168) (diff) | |
| download | mason-5679a8bd21c25c33f4fb971ed09241e327f9fa76.tar mason-5679a8bd21c25c33f4fb971ed09241e327f9fa76.tar.gz mason-5679a8bd21c25c33f4fb971ed09241e327f9fa76.tar.bz2 mason-5679a8bd21c25c33f4fb971ed09241e327f9fa76.tar.lz mason-5679a8bd21c25c33f4fb971ed09241e327f9fa76.tar.xz mason-5679a8bd21c25c33f4fb971ed09241e327f9fa76.tar.zst mason-5679a8bd21c25c33f4fb971ed09241e327f9fa76.zip | |
add vala_ls (#167)
Diffstat (limited to 'lua/nvim-lsp-installer/installers/std.lua')
| -rw-r--r-- | lua/nvim-lsp-installer/installers/std.lua | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/lua/nvim-lsp-installer/installers/std.lua b/lua/nvim-lsp-installer/installers/std.lua index b9e6f74f..c011279d 100644 --- a/lua/nvim-lsp-installer/installers/std.lua +++ b/lua/nvim-lsp-installer/installers/std.lua @@ -43,7 +43,7 @@ function M.unzip(file, dest) end, win = shell.powershell(("Expand-Archive -Path %q -DestinationPath %q"):format(file, dest)), }, - installers.always_succeed(M.delete_file(file)), + installers.always_succeed(M.rmrf(file)), } end @@ -63,7 +63,7 @@ function M.untar(file) stdio_sink = context.stdio_sink, }, callback) end, - installers.always_succeed(M.delete_file(file)), + installers.always_succeed(M.rmrf(file)), } end @@ -91,7 +91,7 @@ local function win_extract(file) on_finish = callback, } end, - installers.always_succeed(M.delete_file(file)), + installers.always_succeed(M.rmrf(file)), } end @@ -112,7 +112,7 @@ local function win_arc_unarchive(file) stdio_sink = context.stdio_sink, }, callback) end, - installers.always_succeed(M.delete_file(file)), + installers.always_succeed(M.rmrf(file)), } end @@ -154,21 +154,24 @@ function M.gunzip_remote(url, out_file) return installers.pipe { M.download_file(url, archive), M.gunzip(archive), - installers.always_succeed(M.delete_file(archive)), + installers.always_succeed(M.rmrf(archive)), } end -function M.delete_file(file) - return installers.when { - unix = function(server, callback, context) - process.spawn("rm", { - args = { "-f", file }, - cwd = server.root_dir, - stdio_sink = context.stdio_sink, - }, callback) - end, - win = shell.powershell(("rm %q"):format(file)), - } +function M.rmrf(rel_path) + return function(server, callback, context) + local abs_path = path.concat { server.root_dir, rel_path } + context.stdio_sink.stdout(("Deleting %q\n"):format(abs_path)) + vim.schedule(function() + local ok = pcall(fs.rmrf, abs_path) + if ok then + callback(true) + else + context.stdio_sink.stderr(("Failed to delete %q.\n"):format(abs_path)) + callback(false) + end + end) + end end function M.git_clone(repo_url) @@ -201,17 +204,17 @@ end function M.ensure_executables(executables) return vim.schedule_wrap(function(_, callback, context) + local has_error = false for i = 1, #executables do local entry = executables[i] local executable = entry[1] local error_msg = entry[2] if vim.fn.executable(executable) ~= 1 then + has_error = true context.stdio_sink.stderr(error_msg .. "\n") - callback(false) - return end end - callback(true) + callback(not has_error) end) end |
