diff options
| author | William Boman <william@redwill.se> | 2022-04-21 12:09:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-21 12:09:59 +0200 |
| commit | b68fcc6bb2c770495ff8e2508c06dfdd49abcc80 (patch) | |
| tree | df7c71efb59958deb21a18eeccf3e3c43c4cd704 /lua/nvim-lsp-installer/servers/zls/init.lua | |
| parent | run autogen_metadata.lua (diff) | |
| download | mason-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/zls/init.lua')
| -rw-r--r-- | lua/nvim-lsp-installer/servers/zls/init.lua | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/lua/nvim-lsp-installer/servers/zls/init.lua b/lua/nvim-lsp-installer/servers/zls/init.lua index 21d52239..c902f4aa 100644 --- a/lua/nvim-lsp-installer/servers/zls/init.lua +++ b/lua/nvim-lsp-installer/servers/zls/init.lua @@ -2,41 +2,39 @@ local path = require "nvim-lsp-installer.path" local server = require "nvim-lsp-installer.server" local platform = require "nvim-lsp-installer.platform" local Data = require "nvim-lsp-installer.data" -local context = require "nvim-lsp-installer.installers.context" -local std = require "nvim-lsp-installer.installers.std" local process = require "nvim-lsp-installer.process" +local github = require "nvim-lsp-installer.core.managers.github" +local std = require "nvim-lsp-installer.core.managers.std" local coalesce, when = Data.coalesce, Data.when return function(name, root_dir) - local archive_name = coalesce( - when(platform.is_mac, "x86_64-macos.tar.xz"), - when( - platform.is_linux, - coalesce( - when(platform.arch == "x64", "x86_64-linux.tar.xz"), - when(platform.arch == "x86", "i386-linux.tar.xz") - ) - ), - when(platform.is_win and platform.arch == "x64", "x86_64-windows.tar.xz") - ) - return server.Server:new { name = name, root_dir = root_dir, homepage = "https://github.com/zigtools/zls", languages = { "zig" }, - installer = { - context.use_github_release_file("zigtools/zls", archive_name), - context.capture(function(ctx) - return std.untarxz_remote(ctx.github_release_file) - end), - std.rename("bin", "package"), - std.chmod("+x", { path.concat { "package", "zls" } }), - context.receipt(function(receipt, ctx) - receipt:with_primary_source(receipt.github_release_file(ctx)) - end), - }, + async = true, + ---@param ctx InstallContext + installer = function(ctx) + local asset_file = coalesce( + when(platform.is_mac, "x86_64-macos.tar.xz"), + when( + platform.is_linux, + coalesce( + when(platform.arch == "x64", "x86_64-linux.tar.xz"), + when(platform.arch == "x86", "i386-linux.tar.xz") + ) + ), + when(platform.is_win and platform.arch == "x64", "x86_64-windows.tar.xz") + ) + github.untarxz_release_file({ + repo = "zigtools/zls", + asset_file = asset_file, + }).with_receipt() + ctx.fs:rename("bin", "package") + std.chmod("+x", { path.concat { "package", "zls" } }) + end, default_options = { cmd_env = { PATH = process.extend_path { path.concat { root_dir, "package" } }, |
