diff options
| author | William Boman <william@redwill.se> | 2021-10-06 15:37:38 +0200 |
|---|---|---|
| committer | William Boman <william@redwill.se> | 2021-10-06 21:52:02 +0200 |
| commit | 28724b26460e22318354fc8c882b06289f09eb2e (patch) | |
| tree | 8d081cb703fd3de1b144f001c1ca3de13296f246 /lua | |
| parent | lemminx: fix std.rename call (diff) | |
| download | mason-28724b26460e22318354fc8c882b06289f09eb2e.tar mason-28724b26460e22318354fc8c882b06289f09eb2e.tar.gz mason-28724b26460e22318354fc8c882b06289f09eb2e.tar.bz2 mason-28724b26460e22318354fc8c882b06289f09eb2e.tar.lz mason-28724b26460e22318354fc8c882b06289f09eb2e.tar.xz mason-28724b26460e22318354fc8c882b06289f09eb2e.tar.zst mason-28724b26460e22318354fc8c882b06289f09eb2e.zip | |
lemminx: fix std.rename call
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-lsp-installer/fs.lua | 6 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/server.lua | 1 | ||||
| -rw-r--r-- | lua/nvim-lsp-installer/servers/lemminx/init.lua | 27 |
3 files changed, 19 insertions, 15 deletions
diff --git a/lua/nvim-lsp-installer/fs.lua b/lua/nvim-lsp-installer/fs.lua index e6864685..775809fd 100644 --- a/lua/nvim-lsp-installer/fs.lua +++ b/lua/nvim-lsp-installer/fs.lua @@ -1,4 +1,5 @@ local pathm = require "nvim-lsp-installer.path" +local log = require "nvim-lsp-installer.log" local uv = vim.loop local M = {} @@ -10,21 +11,26 @@ local function assert_ownership(path) end function M.rmrf(path) + log.debug("fs: rmrf", path) assert_ownership(path) if vim.fn.delete(path, "rf") ~= 0 then + log.debug "fs: rmrf failed" error(("rmrf: Could not remove directory %q."):format(path)) end end function M.rename(path, new_path) + log.debug("fs: rename", path, new_path) assert_ownership(path) assert_ownership(new_path) uv.fs_rename(path, new_path) end function M.mkdirp(path) + log.debug("fs: mkdirp", path) assert_ownership(path) if vim.fn.mkdir(path, "p") ~= 1 then + log.debug "fs: mkdirp failed" error(("mkdirp: Could not create directory %q."):format(path)) end end diff --git a/lua/nvim-lsp-installer/server.lua b/lua/nvim-lsp-installer/server.lua index f3ad3fe1..4c8d4e65 100644 --- a/lua/nvim-lsp-installer/server.lua +++ b/lua/nvim-lsp-installer/server.lua @@ -110,6 +110,7 @@ function M.Server:install_attached(context, callback) end function M.Server:uninstall() + log.debug("Uninstalling server", self.name) if fs.dir_exists(self.root_dir) then fs.rmrf(self.root_dir) end diff --git a/lua/nvim-lsp-installer/servers/lemminx/init.lua b/lua/nvim-lsp-installer/servers/lemminx/init.lua index 038ab536..ef52c149 100644 --- a/lua/nvim-lsp-installer/servers/lemminx/init.lua +++ b/lua/nvim-lsp-installer/servers/lemminx/init.lua @@ -9,17 +9,18 @@ local platform = require "nvim-lsp-installer.platform" local coalesce, when = Data.coalesce, Data.when return function(name, root_dir) - local file = coalesce( - when(platform.is_mac, "lemminx-osx-x86_64.zip"), - when(platform.is_linux, "lemminx-linux.zip"), - when(platform.is_win, "lemminx-win32.zip") + local unzipped_file = coalesce( + when(platform.is_mac, "lemminx-osx-x86_64"), + when(platform.is_linux, "lemminx-linux"), + when(platform.is_win, "lemminx-win32") ) + return server.Server:new { name = name, root_dir = root_dir, installer = { function(_, callback, ctx) - if not file then + if not unzipped_file then ctx.stdio_sink.stderr( ("Your operating system or architecture (%q) is not yet supported."):format(platform.arch) ) @@ -33,20 +34,16 @@ return function(name, root_dir) end), context.capture(function(ctx) return std.unzip_remote( - ("https://download.jboss.org/jbosstools/vscode/stable/lemminx-binary/%s/%s"):format( + ("https://download.jboss.org/jbosstools/vscode/stable/lemminx-binary/%s/%s.zip"):format( ctx.requested_server_version, - file + unzipped_file ) ) end), - function(server, callback, ctx) - local unzipped_file = file:gsub(".zip$", "") - local old_path = path.concat { server.root_dir, unzipped_file } - local new_path = path.concat { server.root_dir, platform.is_win and "lemminx.exe" or "lemminx" } - ctx.stdio_sink.stdout(("Renaming %q to %q."):format(old_path, new_path)) - local ok, result = pcall(fs.rename, old_path, new_path) - callback(ok and result) - end, + std.rename( + platform.is_win and ("%s.exe"):format(unzipped_file) or unzipped_file, + platform.is_win and "lemminx.exe" or "lemminx" + ) }, default_options = { cmd = { path.concat { root_dir, "lemminx" } }, |
