aboutsummaryrefslogtreecommitdiffstats
path: root/lua/mason-core/managers/cargo/init.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2022-08-15 21:03:06 +0200
committerGitHub <noreply@github.com>2022-08-15 21:03:06 +0200
commit3c62386a396ae0c1cd7adbaacc379eb4af072a65 (patch)
tree4d00d20958839a04e6a996c11b97724c762e491a /lua/mason-core/managers/cargo/init.lua
parentchore: update generated code (#295) (diff)
downloadmason-3c62386a396ae0c1cd7adbaacc379eb4af072a65.tar
mason-3c62386a396ae0c1cd7adbaacc379eb4af072a65.tar.gz
mason-3c62386a396ae0c1cd7adbaacc379eb4af072a65.tar.bz2
mason-3c62386a396ae0c1cd7adbaacc379eb4af072a65.tar.lz
mason-3c62386a396ae0c1cd7adbaacc379eb4af072a65.tar.xz
mason-3c62386a396ae0c1cd7adbaacc379eb4af072a65.tar.zst
mason-3c62386a396ae0c1cd7adbaacc379eb4af072a65.zip
refactor: introduce selene, harden type defs, and use proper EmmyLua syntax (#296)
Diffstat (limited to 'lua/mason-core/managers/cargo/init.lua')
-rw-r--r--lua/mason-core/managers/cargo/init.lua13
1 files changed, 7 insertions, 6 deletions
diff --git a/lua/mason-core/managers/cargo/init.lua b/lua/mason-core/managers/cargo/init.lua
index 2dcc3a69..b8cd4fa7 100644
--- a/lua/mason-core/managers/cargo/init.lua
+++ b/lua/mason-core/managers/cargo/init.lua
@@ -23,7 +23,7 @@ local M = {}
---@async
---@param crate string The crate to install.
----@param opts {git: boolean | string, features: string|nil, bin: string[] | nil } | nil
+---@param opts {git: boolean | string, features: string?, bin: string[]? }?
function M.crate(crate, opts)
return function()
M.install(crate, opts).with_receipt()
@@ -32,7 +32,7 @@ end
---@async
---@param crate string The crate to install.
----@param opts {git: boolean | string, features: string|nil, bin: string[] | nil } | nil
+---@param opts {git: boolean | string, features: string?, bin: string[]? }?
function M.install(crate, opts)
local ctx = installer.context()
opts = opts or {}
@@ -40,6 +40,7 @@ function M.install(crate, opts)
assert(not opts.git, "Providing a version when installing a git crate is not allowed.")
end)
+ ---@type string | string[]
local final_crate = crate
if opts.git then
@@ -75,8 +76,8 @@ function M.install(crate, opts)
}
end
----@param output string: The `cargo install --list` output.
----@return table<string, string>: Key is the crate name, value is its version.
+---@param output string The `cargo install --list` output.
+---@return table<string, string> # Key is the crate name, value is its version.
function M.parse_installed_crates(output)
local installed_crates = {}
for _, line in ipairs(vim.split(output, "\n")) do
@@ -89,7 +90,7 @@ function M.parse_installed_crates(output)
end
---@async
----@param receipt InstallReceipt
+---@param receipt InstallReceipt<InstallReceiptPackageSource>
---@param install_dir string
function M.check_outdated_primary_package(receipt, install_dir)
return M.get_installed_primary_package_version(receipt, install_dir):map_catching(function(installed_version)
@@ -108,7 +109,7 @@ function M.check_outdated_primary_package(receipt, install_dir)
end
---@async
----@param receipt InstallReceipt
+---@param receipt InstallReceipt<InstallReceiptPackageSource>
---@param install_dir string
function M.get_installed_primary_package_version(receipt, install_dir)
return spawn