diff options
59 files changed, 666 insertions, 555 deletions
diff --git a/lua/mason-lspconfig/init.lua b/lua/mason-lspconfig/init.lua index 850c1069..b81bef70 100644 --- a/lua/mason-lspconfig/init.lua +++ b/lua/mason-lspconfig/init.lua @@ -19,10 +19,8 @@ end ---@param lspconfig_server_name string function M.resolve_server_config_factory(lspconfig_server_name) - local ok, server_config = pcall( - require, - ("mason.adapters.lspconfig.server_configurations.%s"):format(lspconfig_server_name) - ) + local ok, server_config = + pcall(require, ("mason.adapters.lspconfig.server_configurations.%s"):format(lspconfig_server_name)) if ok then return Optional.of(server_config) end diff --git a/lua/mason-lspconfig/settings.lua b/lua/mason-lspconfig/settings.lua index e7dc0e57..23d1bdfb 100644 --- a/lua/mason-lspconfig/settings.lua +++ b/lua/mason-lspconfig/settings.lua @@ -1,7 +1,7 @@ local M = {} ---@class MasonLspconfigSettings -local DEFAULT_SETTINGS = { +local DEFAULT_SETTINGS = { -- A list of servers to automatically install if they're not already installed. Example: { "rust-analyzer@nightly", "sumneko_lua" } -- This setting has no relation with the `automatic_installation` setting. ensure_installed = {}, diff --git a/lua/mason/core/fetch.lua b/lua/mason/core/fetch.lua index ba9dd9a7..cf2e3d83 100644 --- a/lua/mason/core/fetch.lua +++ b/lua/mason/core/fetch.lua @@ -64,21 +64,21 @@ local function fetch(url, opts) return platform_specific :recover_catching(function() - local headers = _.sort_by( - _.identity, - _.map(_.compose(_.format "--header='%s'", _.join ": "), _.to_pairs(opts.headers)) - ) - return spawn.wget({ - headers, - "-nv", - "-O", - opts.out_file or "-", - ("--method=%s"):format(opts.method), - opts.data and { - ("--body-data=%s"):format(opts.data) or vim.NIL, - } or vim.NIL, - url, - }):get_or_throw() + local headers = + _.sort_by(_.identity, _.map(_.compose(_.format "--header='%s'", _.join ": "), _.to_pairs(opts.headers))) + return spawn + .wget({ + headers, + "-nv", + "-O", + opts.out_file or "-", + ("--method=%s"):format(opts.method), + opts.data and { + ("--body-data=%s"):format(opts.data) or vim.NIL, + } or vim.NIL, + url, + }) + :get_or_throw() end) :recover_catching(function() local headers = _.sort_by( @@ -90,25 +90,27 @@ local function fetch(url, opts) _.to_pairs(opts.headers) ) ) - return spawn.curl({ - headers, - "-fsSL", - { - "-X", - opts.method, - }, - opts.data and { "-d", "@-" } or vim.NIL, - opts.out_file and { "-o", opts.out_file } or vim.NIL, - url, - on_spawn = function(_, stdio) - local stdin = stdio[1] - if opts.data then - log.trace("Writing stdin to curl", opts.data) - stdin:write(opts.data) - end - stdin:close() - end, - }):get_or_throw() + return spawn + .curl({ + headers, + "-fsSL", + { + "-X", + opts.method, + }, + opts.data and { "-d", "@-" } or vim.NIL, + opts.out_file and { "-o", opts.out_file } or vim.NIL, + url, + on_spawn = function(_, stdio) + local stdin = stdio[1] + if opts.data then + log.trace("Writing stdin to curl", opts.data) + stdin:write(opts.data) + end + stdin:close() + end, + }) + :get_or_throw() end) :map(function(result) if opts.out_file then diff --git a/lua/mason/core/installer/handle.lua b/lua/mason/core/installer/handle.lua index 42ea58b6..174f7ed6 100644 --- a/lua/mason/core/installer/handle.lua +++ b/lua/mason/core/installer/handle.lua @@ -139,12 +139,12 @@ function InstallHandle:kill(signal) end ---@param pid integer -local win_taskkill = a.scope(function (pid) +local win_taskkill = a.scope(function(pid) spawn.taskkill { "/f", "/t", "/pid", - pid + pid, } end) diff --git a/lua/mason/core/installer/linker.lua b/lua/mason/core/installer/linker.lua index be5e8d82..e81f81a5 100644 --- a/lua/mason/core/installer/linker.lua +++ b/lua/mason/core/installer/linker.lua @@ -25,7 +25,7 @@ end ---@param to string local function relative_path_from_bin(to) local _, match_end = to:find(path.install_prefix(), 1, true) - assert(match_end, "Failed to produce relative path.") + assert(match_end, "Failed to produce relative path.") local relative_path = to:sub(match_end + 1) return ".." .. relative_path end diff --git a/lua/mason/core/managers/cargo/init.lua b/lua/mason/core/managers/cargo/init.lua index f845e7d8..aeab65ab 100644 --- a/lua/mason/core/managers/cargo/init.lua +++ b/lua/mason/core/managers/cargo/init.lua @@ -112,20 +112,22 @@ end ---@param receipt InstallReceipt ---@param install_dir string function M.get_installed_primary_package_version(receipt, install_dir) - return spawn.cargo({ - "install", - "--list", - "--root", - ".", - cwd = install_dir, - }):map_catching(function(result) - local installed_crates = M.parse_installed_crates(result.stdout) - if vim.in_fast_event() then - a.scheduler() -- needed because vim.fn.* call - end - local package = vim.fn.fnamemodify(receipt.primary_source.package, ":t") - return Optional.of_nilable(installed_crates[package]):or_else_throw "Failed to find cargo package version." - end) + return spawn + .cargo({ + "install", + "--list", + "--root", + ".", + cwd = install_dir, + }) + :map_catching(function(result) + local installed_crates = M.parse_installed_crates(result.stdout) + if vim.in_fast_event() then + a.scheduler() -- needed because vim.fn.* call + end + local package = vim.fn.fnamemodify(receipt.primary_source.package, ":t") + return Optional.of_nilable(installed_crates[package]):or_else_throw "Failed to find cargo package version." + end) end ---@param install_dir string diff --git a/lua/mason/core/managers/composer/init.lua b/lua/mason/core/managers/composer/init.lua index a0656ba7..98419b8c 100644 --- a/lua/mason/core/managers/composer/init.lua +++ b/lua/mason/core/managers/composer/init.lua @@ -79,28 +79,30 @@ function M.check_outdated_primary_package(receipt, install_dir) if receipt.primary_source.type ~= "composer" then return Result.failure "Receipt does not have a primary source of type composer" end - return spawn.composer({ - "outdated", - "--no-interaction", - "--format=json", - cwd = install_dir, - }):map_catching(function(result) - local outdated_packages = vim.json.decode(result.stdout) - local outdated_package = _.find_first(function(package) - return package.name == receipt.primary_source.package - end, outdated_packages.installed) - return Optional.of_nilable(outdated_package) - :map(function(package) - if package.version ~= package.latest then - return { - name = package.name, - current_version = package.version, - latest_version = package.latest, - } - end - end) - :or_else_throw "Primary package is not outdated." - end) + return spawn + .composer({ + "outdated", + "--no-interaction", + "--format=json", + cwd = install_dir, + }) + :map_catching(function(result) + local outdated_packages = vim.json.decode(result.stdout) + local outdated_package = _.find_first(function(package) + return package.name == receipt.primary_source.package + end, outdated_packages.installed) + return Optional.of_nilable(outdated_package) + :map(function(package) + if package.version ~= package.latest then + return { + name = package.name, + current_version = package.version, + latest_version = package.latest, + } + end + end) + :or_else_throw "Primary package is not outdated." + end) end ---@async @@ -110,15 +112,17 @@ function M.get_installed_primary_package_version(receipt, install_dir) if receipt.primary_source.type ~= "composer" then return Result.failure "Receipt does not have a primary source of type composer" end - return spawn.composer({ - "info", - "--format=json", - receipt.primary_source.package, - cwd = install_dir, - }):map_catching(function(result) - local info = vim.json.decode(result.stdout) - return info.versions[1] - end) + return spawn + .composer({ + "info", + "--format=json", + receipt.primary_source.package, + cwd = install_dir, + }) + :map_catching(function(result) + local info = vim.json.decode(result.stdout) + return info.versions[1] + end) end ---@param install_dir string diff --git a/lua/mason/core/managers/gem/init.lua b/lua/mason/core/managers/gem/init.lua index 0aa900b5..f4056c8f 100644 --- a/lua/mason/core/managers/gem/init.lua +++ b/lua/mason/core/managers/gem/init.lua @@ -134,14 +134,17 @@ end ---@param receipt InstallReceipt ---@param install_dir string function M.get_installed_primary_package_version(receipt, install_dir) - return spawn.gem({ - "list", - cwd = install_dir, - env = M.env(install_dir), - }):map_catching(function(result) - local gems = M.parse_gem_list_output(result.stdout) - return Optional.of_nilable(gems[receipt.primary_source.package]):or_else_throw "Failed to find gem package version." - end) + return spawn + .gem({ + "list", + cwd = install_dir, + env = M.env(install_dir), + }) + :map_catching(function(result) + local gems = M.parse_gem_list_output(result.stdout) + return Optional.of_nilable(gems[receipt.primary_source.package]) + :or_else_throw "Failed to find gem package version." + end) end ---@param install_dir string diff --git a/lua/mason/core/managers/git/init.lua b/lua/mason/core/managers/git/init.lua index 517557e0..5b8fe4d1 100644 --- a/lua/mason/core/managers/git/init.lua +++ b/lua/mason/core/managers/git/init.lua @@ -61,14 +61,16 @@ end ---@param receipt InstallReceipt ---@param install_dir string function M.get_installed_revision(receipt, install_dir) - return spawn.git({ - "rev-parse", - "--short", - "HEAD", - cwd = install_dir, - }):map_catching(function(result) - return assert(vim.trim(result.stdout)) - end) + return spawn + .git({ + "rev-parse", + "--short", + "HEAD", + cwd = install_dir, + }) + :map_catching(function(result) + return assert(vim.trim(result.stdout)) + end) end return M diff --git a/lua/mason/core/managers/github/client.lua b/lua/mason/core/managers/github/client.lua index 99398c59..ba052545 100644 --- a/lua/mason/core/managers/github/client.lua +++ b/lua/mason/core/managers/github/client.lua @@ -12,7 +12,8 @@ local M = {} ---@param path string ---@return Result @JSON decoded response. local function api_call(path) - return spawn.gh({ "api", path }) + return spawn + .gh({ "api", path }) :map(_.prop "stdout") :recover_catching(function() return fetch(("https://api.github.com/%s"):format(path)):get_or_throw() diff --git a/lua/mason/core/managers/github/init.lua b/lua/mason/core/managers/github/init.lua index aa44073f..549cff86 100644 --- a/lua/mason/core/managers/github/init.lua +++ b/lua/mason/core/managers/github/init.lua @@ -41,7 +41,8 @@ end function M.release_file(opts) local ctx = installer.context() local release = _.coalesce(opts.version, ctx.requested_version):or_else_get(function() - return client.fetch_latest_release(opts.repo) + return client + .fetch_latest_release(opts.repo) :map(_.prop "tag_name") :get_or_throw "Failed to fetch latest release from GitHub API. Refer to :h mason-errors-github-api for more information." end) diff --git a/lua/mason/core/managers/go/init.lua b/lua/mason/core/managers/go/init.lua index d83f2e16..fe5c7289 100644 --- a/lua/mason/core/managers/go/init.lua +++ b/lua/mason/core/managers/go/init.lua @@ -90,43 +90,49 @@ function M.get_installed_primary_package_version(receipt, install_dir) end -- trims e.g. golang.org/x/tools/gopls to gopls local executable = vim.fn.fnamemodify(receipt.primary_source.package, ":t") - return spawn.go({ - "version", - "-m", - platform.is_win and ("%s.exe"):format(executable) or executable, - cwd = install_dir, - }):map_catching(function(result) - local parsed_output = M.parse_mod_version_output(result.stdout) - return Optional.of_nilable(parsed_output.mod[receipt.primary_source.package]):or_else_throw "Failed to parse mod version" - end) + return spawn + .go({ + "version", + "-m", + platform.is_win and ("%s.exe"):format(executable) or executable, + cwd = install_dir, + }) + :map_catching(function(result) + local parsed_output = M.parse_mod_version_output(result.stdout) + return Optional.of_nilable(parsed_output.mod[receipt.primary_source.package]) + :or_else_throw "Failed to parse mod version" + end) end ---@async ---@param receipt InstallReceipt ---@param install_dir string function M.check_outdated_primary_package(receipt, install_dir) - return spawn.go({ - "list", - "-json", - "-m", - ("%s@latest"):format(receipt.primary_source.package), - cwd = install_dir, - }):map_catching(function(result) - ---@type {Path: string, Version: string} - local output = vim.json.decode(result.stdout) - return Optional.of_nilable(output.Version) - :map(function(latest_version) - local installed_version = M.get_installed_primary_package_version(receipt, install_dir):get_or_throw() - if installed_version ~= latest_version then - return { - name = receipt.primary_source.package, - current_version = assert(installed_version), - latest_version = assert(latest_version), - } - end - end) - :or_else_throw "Primary package is not outdated." - end) + return spawn + .go({ + "list", + "-json", + "-m", + ("%s@latest"):format(receipt.primary_source.package), + cwd = install_dir, + }) + :map_catching(function(result) + ---@type {Path: string, Version: string} + local output = vim.json.decode(result.stdout) + return Optional.of_nilable(output.Version) + :map(function(latest_version) + local installed_version = + M.get_installed_primary_package_version(receipt, install_dir):get_or_throw() + if installed_version ~= latest_version then + return { + name = receipt.primary_source.package, + current_version = assert(installed_version), + latest_version = assert(latest_version), + } + end + end) + :or_else_throw "Primary package is not outdated." + end) end ---@param install_dir string diff --git a/lua/mason/core/managers/luarocks/init.lua b/lua/mason/core/managers/luarocks/init.lua index dee31cfd..7ce172a3 100644 --- a/lua/mason/core/managers/luarocks/init.lua +++ b/lua/mason/core/managers/luarocks/init.lua @@ -65,17 +65,19 @@ function M.get_installed_primary_package_version(receipt, install_dir) return Result.failure "Receipt does not have a primary source of type luarocks" end local primary_package = receipt.primary_source.package - return spawn.luarocks({ - "list", - "--tree", - install_dir, - "--porcelain", - }):map_catching(function(result) - local luarocks = M.parse_installed_rocks(result.stdout) - return Optional.of_nilable(_.find_first(_.prop_eq("package", primary_package), luarocks)) - :map(_.prop "version") - :or_else_throw() - end) + return spawn + .luarocks({ + "list", + "--tree", + install_dir, + "--porcelain", + }) + :map_catching(function(result) + local luarocks = M.parse_installed_rocks(result.stdout) + return Optional.of_nilable(_.find_first(_.prop_eq("package", primary_package), luarocks)) + :map(_.prop "version") + :or_else_throw() + end) end ---@alias OutdatedLuarock {name: string, installed: string, available: string, repo: string} @@ -98,27 +100,29 @@ function M.check_outdated_primary_package(receipt, install_dir) return Result.failure "Receipt does not have a primary source of type luarocks" end local primary_package = receipt.primary_source.package - return spawn.luarocks({ - "list", - "--outdated", - "--tree", - install_dir, - "--porcelain", - }):map_catching(function(result) - local outdated_rocks = M.parse_outdated_rocks(result.stdout) - return Optional.of_nilable(_.find_first(_.prop_eq("name", primary_package), outdated_rocks)) - :map( - ---@param outdated_rock OutdatedLuarock - function(outdated_rock) - return { - name = outdated_rock.name, - current_version = assert(outdated_rock.installed), - latest_version = assert(outdated_rock.available), - } - end - ) - :or_else_throw() - end) + return spawn + .luarocks({ + "list", + "--outdated", + "--tree", + install_dir, + "--porcelain", + }) + :map_catching(function(result) + local outdated_rocks = M.parse_outdated_rocks(result.stdout) + return Optional.of_nilable(_.find_first(_.prop_eq("name", primary_package), outdated_rocks)) + :map( + ---@param outdated_rock OutdatedLuarock + function(outdated_rock) + return { + name = outdated_rock.name, + current_version = assert(outdated_rock.installed), + latest_version = assert(outdated_rock.available), + } + end + ) + :or_else_throw() + end) end ---@param install_dir string diff --git a/lua/mason/core/managers/pip3/init.lua b/lua/mason/core/managers/pip3/init.lua index 629c6838..62755d93 100644 --- a/lua/mason/core/managers/pip3/init.lua +++ b/lua/mason/core/managers/pip3/init.lua @@ -98,34 +98,36 @@ function M.check_outdated_primary_package(receipt, install_dir) return Result.failure "Receipt does not have a primary source of type pip3" end local normalized_package = M.normalize_package(receipt.primary_source.package) - return spawn.python({ - "-m", - "pip", - "list", - "--outdated", - "--format=json", - cwd = install_dir, - with_paths = { M.venv_path(install_dir) }, - }):map_catching(function(result) - ---@alias PipOutdatedPackage {name: string, version: string, latest_version: string} - ---@type PipOutdatedPackage[] - local packages = vim.json.decode(result.stdout) + return spawn + .python({ + "-m", + "pip", + "list", + "--outdated", + "--format=json", + cwd = install_dir, + with_paths = { M.venv_path(install_dir) }, + }) + :map_catching(function(result) + ---@alias PipOutdatedPackage {name: string, version: string, latest_version: string} + ---@type PipOutdatedPackage[] + local packages = vim.json.decode(result.stdout) - local outdated_primary_package = _.find_first(function(outdated_package) - return outdated_package.name == normalized_package - and outdated_package.version ~= outdated_package.latest_version - end, packages) + local outdated_primary_package = _.find_first(function(outdated_package) + return outdated_package.name == normalized_package + and outdated_package.version ~= outdated_package.latest_version + end, packages) - return Optional.of_nilable(outdated_primary_package) - :map(function(package) - return { - name = normalized_package, - current_version = assert(package.version), - latest_version = assert(package.latest_version), - } - end) - :or_else_throw "Primary package is not outdated." - end) + return Optional.of_nilable(outdated_primary_package) + :map(function(package) + return { + name = normalized_package, + current_version = assert(package.version), + latest_version = assert(package.latest_version), + } + end) + :or_else_throw "Primary package is not outdated." + end) end ---@async @@ -135,25 +137,27 @@ function M.get_installed_primary_package_version(receipt, install_dir) if receipt.primary_source.type ~= "pip3" then return Result.failure "Receipt does not have a primary source of type pip3" end - return spawn.python({ - "-m", - "pip", - "list", - "--format=json", - cwd = install_dir, - with_paths = { M.venv_path(install_dir) }, - }):map_catching(function(result) - local pip_packages = vim.json.decode(result.stdout) - local normalized_pip_package = M.normalize_package(receipt.primary_source.package) - local pip_package = _.find_first(function(package) - return package.name == normalized_pip_package - end, pip_packages) - return Optional.of_nilable(pip_package) - :map(function(package) - return package.version - end) - :or_else_throw "Unable to find pip package." - end) + return spawn + .python({ + "-m", + "pip", + "list", + "--format=json", + cwd = install_dir, + with_paths = { M.venv_path(install_dir) }, + }) + :map_catching(function(result) + local pip_packages = vim.json.decode(result.stdout) + local normalized_pip_package = M.normalize_package(receipt.primary_source.package) + local pip_package = _.find_first(function(package) + return package.name == normalized_pip_package + end, pip_packages) + return Optional.of_nilable(pip_package) + :map(function(package) + return package.version + end) + :or_else_throw "Unable to find pip package." + end) end ---@param install_dir string diff --git a/lua/mason/core/managers/std/init.lua b/lua/mason/core/managers/std/init.lua index df368079..298d6999 100644 --- a/lua/mason/core/managers/std/init.lua +++ b/lua/mason/core/managers/std/init.lua @@ -53,8 +53,8 @@ function M.download_file(url, out_file) local ctx = installer.context() ctx.stdio_sink.stdout(("Downloading file %q...\n"):format(url)) fetch(url, { - out_file = path.concat { ctx.cwd:get(), out_file }, - }) + out_file = path.concat { ctx.cwd:get(), out_file }, + }) :map_err(function(err) return ("Failed to download file %q.\n%s"):format(url, err) end) diff --git a/lua/mason/core/package/version-check.lua b/lua/mason/core/package/version-check.lua index 484db0e9..54a1446b 100644 --- a/lua/mason/core/package/version-check.lua +++ b/lua/mason/core/package/version-check.lua @@ -77,7 +77,9 @@ local function version_check(provider_mapping) return function(receipt, install_dir) local check = provider_mapping[receipt.primary_source.type] if not check then - return Result.failure(( "Packages installed via %s does not yet support version check."):format(receipt.primary_source.type)) + return Result.failure( + ("Packages installed via %s does not yet support version check."):format(receipt.primary_source.type) + ) end return check(receipt, install_dir) end diff --git a/lua/mason/core/platform.lua b/lua/mason/core/platform.lua index 76ecb7e5..38c2220a 100644 --- a/lua/mason/core/platform.lua +++ b/lua/mason/core/platform.lua @@ -102,7 +102,8 @@ M.os_distribution = fun.lazy(function() return M.when { linux = function() local spawn = require "mason.core.spawn" - return spawn.bash({ "-c", "cat /etc/*-release" }) + return spawn + .bash({ "-c", "cat /etc/*-release" }) :map_catching(function(result) return parse_linux_dist(result.stdout) end) @@ -124,7 +125,8 @@ end) M.get_homebrew_prefix = fun.lazy(function() assert(M.is_mac, "Can only locate Homebrew installation on Mac systems.") local spawn = require "mason.core.spawn" - return spawn.brew({ "--prefix" }) + return spawn + .brew({ "--prefix" }) :map_catching(function(result) return vim.trim(result.stdout) end) diff --git a/lua/mason/core/spawn.lua b/lua/mason/core/spawn.lua index 60399361..b01acb6c 100644 --- a/lua/mason/core/spawn.lua +++ b/lua/mason/core/spawn.lua @@ -15,7 +15,7 @@ local spawn = { gradlew = platform.is_win and "gradlew.bat" or "gradlew", -- for hererocks installations luarocks = (platform.is_win and vim.fn.executable "luarocks.bat" == 1) and "luarocks.bat" or "luarocks", - rebar3 = platform.is_win and "rebar3.cmd" or "rebar3" + rebar3 = platform.is_win and "rebar3.cmd" or "rebar3", }, _flatten_cmd_args = _.compose(_.filter(_.complement(_.equals(vim.NIL))), _.flatten), } diff --git a/lua/mason/health/init.lua b/lua/mason/health/init.lua index 510b099a..e30c5dd5 100644 --- a/lua/mason/health/init.lua +++ b/lua/mason/health/init.lua @@ -60,21 +60,19 @@ end local function mk_healthcheck(callback) ---@param opts {cmd:string, args:string[], name: string, use_stderr:boolean} return function(opts) - local parse_version = _.compose( - _.head, - _.split "\n", - _.if_else(_.always(opts.use_stderr), _.prop "stderr", _.prop "stdout") - ) + local parse_version = + _.compose(_.head, _.split "\n", _.if_else(_.always(opts.use_stderr), _.prop "stderr", _.prop "stdout")) ---@async return function() - local healthcheck_result = spawn[opts.cmd]({ - opts.args, - on_spawn = function(_, stdio) - local stdin = stdio[1] - stdin:close() -- some processes (`sh` for example) will endlessly read from stdin, so we close it immediately - end, - }) + local healthcheck_result = spawn + [opts.cmd]({ + opts.args, + on_spawn = function(_, stdio) + local stdin = stdio[1] + stdin:close() -- some processes (`sh` for example) will endlessly read from stdin, so we close it immediately + end, + }) :map(parse_version) :map(function(version) if opts.version_check then @@ -263,7 +261,8 @@ function M.check() c() end - github_client.fetch_rate_limit() + github_client + .fetch_rate_limit() :map( ---@param rate_limit GitHubRateLimitResponse function(rate_limit) diff --git a/lua/mason/packages/ansible-language-server/init.lua b/lua/mason/packages/ansible-language-server/init.lua index dc894134..d1749e71 100644 --- a/lua/mason/packages/ansible-language-server/init.lua +++ b/lua/mason/packages/ansible-language-server/init.lua @@ -7,5 +7,5 @@ return Pkg.new { homepage = "https://github.com/ansible/ansible-language-server", languages = { Pkg.Lang.Ansible }, categories = { Pkg.Cat.LSP }, - install = npm.packages { "@ansible/ansible-language-server", bin = { "ansible-language-server"} }, + install = npm.packages { "@ansible/ansible-language-server", bin = { "ansible-language-server" } }, } diff --git a/lua/mason/packages/apex-language-server/init.lua b/lua/mason/packages/apex-language-server/init.lua index bf3bf3e9..0dad40e6 100644 --- a/lua/mason/packages/apex-language-server/init.lua +++ b/lua/mason/packages/apex-language-server/init.lua @@ -26,11 +26,13 @@ return Pkg.new { :get_or_throw() -- Result unwrap :or_else_throw "Failed to find release with assets." -- Optional unwrap - github.unzip_release_file({ - version = Optional.of(release.tag_name), - asset_file = _.compose(_.format "salesforcedx-vscode-apex-%s.vsix", _.gsub("^v", "")), - repo = repo, - }).with_receipt() + github + .unzip_release_file({ + version = Optional.of(release.tag_name), + asset_file = _.compose(_.format "salesforcedx-vscode-apex-%s.vsix", _.gsub("^v", "")), + repo = repo, + }) + .with_receipt() ctx.fs:rename(path.concat { "extension", "out", JAR_FILE }, JAR_FILE) ctx.fs:rmrf "extension" diff --git a/lua/mason/packages/bicep-lsp/init.lua b/lua/mason/packages/bicep-lsp/init.lua index 81e814d6..0e1eff44 100644 --- a/lua/mason/packages/bicep-lsp/init.lua +++ b/lua/mason/packages/bicep-lsp/init.lua @@ -17,10 +17,12 @@ return Pkg.new { ctx:chdir("vscode", function() -- The bicep-langserver.zip is a bit broken on POSIX systems - so we download it via the VSCode distribution -- instead. See https://github.com/Azure/bicep/issues/3704. - github.unzip_release_file({ - repo = "Azure/bicep", - asset_file = "vscode-bicep.vsix", - }).with_receipt() + github + .unzip_release_file({ + repo = "Azure/bicep", + asset_file = "vscode-bicep.vsix", + }) + .with_receipt() end) ctx.fs:rename(path.concat { "vscode", "extension", "bicepLanguageServer" }, "langserver") ctx.fs:rmrf "vscode" diff --git a/lua/mason/packages/bsl-language-server/init.lua b/lua/mason/packages/bsl-language-server/init.lua index 28a3e753..be28e06b 100644 --- a/lua/mason/packages/bsl-language-server/init.lua +++ b/lua/mason/packages/bsl-language-server/init.lua @@ -9,13 +9,15 @@ return Pkg.new { categories = { Pkg.Cat.LSP }, ---@async install = function() - github.download_release_file({ - repo = "1c-syntax/bsl-language-server", - out_file = "bsl-lsp.jar", - asset_file = function(release) - local version = release:gsub("^v", "") - return ("bsl-language-server-%s-exec.jar"):format(version) - end, - }).with_receipt() + github + .download_release_file({ + repo = "1c-syntax/bsl-language-server", + out_file = "bsl-lsp.jar", + asset_file = function(release) + local version = release:gsub("^v", "") + return ("bsl-language-server-%s-exec.jar"):format(version) + end, + }) + .with_receipt() end, } diff --git a/lua/mason/packages/ccls/common.lua b/lua/mason/packages/ccls/common.lua index 3226f397..728943a9 100644 --- a/lua/mason/packages/ccls/common.lua +++ b/lua/mason/packages/ccls/common.lua @@ -28,10 +28,10 @@ return function(opts) :map(function(llvm_dir) return { ("-DCMAKE_PREFIX_PATH=%s"):format(llvm_dir), - -- On Mac we use Homebrew LLVM which will persist after installation. - -- On Linux, and when a custom llvm_dir is provided, its clang resource dir will be the only - -- artifact persisted after installation, as the locally installed llvm installation will be - -- cleaned up after compilation. + -- On Mac we use Homebrew LLVM which will persist after installation. + -- On Linux, and when a custom llvm_dir is provided, its clang resource dir will be the only + -- artifact persisted after installation, as the locally installed llvm installation will be + -- cleaned up after compilation. not platform.is_mac and ("-DCLANG_RESOURCE_DIR=%s"):format(clang_resource_dir) or vim.NIL, } end) diff --git a/lua/mason/packages/clarity-lsp/init.lua b/lua/mason/packages/clarity-lsp/init.lua index 060d18fa..3c2b6da8 100644 --- a/lua/mason/packages/clarity-lsp/init.lua +++ b/lua/mason/packages/clarity-lsp/init.lua @@ -14,14 +14,16 @@ return Pkg.new { ---@async ---@param ctx InstallContext install = function(ctx) - github.unzip_release_file({ - repo = "hirosystems/clarity-lsp", - asset_file = coalesce( - when(platform.is.mac, "clarity-lsp-macos-x64.zip"), - when(platform.is.linux_x64, "clarity-lsp-linux-x64.zip"), - when(platform.is.win_x64, "clarity-lsp-windows-x64.zip") - ), - }).with_receipt() + github + .unzip_release_file({ + repo = "hirosystems/clarity-lsp", + asset_file = coalesce( + when(platform.is.mac, "clarity-lsp-macos-x64.zip"), + when(platform.is.linux_x64, "clarity-lsp-linux-x64.zip"), + when(platform.is.win_x64, "clarity-lsp-windows-x64.zip") + ), + }) + .with_receipt() ctx:link_bin("clarity-lsp", platform.is.win and "clarity-lsp.exe" or "clarity-lsp") end, } diff --git a/lua/mason/packages/clojure-lsp/init.lua b/lua/mason/packages/clojure-lsp/init.lua index 127fa80e..78e8461e 100644 --- a/lua/mason/packages/clojure-lsp/init.lua +++ b/lua/mason/packages/clojure-lsp/init.lua @@ -15,16 +15,18 @@ return Pkg.new { ---@async ---@param ctx InstallContext install = function(ctx) - github.unzip_release_file({ - repo = "clojure-lsp/clojure-lsp", - asset_file = coalesce( - when(platform.is.mac_arm64, "clojure-lsp-native-macos-aarch64.zip"), - when(platform.is.mac_x64, "clojure-lsp-native-macos-amd64.zip"), - when(platform.is.linux_x64, "clojure-lsp-native-linux-amd64.zip"), - when(platform.is.linux_arm64, "clojure-lsp-native-linux-aarch64.zip"), - when(platform.is_win, "clojure-lsp-native-windows-amd64.zip") - ), - }).with_receipt() + github + .unzip_release_file({ + repo = "clojure-lsp/clojure-lsp", + asset_file = coalesce( + when(platform.is.mac_arm64, "clojure-lsp-native-macos-aarch64.zip"), + when(platform.is.mac_x64, "clojure-lsp-native-macos-amd64.zip"), + when(platform.is.linux_x64, "clojure-lsp-native-linux-amd64.zip"), + when(platform.is.linux_arm64, "clojure-lsp-native-linux-aarch64.zip"), + when(platform.is_win, "clojure-lsp-native-windows-amd64.zip") + ), + }) + .with_receipt() std.chmod("+x", { "clojure-lsp" }) ctx:link_bin("clojure-lsp", platform.is.win and "clojure-lsp.exe" or "clojure-lsp") end, diff --git a/lua/mason/packages/codelldb/init.lua b/lua/mason/packages/codelldb/init.lua index 9949d95f..651ca882 100644 --- a/lua/mason/packages/codelldb/init.lua +++ b/lua/mason/packages/codelldb/init.lua @@ -13,17 +13,19 @@ return Pkg.new { ---@async ---@param ctx InstallContext install = function(ctx) - github.unzip_release_file({ - repo = "vadimcn/vscode-lldb", - asset_file = _.coalesce( - _.when(platform.is.mac_x64, "codelldb-x86_64-darwin.vsix"), - _.when(platform.is.mac_arm64, "codelldb-aarch64-darwin.vsix"), - _.when(platform.is.linux_x64, "codelldb-x86_64-linux.vsix"), - _.when(platform.is.linux_arm64, "codelldb-aarch64-linux.vsix"), - _.when(platform.is.linux_arm, "codelldb-arm-linux.vsix"), - _.when(platform.is.win_x64, "codelldb-x86_64-windows.vsix") - ), - }).with_receipt() + github + .unzip_release_file({ + repo = "vadimcn/vscode-lldb", + asset_file = _.coalesce( + _.when(platform.is.mac_x64, "codelldb-x86_64-darwin.vsix"), + _.when(platform.is.mac_arm64, "codelldb-aarch64-darwin.vsix"), + _.when(platform.is.linux_x64, "codelldb-x86_64-linux.vsix"), + _.when(platform.is.linux_arm64, "codelldb-aarch64-linux.vsix"), + _.when(platform.is.linux_arm, "codelldb-arm-linux.vsix"), + _.when(platform.is.win_x64, "codelldb-x86_64-windows.vsix") + ), + }) + .with_receipt() ctx:link_bin( "codelldb", path.concat { "extension", "adapter", platform.is.win and "codelldb.exe" or "codelldb" } diff --git a/lua/mason/packages/codeql/init.lua b/lua/mason/packages/codeql/init.lua index fd27f938..849c355d 100644 --- a/lua/mason/packages/codeql/init.lua +++ b/lua/mason/packages/codeql/init.lua @@ -2,7 +2,7 @@ local Pkg = require "mason.core.package" local _ = require "mason.core.functional" local platform = require "mason.core.platform" local github = require "mason.core.managers.github" -local path = require "mason.core.path" +local path = require "mason.core.path" local coalesce, when = _.coalesce, _.when @@ -15,14 +15,16 @@ return Pkg.new { ---@async ---@param ctx InstallContext install = function(ctx) - github.unzip_release_file({ - repo = "github/codeql-cli-binaries", - asset_file = coalesce( - when(platform.is.mac, "codeql-osx64.zip"), - when(platform.is.linux_x64, "codeql-linux64.zip"), - when(platform.is.win_x64, "codeql-win64.zip") - ), - }).with_receipt() + github + .unzip_release_file({ + repo = "github/codeql-cli-binaries", + asset_file = coalesce( + when(platform.is.mac, "codeql-osx64.zip"), + when(platform.is.linux_x64, "codeql-linux64.zip"), + when(platform.is.win_x64, "codeql-win64.zip") + ), + }) + .with_receipt() ctx:link_bin("codeql", path.concat { "codeql", platform.is.win and "codeql.cmd" or "codeql" }) end, } diff --git a/lua/mason/packages/cpptools/init.lua b/lua/mason/packages/cpptools/init.lua index 944bf2d2..1ef5ffa2 100644 --- a/lua/mason/packages/cpptools/init.lua +++ b/lua/mason/packages/cpptools/init.lua @@ -14,19 +14,21 @@ return Pkg.new { ---@async ---@param ctx InstallContext install = function(ctx) - github.unzip_release_file({ - repo = "microsoft/vscode-cpptools", - asset_file = _.coalesce( - _.when(platform.is.mac_x64, "cpptools-osx.vsix"), - _.when(platform.is.mac_arm64, "cpptools-osx-arm64.vsix"), - _.when(platform.is.linux_x64, "cpptools-linux.vsix"), - _.when(platform.is.linux_arm64, "cpptools-linux-aarch64.vsix"), - _.when(platform.is.linux_arm, "cpptools-linux-armhf.vsix"), - _.when(platform.is.win_x64, "cpptools-win64.vsix"), - _.when(platform.is.win_arm64, "cpptools-win-arm64.vsix"), - _.when(platform.is.win_x86, "cpptools-win32.vsix") - ), - }).with_receipt() + github + .unzip_release_file({ + repo = "microsoft/vscode-cpptools", + asset_file = _.coalesce( + _.when(platform.is.mac_x64, "cpptools-osx.vsix"), + _.when(platform.is.mac_arm64, "cpptools-osx-arm64.vsix"), + _.when(platform.is.linux_x64, "cpptools-linux.vsix"), + _.when(platform.is.linux_arm64, "cpptools-linux-aarch64.vsix"), + _.when(platform.is.linux_arm, "cpptools-linux-armhf.vsix"), + _.when(platform.is.win_x64, "cpptools-win64.vsix"), + _.when(platform.is.win_arm64, "cpptools-win-arm64.vsix"), + _.when(platform.is.win_x86, "cpptools-win32.vsix") + ), + }) + .with_receipt() local debug_executable = path.concat { "extension", diff --git a/lua/mason/packages/crystalline/init.lua b/lua/mason/packages/crystalline/init.lua index 9881cd90..22d426fc 100644 --- a/lua/mason/packages/crystalline/init.lua +++ b/lua/mason/packages/crystalline/init.lua @@ -15,14 +15,16 @@ return Pkg.new { ---@async ---@param ctx InstallContext install = function(ctx) - github.gunzip_release_file({ - repo = "elbywan/crystalline", - asset_file = coalesce( - when(platform.is.mac_x64, "crystalline_x86_64-apple-darwin.gz"), - when(platform.is.linux_x64, "crystalline_x86_64-unknown-linux-gnu.gz") - ), - out_file = "crystalline", - }).with_receipt() + github + .gunzip_release_file({ + repo = "elbywan/crystalline", + asset_file = coalesce( + when(platform.is.mac_x64, "crystalline_x86_64-apple-darwin.gz"), + when(platform.is.linux_x64, "crystalline_x86_64-unknown-linux-gnu.gz") + ), + out_file = "crystalline", + }) + .with_receipt() std.chmod("+x", { "crystalline" }) ctx:link_bin("crystalline", "crystalline") end, diff --git a/lua/mason/packages/deno/init.lua b/lua/mason/packages/deno/init.lua index 19390dc5..1ec24302 100644 --- a/lua/mason/packages/deno/init.lua +++ b/lua/mason/packages/deno/init.lua @@ -14,15 +14,17 @@ return Pkg.new { ---@async ---@param ctx InstallContext install = function(ctx) - github.unzip_release_file({ - repo = "denoland/deno", - asset_file = coalesce( - when(platform.is.mac_arm64, "deno-aarch64-apple-darwin.zip"), - when(platform.is.mac_x64, "deno-x86_64-apple-darwin.zip"), - when(platform.is.linux_x64, "deno-x86_64-unknown-linux-gnu.zip"), - when(platform.is.win_x64, "deno-x86_64-pc-windows-msvc.zip") - ), - }).with_receipt() + github + .unzip_release_file({ + repo = "denoland/deno", + asset_file = coalesce( + when(platform.is.mac_arm64, "deno-aarch64-apple-darwin.zip"), + when(platform.is.mac_x64, "deno-x86_64-apple-darwin.zip"), + when(platform.is.linux_x64, "deno-x86_64-unknown-linux-gnu.zip"), + when(platform.is.win_x64, "deno-x86_64-pc-windows-msvc.zip") + ), + }) + .with_receipt() ctx:link_bin("deno", platform.is.win and "deno.exe" or "deno") end, } diff --git a/lua/mason/packages/dhall-lsp/init.lua b/lua/mason/packages/dhall-lsp/init.lua index d941caee..85f7ac23 100644 --- a/lua/mason/packages/dhall-lsp/init.lua +++ b/lua/mason/packages/dhall-lsp/init.lua @@ -33,10 +33,8 @@ return Pkg.new { _.when(platform.is.win_x64, "dhall%-lsp%-server%-.+%-x86_64%-windows.zip") ) ) - local dhall_lsp_server_asset = _.find_first( - _.prop_satisfies(_.matches(asset_name_pattern), "name"), - gh_release.assets - ) + local dhall_lsp_server_asset = + _.find_first(_.prop_satisfies(_.matches(asset_name_pattern), "name"), gh_release.assets) Optional.of_nilable(dhall_lsp_server_asset) :if_present( ---@param asset GitHubReleaseAsset diff --git a/lua/mason/packages/elixir-ls/init.lua b/lua/mason/packages/elixir-ls/init.lua index 4027a3e8..8e164fed 100644 --- a/lua/mason/packages/elixir-ls/init.lua +++ b/lua/mason/packages/elixir-ls/init.lua @@ -11,9 +11,11 @@ return Pkg.new { ---@async ---@param ctx InstallContext install = function(ctx) - github.unzip_release_file({ - repo = "elixir-lsp/elixir-ls", - asset_file = "elixir-ls.zip", - }).with_receipt() + github + .unzip_release_file({ + repo = "elixir-lsp/elixir-ls", + asset_file = "elixir-ls.zip", + }) + .with_receipt() end, } diff --git a/lua/mason/packages/haskell-language-server/init.lua b/lua/mason/packages/haskell-language-server/init.lua index a3560556..7282386a 100644 --- a/lua/mason/packages/haskell-language-server/init.lua +++ b/lua/mason/packages/haskell-language-server/init.lua @@ -17,7 +17,8 @@ return Pkg.new { install = function(ctx) local repo = "haskell/haskell-language-server" local release = ctx.requested_version:or_else_get(function() - return github_client.fetch_latest_release(repo) + return github_client + .fetch_latest_release(repo) :map( ---@param release GitHubRelease function(release) diff --git a/lua/mason/packages/julia-lsp/init.lua b/lua/mason/packages/julia-lsp/init.lua index cd4bf1f5..e8aaee6a 100644 --- a/lua/mason/packages/julia-lsp/init.lua +++ b/lua/mason/packages/julia-lsp/init.lua @@ -33,13 +33,15 @@ return Pkg.new { ctx.fs:mkdir "vscode-package" ctx:chdir("vscode-package", function() - github.unzip_release_file({ - repo = "julia-vscode/julia-vscode", - asset_file = function(version) - local version_number = version:gsub("^v", "") - return ("language-julia-%s.vsix"):format(version_number) - end, - }).with_receipt() + github + .unzip_release_file({ + repo = "julia-vscode/julia-vscode", + asset_file = function(version) + local version_number = version:gsub("^v", "") + return ("language-julia-%s.vsix"):format(version_number) + end, + }) + .with_receipt() end) ctx.fs:rename( diff --git a/lua/mason/packages/kotlin-language-server/init.lua b/lua/mason/packages/kotlin-language-server/init.lua index 71152bda..eb04b990 100644 --- a/lua/mason/packages/kotlin-language-server/init.lua +++ b/lua/mason/packages/kotlin-language-server/init.lua @@ -12,10 +12,12 @@ return Pkg.new { ---@async ---@param ctx InstallContext install = function(ctx) - github.unzip_release_file({ - repo = "fwcd/kotlin-language-server", - asset_file = "server.zip", - }).with_receipt() + github + .unzip_release_file({ + repo = "fwcd/kotlin-language-server", + asset_file = "server.zip", + }) + .with_receipt() ctx:link_bin( "kotlin-language-server", path.concat { diff --git a/lua/mason/packages/lua-language-server/init.lua b/lua/mason/packages/lua-language-server/init.lua index 9e1436a3..437ebfc4 100644 --- a/lua/mason/packages/lua-language-server/init.lua +++ b/lua/mason/packages/lua-language-server/init.lua @@ -15,21 +15,23 @@ return Pkg.new { ---@async ---@param ctx InstallContext install = function(ctx) - github.unzip_release_file({ - repo = "sumneko/vscode-lua", - asset_file = function(version) - local target = coalesce( - when(platform.is.mac_x64, "vscode-lua-%s-darwin-x64.vsix"), - when(platform.is.mac_arm64, "vscode-lua-%s-darwin-arm64.vsix"), - when(platform.is.linux_x64, "vscode-lua-%s-linux-x64.vsix"), - when(platform.is.linux_arm64, "vscode-lua-%s-linux-arm64.vsix"), - when(platform.is.win_x64, "vscode-lua-%s-win32-x64.vsix"), - when(platform.is.win_x86, "vscode-lua-%s-win32-ia32.vsix") - ) + github + .unzip_release_file({ + repo = "sumneko/vscode-lua", + asset_file = function(version) + local target = coalesce( + when(platform.is.mac_x64, "vscode-lua-%s-darwin-x64.vsix"), + when(platform.is.mac_arm64, "vscode-lua-%s-darwin-arm64.vsix"), + when(platform.is.linux_x64, "vscode-lua-%s-linux-x64.vsix"), + when(platform.is.linux_arm64, "vscode-lua-%s-linux-arm64.vsix"), + when(platform.is.win_x64, "vscode-lua-%s-win32-x64.vsix"), + when(platform.is.win_x86, "vscode-lua-%s-win32-ia32.vsix") + ) - return target and target:format(version) - end, - }).with_receipt() + return target and target:format(version) + end, + }) + .with_receipt() platform.when { unix = function() diff --git a/lua/mason/packages/marksman/init.lua b/lua/mason/packages/marksman/init.lua index bd9d8e3a..f4efbe71 100644 --- a/lua/mason/packages/marksman/init.lua +++ b/lua/mason/packages/marksman/init.lua @@ -15,15 +15,17 @@ return Pkg.new { ---@async ---@param ctx InstallContext install = function(ctx) - github.download_release_file({ - repo = "artempyanykh/marksman", - out_file = platform.is.win and "marksman.exe" or "marksman", - asset_file = coalesce( - when(platform.is.mac, "marksman-macos"), - when(platform.is.linux_x64, "marksman-linux"), - when(platform.is.win_x64, "marksman.exe") - ), - }).with_receipt() + github + .download_release_file({ + repo = "artempyanykh/marksman", + out_file = platform.is.win and "marksman.exe" or "marksman", + asset_file = coalesce( + when(platform.is.mac, "marksman-macos"), + when(platform.is.linux_x64, "marksman-linux"), + when(platform.is.win_x64, "marksman.exe") + ), + }) + .with_receipt() std.chmod("+x", { "marksman" }) ctx:link_bin("marksman", platform.is.win and "marksman.exe" or "marksman") end, diff --git a/lua/mason/packages/omnisharp-roslyn/init.lua b/lua/mason/packages/omnisharp-roslyn/init.lua index 3f72bc4f..95a91fe5 100644 --- a/lua/mason/packages/omnisharp-roslyn/init.lua +++ b/lua/mason/packages/omnisharp-roslyn/init.lua @@ -32,10 +32,12 @@ return Pkg.new { ctx.fs:mkdir "omnisharp-mono" ctx:chdir("omnisharp-mono", function() - github.unzip_release_file({ - repo = "OmniSharp/omnisharp-roslyn", - asset_file = "omnisharp-mono.zip", - }).with_receipt() + github + .unzip_release_file({ + repo = "OmniSharp/omnisharp-roslyn", + asset_file = "omnisharp-mono.zip", + }) + .with_receipt() end) end, } diff --git a/lua/mason/packages/opencl-language-server/init.lua b/lua/mason/packages/opencl-language-server/init.lua index e1f754d5..7bb41a91 100644 --- a/lua/mason/packages/opencl-language-server/init.lua +++ b/lua/mason/packages/opencl-language-server/init.lua @@ -20,16 +20,20 @@ return Pkg.new { when(platform.is.mac, "opencl-language-server-darwin-x86_64.tar.gz"), when(platform.is.linux_x64, "opencl-language-server-linux-x86_64.tar.gz") ) - github.untargz_release_file({ - repo = "Galarius/opencl-language-server", - asset_file = asset_file, - }).with_receipt() + github + .untargz_release_file({ + repo = "Galarius/opencl-language-server", + asset_file = asset_file, + }) + .with_receipt() end, win = function() - github.unzip_release_file({ - repo = "Galarius/opencl-language-server", - asset_file = "opencl-language-server-win32-x86_64.zip", - }).with_receipt() + github + .unzip_release_file({ + repo = "Galarius/opencl-language-server", + asset_file = "opencl-language-server-win32-x86_64.zip", + }) + .with_receipt() end, } ctx:link_bin( diff --git a/lua/mason/packages/powershell-editor-services/init.lua b/lua/mason/packages/powershell-editor-services/init.lua index 9136fa53..706077dc 100644 --- a/lua/mason/packages/powershell-editor-services/init.lua +++ b/lua/mason/packages/powershell-editor-services/init.lua @@ -11,9 +11,11 @@ return Pkg.new { ---@async install = function() std.ensure_executable("pwsh", { help_url = "https://github.com/PowerShell/PowerShell#get-powershell" }) - github.unzip_release_file({ - repo = "PowerShell/PowerShellEditorServices", - asset_file = "PowerShellEditorServices.zip", - }).with_receipt() + github + .unzip_release_file({ + repo = "PowerShell/PowerShellEditorServices", + asset_file = "PowerShellEditorServices.zip", + }) + .with_receipt() end, } diff --git a/lua/mason/packages/prosemd-lsp/init.lua b/lua/mason/packages/prosemd-lsp/init.lua index 18fc623b..4ffd9e06 100644 --- a/lua/mason/packages/prosemd-lsp/init.lua +++ b/lua/mason/packages/prosemd-lsp/init.lua @@ -15,15 +15,17 @@ return Pkg.new { ---@async ---@param ctx InstallContext install = function(ctx) - github.download_release_file({ - repo = "kitten/prosemd-lsp", - out_file = platform.is_win and "prosemd-lsp.exe" or "prosemd-lsp", - asset_file = coalesce( - when(platform.is_mac, "prosemd-lsp-macos"), - when(platform.is_linux and platform.arch == "x64", "prosemd-lsp-linux"), - when(platform.is_win and platform.arch == "x64", "prosemd-lsp-windows.exe") - ), - }).with_receipt() + github + .download_release_file({ + repo = "kitten/prosemd-lsp", + out_file = platform.is_win and "prosemd-lsp.exe" or "prosemd-lsp", + asset_file = coalesce( + when(platform.is_mac, "prosemd-lsp-macos"), + when(platform.is_linux and platform.arch == "x64", "prosemd-lsp-linux"), + when(platform.is_win and platform.arch == "x64", "prosemd-lsp-windows.exe") + ), + }) + .with_receipt() std.chmod("+x", { "prosemd-lsp" }) ctx:link_bin("prosemd-lsp", platform.is.win and "prosemd-lsp.exe" or "prosemd-lsp") end, diff --git a/lua/mason/packages/puppet-editor-services/init.lua b/lua/mason/packages/puppet-editor-services/init.lua index c5c702ec..c9d8db55 100644 --- a/lua/mason/packages/puppet-editor-services/init.lua +++ b/lua/mason/packages/puppet-editor-services/init.lua @@ -12,12 +12,14 @@ return Pkg.new { ---@param ctx InstallContext install = function(ctx) assert(platform.is.unix, "puppet-editor-services only supports UNIX environments.") - github.unzip_release_file({ - repo = "puppetlabs/puppet-editor-services", - asset_file = function(version) - return ("puppet_editor_services_%s.zip"):format(version) - end, - }).with_receipt() + github + .unzip_release_file({ + repo = "puppetlabs/puppet-editor-services", + asset_file = function(version) + return ("puppet_editor_services_%s.zip"):format(version) + end, + }) + .with_receipt() ctx:link_bin("puppet-languageserver", "puppet-languageserver") ctx:link_bin("puppet-debugserver", "puppet-debugserver") end, diff --git a/lua/mason/packages/reason-language-server/init.lua b/lua/mason/packages/reason-language-server/init.lua index 65873a90..ef9fd2f6 100644 --- a/lua/mason/packages/reason-language-server/init.lua +++ b/lua/mason/packages/reason-language-server/init.lua @@ -20,10 +20,12 @@ return Pkg.new { when(platform.is.linux_x64, "rls-linux"), when(platform.is.win_x64, "rls-windows") ) - github.unzip_release_file({ - repo = "jaredly/reason-language-server", - asset_file = ("%s.zip"):format(archive_name), - }).with_receipt() + github + .unzip_release_file({ + repo = "jaredly/reason-language-server", + asset_file = ("%s.zip"):format(archive_name), + }) + .with_receipt() ctx.fs:rename(archive_name, "reason") ctx:link_bin( "reason-language-server", diff --git a/lua/mason/packages/rescript-lsp/init.lua b/lua/mason/packages/rescript-lsp/init.lua index e12ba749..8cf39adb 100644 --- a/lua/mason/packages/rescript-lsp/init.lua +++ b/lua/mason/packages/rescript-lsp/init.lua @@ -9,11 +9,13 @@ return Pkg.new { categories = { Pkg.Cat.LSP }, ---@async install = function() - github.unzip_release_file({ - repo = "rescript-lang/rescript-vscode", - asset_file = function(version) - return ("rescript-vscode-%s.vsix"):format(version) - end, - }).with_receipt() + github + .unzip_release_file({ + repo = "rescript-lang/rescript-vscode", + asset_file = function(version) + return ("rescript-vscode-%s.vsix"):format(version) + end, + }) + .with_receipt() end, } diff --git a/lua/mason/packages/rust-analyzer/init.lua b/lua/mason/packages/rust-analyzer/init.lua index 0b966823..8aa3b23f 100644 --- a/lua/mason/packages/rust-analyzer/init.lua +++ b/lua/mason/packages/rust-analyzer/init.lua @@ -40,11 +40,13 @@ return Pkg.new { when(platform.is.win_x64, "rust-analyzer-x86_64-pc-windows-msvc.gz") ) - github.gunzip_release_file({ - repo = "rust-lang/rust-analyzer", - asset_file = asset_file, - out_file = platform.is.win and "rust-analyzer.exe" or "rust-analyzer", - }).with_receipt() + github + .gunzip_release_file({ + repo = "rust-lang/rust-analyzer", + asset_file = asset_file, + out_file = platform.is.win and "rust-analyzer.exe" or "rust-analyzer", + }) + .with_receipt() std.chmod("+x", { "rust-analyzer" }) ctx:link_bin("rust-analyzer", platform.is.win and "rust-analyzer.exe" or "rust-analyzer") end, diff --git a/lua/mason/packages/serve-d/init.lua b/lua/mason/packages/serve-d/init.lua index 6c10d311..fc57719b 100644 --- a/lua/mason/packages/serve-d/init.lua +++ b/lua/mason/packages/serve-d/init.lua @@ -17,29 +17,33 @@ return Pkg.new { local repo = "Pure-D/serve-d" platform.when { unix = function() - github.untarxz_release_file({ - repo = repo, - asset_file = function(release) - local target = coalesce( - when(platform.is.mac, "serve-d_%s-osx-x86_64.tar.xz"), - when(platform.is.linux_x64, "serve-d_%s-linux-x86_64.tar.xz") - ) - return target and target:format(release:gsub("^v", "")) - end, - }).with_receipt() + github + .untarxz_release_file({ + repo = repo, + asset_file = function(release) + local target = coalesce( + when(platform.is.mac, "serve-d_%s-osx-x86_64.tar.xz"), + when(platform.is.linux_x64, "serve-d_%s-linux-x86_64.tar.xz") + ) + return target and target:format(release:gsub("^v", "")) + end, + }) + .with_receipt() ctx:link_bin("serve-d", "serve-d") end, win = function() - github.unzip_release_file({ - repo = repo, - asset_file = function(release) - local target = coalesce( - when(platform.arch == "x64", "serve-d_%s-windows-x86_64.zip"), - when(platform.arch == "x86", "serve-d_%s-windows-x86.zip") - ) - return target and target:format(release:gsub("^v", "")) - end, - }).with_receipt() + github + .unzip_release_file({ + repo = repo, + asset_file = function(release) + local target = coalesce( + when(platform.arch == "x64", "serve-d_%s-windows-x86_64.zip"), + when(platform.arch == "x86", "serve-d_%s-windows-x86.zip") + ) + return target and target:format(release:gsub("^v", "")) + end, + }) + .with_receipt() ctx:link_bin("serve-d", "serve-d.exe") end, } diff --git a/lua/mason/packages/shellcheck/init.lua b/lua/mason/packages/shellcheck/init.lua index b05f3087..634e42f1 100644 --- a/lua/mason/packages/shellcheck/init.lua +++ b/lua/mason/packages/shellcheck/init.lua @@ -14,23 +14,27 @@ return Pkg.new { install = function(ctx) platform.when { unix = function() - github.untarxz_release_file({ - strip_components = 1, - repo = "koalaman/shellcheck", - asset_file = _.coalesce( - _.when(platform.is.mac, _.format "shellcheck-%s.darwin.x86_64.tar.xz"), - _.when(platform.is.linux_x64, _.format "shellcheck-%s.linux.x86_64.tar.xz"), - _.when(platform.is.linux_arm64, _.format "shellcheck-%s.linux.aarch64.tar.xz"), - _.when(platform.is.linux_arm, _.format "shellcheck-%s.linux.armv6hf.tar.xz") - ), - }).with_receipt() + github + .untarxz_release_file({ + strip_components = 1, + repo = "koalaman/shellcheck", + asset_file = _.coalesce( + _.when(platform.is.mac, _.format "shellcheck-%s.darwin.x86_64.tar.xz"), + _.when(platform.is.linux_x64, _.format "shellcheck-%s.linux.x86_64.tar.xz"), + _.when(platform.is.linux_arm64, _.format "shellcheck-%s.linux.aarch64.tar.xz"), + _.when(platform.is.linux_arm, _.format "shellcheck-%s.linux.armv6hf.tar.xz") + ), + }) + .with_receipt() ctx:link_bin("shellcheck", "shellcheck") end, win = function() - github.unzip_release_file({ - repo = "koalaman/shellcheck", - asset_file = _.coalesce(_.when(platform.is.win_x64, _.format "shellcheck-%s.zip")), - }).with_receipt() + github + .unzip_release_file({ + repo = "koalaman/shellcheck", + asset_file = _.coalesce(_.when(platform.is.win_x64, _.format "shellcheck-%s.zip")), + }) + .with_receipt() ctx:link_bin("shellcheck", "shellcheck.exe") end, } diff --git a/lua/mason/packages/slint-lsp/init.lua b/lua/mason/packages/slint-lsp/init.lua index ad9c53fa..93973e4b 100644 --- a/lua/mason/packages/slint-lsp/init.lua +++ b/lua/mason/packages/slint-lsp/init.lua @@ -15,16 +15,20 @@ return Pkg.new { local repo = "slint-ui/slint" platform.when { win = function() - github.unzip_release_file({ - repo = repo, - asset_file = "slint-lsp-windows.zip", - }).with_receipt() + github + .unzip_release_file({ + repo = repo, + asset_file = "slint-lsp-windows.zip", + }) + .with_receipt() end, linux = function() - github.untargz_release_file({ - repo = repo, - asset_file = "slint-lsp-linux.tar.gz", - }).with_receipt() + github + .untargz_release_file({ + repo = repo, + asset_file = "slint-lsp-linux.tar.gz", + }) + .with_receipt() end, } ctx:link_bin("slint-lsp", path.concat { "slint-lsp", platform.is.win and "slint-lsp.exe" or "slint-lsp" }) diff --git a/lua/mason/packages/solang/init.lua b/lua/mason/packages/solang/init.lua index ebc7c089..bcfc54f3 100644 --- a/lua/mason/packages/solang/init.lua +++ b/lua/mason/packages/solang/init.lua @@ -9,17 +9,19 @@ local coalesce, when = _.coalesce, _.when ---@async local function download_solang() - local source = github.download_release_file({ - repo = "hyperledger-labs/solang", - out_file = platform.is.win and "solang.exe" or "solang", - asset_file = coalesce( - when(platform.is.mac_x64, "solang-mac-intel"), - when(platform.is.mac_arm64, "solang-mac-arm"), - when(platform.is.linux_arm64, "solang-linux-arm64"), - when(platform.is.linux_x64, "solang-linux-x86-64"), - when(platform.is.win_x64, "solang.exe") - ), - }).with_receipt() + local source = github + .download_release_file({ + repo = "hyperledger-labs/solang", + out_file = platform.is.win and "solang.exe" or "solang", + asset_file = coalesce( + when(platform.is.mac_x64, "solang-mac-intel"), + when(platform.is.mac_arm64, "solang-mac-arm"), + when(platform.is.linux_arm64, "solang-linux-arm64"), + when(platform.is.linux_x64, "solang-linux-x86-64"), + when(platform.is.win_x64, "solang.exe") + ), + }) + .with_receipt() std.chmod("+x", { "solang" }) return source end diff --git a/lua/mason/packages/solidity/init.lua b/lua/mason/packages/solidity/init.lua index e7379c9f..b6c04188 100644 --- a/lua/mason/packages/solidity/init.lua +++ b/lua/mason/packages/solidity/init.lua @@ -15,15 +15,17 @@ return Pkg.new { ---@async ---@param ctx InstallContext install = function(ctx) - github.download_release_file({ - repo = "ethereum/solidity", - out_file = platform.is_win and "solc.exe" or "solc", - asset_file = coalesce( - when(platform.is.mac, "solc-macos"), - when(platform.is.linux, "solc-static-linux"), - when(platform.is.win, "solc-windows.exe") - ), - }).with_receipt() + github + .download_release_file({ + repo = "ethereum/solidity", + out_file = platform.is_win and "solc.exe" or "solc", + asset_file = coalesce( + when(platform.is.mac, "solc-macos"), + when(platform.is.linux, "solc-static-linux"), + when(platform.is.win, "solc-windows.exe") + ), + }) + .with_receipt() std.chmod("+x", { "solc" }) ctx:link_bin("solc", platform.is.win and "solc.exe" or "solc") end, diff --git a/lua/mason/packages/stylua/init.lua b/lua/mason/packages/stylua/init.lua index c421f4af..227b637c 100644 --- a/lua/mason/packages/stylua/init.lua +++ b/lua/mason/packages/stylua/init.lua @@ -8,6 +8,6 @@ return Pkg.new { languages = { Pkg.Lang.Lua }, categories = { Pkg.Cat.Formatter }, install = cargo.crate("stylua", { - bin = { "stylua" } + bin = { "stylua" }, }), } diff --git a/lua/mason/packages/terraform-ls/init.lua b/lua/mason/packages/terraform-ls/init.lua index 85e7f4a8..9588b094 100644 --- a/lua/mason/packages/terraform-ls/init.lua +++ b/lua/mason/packages/terraform-ls/init.lua @@ -14,20 +14,22 @@ return Pkg.new { ---@async ---@param ctx InstallContext install = function(ctx) - github.unzip_release_file({ - repo = "hashicorp/terraform-ls", - asset_file = function(version) - local target = coalesce( - when(platform.is.mac_arm64, "terraform-ls_%s_darwin_arm64.zip"), - when(platform.is.mac_x64, "terraform-ls_%s_darwin_amd64.zip"), - when(platform.is.linux_arm64, "terraform-ls_%s_linux_arm64.zip"), - when(platform.is.linux_arm, "terraform-ls_%s_linux_arm.zip"), - when(platform.is.linux_x64, "terraform-ls_%s_linux_amd64.zip"), - when(platform.is.win_x64, "terraform-ls_%s_windows_amd64.zip") - ) - return target and target:format(version:gsub("^v", "")) - end, - }).with_receipt() + github + .unzip_release_file({ + repo = "hashicorp/terraform-ls", + asset_file = function(version) + local target = coalesce( + when(platform.is.mac_arm64, "terraform-ls_%s_darwin_arm64.zip"), + when(platform.is.mac_x64, "terraform-ls_%s_darwin_amd64.zip"), + when(platform.is.linux_arm64, "terraform-ls_%s_linux_arm64.zip"), + when(platform.is.linux_arm, "terraform-ls_%s_linux_arm.zip"), + when(platform.is.linux_x64, "terraform-ls_%s_linux_amd64.zip"), + when(platform.is.win_x64, "terraform-ls_%s_windows_amd64.zip") + ) + return target and target:format(version:gsub("^v", "")) + end, + }) + .with_receipt() ctx:link_bin("terraform-ls", platform.is.win and "terraform-ls.exe" or "terraform-ls") end, } diff --git a/lua/mason/packages/texlab/init.lua b/lua/mason/packages/texlab/init.lua index dfb4f3d0..c777a5f6 100644 --- a/lua/mason/packages/texlab/init.lua +++ b/lua/mason/packages/texlab/init.lua @@ -17,21 +17,25 @@ return Pkg.new { local repo = "latex-lsp/texlab" platform.when { unix = function() - github.untargz_release_file({ - repo = repo, - asset_file = coalesce( - when(platform.is.mac_arm64, "texlab-aarch64-macos.tar.gz"), - when(platform.is.mac_x64, "texlab-x86_64-macos.tar.gz"), - when(platform.is.linux_x64, "texlab-x86_64-linux.tar.gz") - ), - }).with_receipt() + github + .untargz_release_file({ + repo = repo, + asset_file = coalesce( + when(platform.is.mac_arm64, "texlab-aarch64-macos.tar.gz"), + when(platform.is.mac_x64, "texlab-x86_64-macos.tar.gz"), + when(platform.is.linux_x64, "texlab-x86_64-linux.tar.gz") + ), + }) + .with_receipt() ctx:link_bin("texlab", "texlab") end, win = function() - github.unzip_release_file({ - repo = repo, - asset_file = coalesce(when(platform.arch == "x64", "texlab-x86_64-windows.zip")), - }).with_receipt() + github + .unzip_release_file({ + repo = repo, + asset_file = coalesce(when(platform.arch == "x64", "texlab-x86_64-windows.zip")), + }) + .with_receipt() ctx:link_bin("texlab", "texlab.exe") end, } diff --git a/lua/mason/packages/tflint/init.lua b/lua/mason/packages/tflint/init.lua index 3206e576..cc910da1 100644 --- a/lua/mason/packages/tflint/init.lua +++ b/lua/mason/packages/tflint/init.lua @@ -14,17 +14,19 @@ return Pkg.new { ---@async ---@param ctx InstallContext install = function(ctx) - github.unzip_release_file({ - repo = "terraform-linters/tflint", - asset_file = coalesce( - when(platform.is.mac_x64, "tflint_darwin_amd64.zip"), - when(platform.is.mac_arm64, "tflint_darwin_arm64.zip"), - when(platform.is.linux_x64, "tflint_linux_amd64.zip"), - when(platform.is.linux_arm64, "tflint_linux_arm64.zip"), - when(platform.is.linux_x86, "tflint_linux_386.zip"), - when(platform.is.win_x64, "tflint_windows_amd64.zip") - ), - }).with_receipt() + github + .unzip_release_file({ + repo = "terraform-linters/tflint", + asset_file = coalesce( + when(platform.is.mac_x64, "tflint_darwin_amd64.zip"), + when(platform.is.mac_arm64, "tflint_darwin_arm64.zip"), + when(platform.is.linux_x64, "tflint_linux_amd64.zip"), + when(platform.is.linux_arm64, "tflint_linux_arm64.zip"), + when(platform.is.linux_x86, "tflint_linux_386.zip"), + when(platform.is.win_x64, "tflint_windows_amd64.zip") + ), + }) + .with_receipt() ctx:link_bin("tflint", platform.is.win and "tflint.exe" or "tflint") end, } diff --git a/lua/mason/packages/visualforce-language-server/init.lua b/lua/mason/packages/visualforce-language-server/init.lua index f3581b5d..0bc422b9 100644 --- a/lua/mason/packages/visualforce-language-server/init.lua +++ b/lua/mason/packages/visualforce-language-server/init.lua @@ -23,10 +23,12 @@ return Pkg.new { :get_or_throw() -- Result unwrap :or_else_throw "Failed to find release with assets." -- Optional unwrap - github.unzip_release_file({ - version = Optional.of(release.tag_name), - asset_file = _.compose(_.format "salesforcedx-vscode-visualforce-%s.vsix", _.gsub("^v", "")), - repo = repo, - }).with_receipt() + github + .unzip_release_file({ + version = Optional.of(release.tag_name), + asset_file = _.compose(_.format "salesforcedx-vscode-visualforce-%s.vsix", _.gsub("^v", "")), + repo = repo, + }) + .with_receipt() end, } diff --git a/lua/mason/packages/vls/init.lua b/lua/mason/packages/vls/init.lua index 81cf7478..110605ab 100644 --- a/lua/mason/packages/vls/init.lua +++ b/lua/mason/packages/vls/init.lua @@ -20,16 +20,18 @@ return Pkg.new { ---@type GitHubRelease local latest_dev_build = github_client.fetch_latest_release(repo, { include_prerelease = true }):get_or_throw() - github.download_release_file({ - version = Optional.of(latest_dev_build.tag_name), - repo = repo, - out_file = platform.is.win and "vls.exe" or "vls", - asset_file = _.coalesce( - _.when(platform.is.linux_x64, "vls_linux_x64"), - _.when(platform.is.mac, "vls_macos_x64"), - _.when(platform.is.win_x64, "vls_windows_x64.exe") - ), - }).with_receipt() + github + .download_release_file({ + version = Optional.of(latest_dev_build.tag_name), + repo = repo, + out_file = platform.is.win and "vls.exe" or "vls", + asset_file = _.coalesce( + _.when(platform.is.linux_x64, "vls_linux_x64"), + _.when(platform.is.mac, "vls_macos_x64"), + _.when(platform.is.win_x64, "vls_windows_x64.exe") + ), + }) + .with_receipt() std.chmod("+x", { "vls" }) ctx:link_bin("vls", platform.is.win and "vls.exe" or "vls") end, diff --git a/lua/mason/packages/zk/init.lua b/lua/mason/packages/zk/init.lua index dc0cab0a..4250f2c4 100644 --- a/lua/mason/packages/zk/init.lua +++ b/lua/mason/packages/zk/init.lua @@ -17,33 +17,37 @@ return Pkg.new { local repo = "mickael-menu/zk" platform.when { mac = function() - github.unzip_release_file({ - repo = repo, - asset_file = coalesce( - when(platform.arch == "arm64", function(version) - return ("zk-%s-macos-arm64.zip"):format(version) - end), - when(platform.arch == "x64", function(version) - return ("zk-%s-macos-x86_64.zip"):format(version) - end) - ), - }):with_receipt() + github + .unzip_release_file({ + repo = repo, + asset_file = coalesce( + when(platform.arch == "arm64", function(version) + return ("zk-%s-macos-arm64.zip"):format(version) + end), + when(platform.arch == "x64", function(version) + return ("zk-%s-macos-x86_64.zip"):format(version) + end) + ), + }) + :with_receipt() end, linux = function() - github.untargz_release_file({ - repo = repo, - asset_file = coalesce( - when(platform.arch == "arm64", function(version) - return ("zk-%s-linux-arm64.tar.gz"):format(version) - end), - when(platform.arch == "x64", function(version) - return ("zk-%s-linux-amd64.tar.gz"):format(version) - end), - when(platform.arch == "x86", function(version) - return ("zk-%s-linux-i386.tar.gz"):format(version) - end) - ), - }).with_receipt() + github + .untargz_release_file({ + repo = repo, + asset_file = coalesce( + when(platform.arch == "arm64", function(version) + return ("zk-%s-linux-arm64.tar.gz"):format(version) + end), + when(platform.arch == "x64", function(version) + return ("zk-%s-linux-amd64.tar.gz"):format(version) + end), + when(platform.arch == "x86", function(version) + return ("zk-%s-linux-i386.tar.gz"):format(version) + end) + ), + }) + .with_receipt() end, } ctx:link_bin("zk", "zk") diff --git a/lua/mason/packages/zls/init.lua b/lua/mason/packages/zls/init.lua index 6a150911..beef3948 100644 --- a/lua/mason/packages/zls/init.lua +++ b/lua/mason/packages/zls/init.lua @@ -22,10 +22,12 @@ return Pkg.new { when(platform.is.linux_x86, "i386-linux.tar.xz"), when(platform.is.win_x64, "x86_64-windows.tar.xz") ) - github.untarxz_release_file({ - repo = "zigtools/zls", - asset_file = asset_file, - }).with_receipt() + github + .untarxz_release_file({ + repo = "zigtools/zls", + asset_file = asset_file, + }) + .with_receipt() std.chmod("+x", { path.concat { "bin", "zls" } }) ctx:link_bin("zls", path.concat { "bin", platform.is.win and "zls.exe" or "zls" }) end, |
