aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/lemminx/init.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-04-21 12:09:59 +0200
committerGitHub <noreply@github.com>2022-04-21 12:09:59 +0200
commitb68fcc6bb2c770495ff8e2508c06dfdd49abcc80 (patch)
treedf7c71efb59958deb21a18eeccf3e3c43c4cd704 /lua/nvim-lsp-installer/servers/lemminx/init.lua
parentrun autogen_metadata.lua (diff)
downloadmason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.gz
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.bz2
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.lz
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.xz
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.tar.zst
mason-b68fcc6bb2c770495ff8e2508c06dfdd49abcc80.zip
chore: refactor remaining installers to async impl (#616)
Diffstat (limited to 'lua/nvim-lsp-installer/servers/lemminx/init.lua')
-rw-r--r--lua/nvim-lsp-installer/servers/lemminx/init.lua61
1 files changed, 25 insertions, 36 deletions
diff --git a/lua/nvim-lsp-installer/servers/lemminx/init.lua b/lua/nvim-lsp-installer/servers/lemminx/init.lua
index b7eebd23..97de73f4 100644
--- a/lua/nvim-lsp-installer/servers/lemminx/init.lua
+++ b/lua/nvim-lsp-installer/servers/lemminx/init.lua
@@ -1,54 +1,43 @@
local server = require "nvim-lsp-installer.server"
-local std = require "nvim-lsp-installer.installers.std"
local Data = require "nvim-lsp-installer.data"
-local context = require "nvim-lsp-installer.installers.context"
local platform = require "nvim-lsp-installer.platform"
local process = require "nvim-lsp-installer.process"
+local std = require "nvim-lsp-installer.core.managers.std"
local coalesce, when = Data.coalesce, Data.when
return function(name, root_dir)
- 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,
languages = { "xml" },
homepage = "https://github.com/eclipse/lemminx",
- installer = {
- function(_, callback, ctx)
- if not unzipped_file then
- ctx.stdio_sink.stderr(
- ("Your operating system or architecture (%q) is not yet supported."):format(platform.arch)
- )
- callback(false)
- else
- callback(true)
- end
- end,
- context.set(function(ctx)
- ctx.requested_server_version = coalesce(ctx.requested_server_version, "0.19.2-655")
- end),
- context.capture(function(ctx)
- return std.unzip_remote(
- ("https://download.jboss.org/jbosstools/vscode/snapshots/lemminx-binary/%s/%s.zip"):format(
- ctx.requested_server_version,
- unzipped_file
- )
- )
- end),
- std.rename(
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ local unzipped_file = assert(
+ coalesce(
+ when(platform.is_mac, "lemminx-osx-x86_64"),
+ when(platform.is_linux, "lemminx-linux"),
+ when(platform.is_win, "lemminx-win32")
+ ),
+ ("Your operating system or architecture (%q) is not yet supported."):format(platform.arch)
+ )
+
+ std.download_file(
+ ("https://download.jboss.org/jbosstools/vscode/snapshots/lemminx-binary/%s/%s.zip"):format(
+ ctx.requested_version:or_else "0.19.2-655", -- TODO: resolve latest version dynamically
+ unzipped_file
+ ),
+ "lemminx.zip"
+ )
+ std.unzip("lemminx.zip", ".")
+ ctx.fs:rename(
platform.is_win and ("%s.exe"):format(unzipped_file) or unzipped_file,
platform.is_win and "lemminx.exe" or "lemminx"
- ),
- context.receipt(function(receipt)
- receipt:with_primary_source(receipt.unmanaged)
- end),
- },
+ )
+ ctx.receipt:with_primary_source(ctx.receipt.unmanaged)
+ end,
default_options = {
cmd_env = {
PATH = process.extend_path { root_dir },