Skip to content

Commit

Permalink
chore: change emmylua annotation syntax from @ to : for comments (wil…
Browse files Browse the repository at this point in the history
  • Loading branch information
williamboman committed Jul 14, 2022
1 parent ee23d7b commit 63de62c
Show file tree
Hide file tree
Showing 30 changed files with 89 additions and 89 deletions.
2 changes: 1 addition & 1 deletion lua/mason-core/async/init.lua
Expand Up @@ -39,7 +39,7 @@ local function table_pack(...)
end

---@param async_fn fun(...)
---@param should_reject_err boolean|nil @Whether the provided async_fn takes a callback with the signature `fun(err, result)`
---@param should_reject_err boolean|nil: Whether the provided async_fn takes a callback with the signature `fun(err, result)`
local function promisify(async_fn, should_reject_err)
return function(...)
local args = table_pack(...)
Expand Down
2 changes: 1 addition & 1 deletion lua/mason-core/fetch.lua
Expand Up @@ -17,7 +17,7 @@ local USER_AGENT = "mason.nvim (+https://github.com/williamboman/mason.nvim)"
---@alias FetchOpts {out_file: string, method: FetchMethod, headers: table<string, string>, data: string}

---@async
---@param url string @The url to fetch.
---@param url string: The url to fetch.
---@param opts FetchOpts | nil
local function fetch(url, opts)
opts = opts or {}
Expand Down
4 changes: 2 additions & 2 deletions lua/mason-core/fs.lua
Expand Up @@ -86,7 +86,7 @@ local function make_module(uv)

---@param path string
---@param contents string
---@param flags string|nil @Defaults to "w".
---@param flags string|nil: Defaults to "w".
function M.write_file(path, contents, flags)
log.debug("fs: write_file", path)
local fd = uv.fs_open(path, flags or "w", 438)
Expand All @@ -112,7 +112,7 @@ local function make_module(uv)

---@alias ReaddirEntry {name: string, type: string}

---@param path string @The full path to the directory to read.
---@param path string: The full path to the directory to read.
---@return ReaddirEntry[]
function M.readdir(path)
log.trace("fs: fs_opendir", path)
Expand Down
2 changes: 1 addition & 1 deletion lua/mason-core/functional/list.lua
Expand Up @@ -88,7 +88,7 @@ end, 2)

---@generic T
---@param list T[]
---@return T[] @A shallow copy of the list.
---@return T[]: A shallow copy of the list.
_.list_copy = _.map(fun.identity)

_.concat = fun.curryN(function(a, b)
Expand Down
30 changes: 15 additions & 15 deletions lua/mason-core/installer/context.lua
Expand Up @@ -53,39 +53,39 @@ function ContextualFs.new(cwd)
end

---@async
---@param rel_path string @The relative path from the current working directory to the file to append.
---@param rel_path string: The relative path from the current working directory to the file to append.
---@param contents string
function ContextualFs:append_file(rel_path, contents)
return fs.async.append_file(path.concat { self.cwd:get(), rel_path }, contents)
end

---@async
---@param rel_path string @The relative path from the current working directory to the file to write.
---@param rel_path string: The relative path from the current working directory to the file to write.
---@param contents string
function ContextualFs:write_file(rel_path, contents)
return fs.async.write_file(path.concat { self.cwd:get(), rel_path }, contents)
end

---@async
---@param rel_path string @The relative path from the current working directory.
---@param rel_path string: The relative path from the current working directory.
function ContextualFs:file_exists(rel_path)
return fs.async.file_exists(path.concat { self.cwd:get(), rel_path })
end

---@async
---@param rel_path string @The relative path from the current working directory.
---@param rel_path string: The relative path from the current working directory.
function ContextualFs:dir_exists(rel_path)
return fs.async.dir_exists(path.concat { self.cwd:get(), rel_path })
end

---@async
---@param rel_path string @The relative path from the current working directory.
---@param rel_path string: The relative path from the current working directory.
function ContextualFs:rmrf(rel_path)
return fs.async.rmrf(path.concat { self.cwd:get(), rel_path })
end

---@async
---@param rel_path string @The relative path from the current working directory.
---@param rel_path string: The relative path from the current working directory.
function ContextualFs:unlink(rel_path)
return fs.async.unlink(path.concat { self.cwd:get(), rel_path })
end
Expand All @@ -104,7 +104,7 @@ function ContextualFs:mkdir(dirpath)
end

---@class CwdManager
---@field private install_prefix string @Defines the upper boundary for which paths are allowed as cwd.
---@field private install_prefix string: Defines the upper boundary for which paths are allowed as cwd.
---@field private cwd string
local CwdManager = {}
CwdManager.__index = CwdManager
Expand Down Expand Up @@ -185,8 +185,8 @@ function InstallContext:promote_cwd()
self.cwd:set(install_path)
end

---@param rel_path string @The relative path from the current working directory to change cwd to. Will only restore to the initial cwd after execution of fn (if provided).
---@param fn async fun() @(optional) The function to run in the context of the given path.
---@param rel_path string: The relative path from the current working directory to change cwd to. Will only restore to the initial cwd after execution of fn (if provided).
---@param fn async (fun()): (optional) The function to run in the context of the given path.
function InstallContext:chdir(rel_path, fn)
local old_cwd = self.cwd:get()
self.cwd:set(path.concat { old_cwd, rel_path })
Expand All @@ -200,8 +200,8 @@ function InstallContext:chdir(rel_path, fn)
end
end

---@param new_executable_rel_path string @Relative path to the executable file to create.
---@param script_rel_path string @Relative path to the Node.js script.
---@param new_executable_rel_path string: Relative path to the executable file to create.
---@param script_rel_path string: Relative path to the Node.js script.
function InstallContext:write_node_exec_wrapper(new_executable_rel_path, script_rel_path)
return self:write_shell_exec_wrapper(
new_executable_rel_path,
Expand All @@ -212,7 +212,7 @@ function InstallContext:write_node_exec_wrapper(new_executable_rel_path, script_
)
end

---@param new_executable_rel_path string @Relative path to the executable file to create.
---@param new_executable_rel_path string: Relative path to the executable file to create.
---@param target_executable_rel_path string
function InstallContext:write_exec_wrapper(new_executable_rel_path, target_executable_rel_path)
return self:write_shell_exec_wrapper(
Expand All @@ -224,9 +224,9 @@ function InstallContext:write_exec_wrapper(new_executable_rel_path, target_execu
)
end

---@param new_executable_rel_path string @Relative path to the executable file to create.
---@param command string @The shell command to run.
---@return string @The created executable filename.
---@param new_executable_rel_path string: Relative path to the executable file to create.
---@param command string: The shell command to run.
---@return string: The created executable filename.
function InstallContext:write_shell_exec_wrapper(new_executable_rel_path, command)
return platform.when {
unix = function()
Expand Down
2 changes: 1 addition & 1 deletion lua/mason-core/installer/handle.lua
Expand Up @@ -99,7 +99,7 @@ function InstallHandle:deregister_spawn_handle(luv_handle)
return false
end

---@return Optional @Optional<InstallHandleSpawnHandle>
---@return Optional: Optional<InstallHandleSpawnHandle>
function InstallHandle:peek_spawn_handle()
return Optional.of_nilable(self.spawn_handles[#self.spawn_handles])
end
Expand Down
2 changes: 1 addition & 1 deletion lua/mason-core/managers/cargo/client.lua
Expand Up @@ -6,7 +6,7 @@ local M = {}

---@async
---@param crate string
---@return Result @of Crate
---@return Result: of Crate
function M.fetch_crate(crate)
return fetch(("https://crates.io/api/v1/crates/%s"):format(crate)):map_catching(vim.json.decode)
end
Expand Down
4 changes: 2 additions & 2 deletions lua/mason-core/managers/cargo/init.lua
Expand Up @@ -76,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
Expand Down
4 changes: 2 additions & 2 deletions lua/mason-core/managers/composer/init.lua
Expand Up @@ -26,15 +26,15 @@ local function with_receipt(packages)
end

---@async
---@param packages { [number]: string, bin: string[] | nil } @The composer packages to install. The first item in this list will be the recipient of the requested version, if set.
---@param packages { [number]: string, bin: string[] | nil }: The composer packages to install. The first item in this list will be the recipient of the requested version, if set.
function M.packages(packages)
return function()
return M.require(packages).with_receipt()
end
end

---@async
---@param packages { [number]: string, bin: string[] | nil } @The composer packages to install. The first item in this list will be the recipient of the requested version, if set.
---@param packages { [number]: string, bin: string[] | nil }: The composer packages to install. The first item in this list will be the recipient of the requested version, if set.
function M.require(packages)
local ctx = installer.context()
local pkgs = _.list_copy(packages)
Expand Down
4 changes: 2 additions & 2 deletions lua/mason-core/managers/gem/init.lua
Expand Up @@ -25,15 +25,15 @@ local function with_receipt(packages)
end

---@async
---@param packages { [number]: string, bin: string[] | nil } @The Gem packages to install. The first item in this list will be the recipient of the requested version, if set.
---@param packages { [number]: string, bin: string[] | nil }: The Gem packages to install. The first item in this list will be the recipient of the requested version, if set.
function M.packages(packages)
return function()
return M.install(packages).with_receipt()
end
end

---@async
---@param packages { [number]: string, bin: string[] | nil } @The Gem packages to install. The first item in this list will be the recipient of the requested version, if set.
---@param packages { [number]: string, bin: string[] | nil }: The Gem packages to install. The first item in this list will be the recipient of the requested version, if set.
function M.install(packages)
local ctx = installer.context()
local pkgs = _.list_copy(packages or {})
Expand Down
2 changes: 1 addition & 1 deletion lua/mason-core/managers/git/init.lua
Expand Up @@ -14,7 +14,7 @@ local function with_receipt(repo)
end

---@async
---@param opts {[1]: string, recursive: boolean, version: Optional|nil} @The first item in the table is the repository to clone.
---@param opts {[1]: string, recursive: boolean, version: Optional|nil}: The first item in the table is the repository to clone.
function M.clone(opts)
local ctx = installer.context()
local repo = assert(opts[1], "No git URL provided.")
Expand Down
22 changes: 11 additions & 11 deletions lua/mason-core/managers/github/client.lua
Expand Up @@ -10,7 +10,7 @@ local M = {}
---@alias GitHubTag {name: string}

---@param path string
---@return Result @JSON decoded response.
---@return Result: JSON decoded response.
local function api_call(path)
return spawn
.gh({ "api", path })
Expand All @@ -22,8 +22,8 @@ local function api_call(path)
end

---@async
---@param repo string @The GitHub repo ("username/repo").
---@return Result @of GitHubRelease[]
---@param repo string: The GitHub repo ("username/repo").
---@return Result: of GitHubRelease[]
function M.fetch_releases(repo)
log.fmt_trace("Fetching GitHub releases for repo=%s", repo)
local path = ("repos/%s/releases"):format(repo)
Expand All @@ -33,8 +33,8 @@ function M.fetch_releases(repo)
end

---@async
---@param repo string @The GitHub repo ("username/repo").
---@param tag_name string @The tag_name of the release to fetch.
---@param repo string: The GitHub repo ("username/repo").
---@param tag_name string: The tag_name of the release to fetch.
function M.fetch_release(repo, tag_name)
log.fmt_trace("Fetching GitHub release for repo=%s, tag_name=%s", repo, tag_name)
local path = ("repos/%s/releases/tags/%s"):format(repo, tag_name)
Expand All @@ -59,9 +59,9 @@ end
---@alias FetchLatestGithubReleaseOpts {tag_name_pattern:string|nil, include_prerelease: boolean}

---@async
---@param repo string @The GitHub repo ("username/repo").
---@param repo string: The GitHub repo ("username/repo").
---@param opts FetchLatestGithubReleaseOpts|nil
---@return Result @of GitHubRelease
---@return Result: of GitHubRelease
function M.fetch_latest_release(repo, opts)
opts = opts or {
tag_name_pattern = nil,
Expand All @@ -86,8 +86,8 @@ function M.fetch_latest_release(repo, opts)
end

---@async
---@param repo string @The GitHub repo ("username/repo").
---@return Result @of GitHubTag[]
---@param repo string: The GitHub repo ("username/repo").
---@return Result: of GitHubTag[]
function M.fetch_tags(repo)
local path = ("repos/%s/tags"):format(repo)
return api_call(path):map_err(function()
Expand All @@ -96,8 +96,8 @@ function M.fetch_tags(repo)
end

---@async
---@param repo string @The GitHub repo ("username/repo").
---@return Result @Result<string> - The latest tag name.
---@param repo string: The GitHub repo ("username/repo").
---@return Result: Result<string> - The latest tag name.
function M.fetch_latest_tag(repo)
-- https://github.com/williamboman/vercel-github-api-latest-tag-proxy
return fetch(("https://latest-github-tag.redwill.se/api/latest-tag?repo=%s"):format(repo))
Expand Down
6 changes: 3 additions & 3 deletions lua/mason-core/managers/go/init.lua
Expand Up @@ -24,15 +24,15 @@ local function with_receipt(packages)
end

---@async
---@param packages { [number]: string, bin: string[] | nil } @The go packages to install. The first item in this list will be the recipient of the requested version, if set.
---@param packages { [number]: string, bin: string[] | nil }: The go packages to install. The first item in this list will be the recipient of the requested version, if set.
function M.packages(packages)
return function()
M.install(packages).with_receipt()
end
end

---@async
---@param packages { [number]: string, bin: string[] | nil } @The go packages to install. The first item in this list will be the recipient of the requested version, if set.
---@param packages { [number]: string, bin: string[] | nil }: The go packages to install. The first item in this list will be the recipient of the requested version, if set.
function M.install(packages)
local ctx = installer.context()
local env = {
Expand Down Expand Up @@ -66,7 +66,7 @@ function M.install(packages)
}
end

---@param output string @The output from `go version -m` command.
---@param output string: The output from `go version -m` command.
function M.parse_mod_version_output(output)
---@type {path: string[], mod: string[], dep: string[], build: string[]}
local result = {}
Expand Down
4 changes: 2 additions & 2 deletions lua/mason-core/managers/luarocks/init.lua
Expand Up @@ -21,7 +21,7 @@ local function with_receipt(package)
end
end

---@param package string @The luarock package to install.
---@param package string: The luarock package to install.
---@param opts { dev: boolean, bin : string[] | nil } | nil
function M.package(package, opts)
return function()
Expand All @@ -30,7 +30,7 @@ function M.package(package, opts)
end

---@async
---@param pkg string @The luarock package to install.
---@param pkg string: The luarock package to install.
---@param opts { dev: boolean, bin : string[] | nil } | nil
function M.install(pkg, opts)
opts = opts or {}
Expand Down
8 changes: 4 additions & 4 deletions lua/mason-core/managers/npm/init.lua
Expand Up @@ -36,15 +36,15 @@ local function with_receipt(packages)
end

---@async
---@param packages { [number]: string, bin: string[] | nil } @The npm packages to install. The first item in this list will be the recipient of the requested version, if set.
---@param packages { [number]: string, bin: string[] | nil }: The npm packages to install. The first item in this list will be the recipient of the requested version, if set.
function M.packages(packages)
return function()
return M.install(packages).with_receipt()
end
end

---@async
---@param packages { [number]: string, bin: string[] | nil } @The npm packages to install. The first item in this list will be the recipient of the requested version, if set.
---@param packages { [number]: string, bin: string[] | nil }: The npm packages to install. The first item in this list will be the recipient of the requested version, if set.
function M.install(packages)
local ctx = installer.context()
local pkgs = list_copy(packages)
Expand Down Expand Up @@ -77,14 +77,14 @@ function M.install(packages)
end

---@async
---@param exec_args string[] @The arguments to pass to npm exec.
---@param exec_args string[]: The arguments to pass to npm exec.
function M.exec(exec_args)
local ctx = installer.context()
ctx.spawn.npm { "exec", "--yes", "--", exec_args }
end

---@async
---@param script string @The npm script to run.
---@param script string: The npm script to run.
function M.run(script)
local ctx = installer.context()
ctx.spawn.npm { "run", script }
Expand Down
4 changes: 2 additions & 2 deletions lua/mason-core/managers/opam/init.lua
Expand Up @@ -24,15 +24,15 @@ local function with_receipt(packages)
end

---@async
---@param packages { [number]: string, bin: string[] | nil } @The opam packages to install. The first item in this list will be the recipient of the requested version, if set.
---@param packages { [number]: string, bin: string[] | nil }: The opam packages to install. The first item in this list will be the recipient of the requested version, if set.
function M.packages(packages)
return function()
return M.install(packages).with_receipt()
end
end

---@async
---@param packages { [number]: string, bin: string[] | nil } @The opam packages to install. The first item in this list will be the recipient of the requested version, if set.
---@param packages { [number]: string, bin: string[] | nil }: The opam packages to install. The first item in this list will be the recipient of the requested version, if set.
function M.install(packages)
local ctx = installer.context()
local pkgs = list_copy(packages)
Expand Down
4 changes: 2 additions & 2 deletions lua/mason-core/managers/pip3/init.lua
Expand Up @@ -28,15 +28,15 @@ local function with_receipt(packages)
end

---@async
---@param packages { [number]: string, bin: string[] | nil } @The pip packages to install. The first item in this list will be the recipient of the requested version, if set.
---@param packages { [number]: string, bin: string[] | nil }: The pip packages to install. The first item in this list will be the recipient of the requested version, if set.
function M.packages(packages)
return function()
return M.install(packages).with_receipt()
end
end

---@async
---@param packages { [number]: string, bin: string[] | nil } @The pip packages to install. The first item in this list will be the recipient of the requested version, if set.
---@param packages { [number]: string, bin: string[] | nil }: The pip packages to install. The first item in this list will be the recipient of the requested version, if set.
function M.install(packages)
local ctx = installer.context()
local pkgs = _.list_copy(packages)
Expand Down

0 comments on commit 63de62c

Please sign in to comment.