aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/installers/context.lua
diff options
context:
space:
mode:
authorWilliam Boman <william@redwill.se>2021-10-25 14:55:47 +0200
committerGitHub <noreply@github.com>2021-10-25 14:55:47 +0200
commitf60d78a29fbe772e0724ee0853a13894b9765fdf (patch)
treeadf8fd822587d779c5b90d5ed30987a982fd497e /lua/nvim-lsp-installer/installers/context.lua
parentfix :LspPrintInstalled (diff)
downloadmason-f60d78a29fbe772e0724ee0853a13894b9765fdf.tar
mason-f60d78a29fbe772e0724ee0853a13894b9765fdf.tar.gz
mason-f60d78a29fbe772e0724ee0853a13894b9765fdf.tar.bz2
mason-f60d78a29fbe772e0724ee0853a13894b9765fdf.tar.lz
mason-f60d78a29fbe772e0724ee0853a13894b9765fdf.tar.xz
mason-f60d78a29fbe772e0724ee0853a13894b9765fdf.tar.zst
mason-f60d78a29fbe772e0724ee0853a13894b9765fdf.zip
add proper emmylua annotations (#196)
Diffstat (limited to 'lua/nvim-lsp-installer/installers/context.lua')
-rw-r--r--lua/nvim-lsp-installer/installers/context.lua16
1 files changed, 14 insertions, 2 deletions
diff --git a/lua/nvim-lsp-installer/installers/context.lua b/lua/nvim-lsp-installer/installers/context.lua
index c36a9e65..13775fc0 100644
--- a/lua/nvim-lsp-installer/installers/context.lua
+++ b/lua/nvim-lsp-installer/installers/context.lua
@@ -6,6 +6,8 @@ local platform = require "nvim-lsp-installer.platform"
local M = {}
+---@param url string @The url to fetch.
+---@param callback fun(err: string|nil, raw_data: string)
local function fetch(url, callback)
local stdio = process.in_memory_sink()
log.fmt_debug("Fetching URL %s", url)
@@ -57,7 +59,9 @@ local function fetch(url, callback)
}
end
+---@param repo string @The GitHub repo ("username/repo").
function M.use_github_release(repo)
+ ---@type ServerInstallerFunction
return function(server, callback, context)
if context.requested_server_version then
log.fmt_debug(
@@ -84,6 +88,8 @@ function M.use_github_release(repo)
end
end
+---@param repo string @The GitHub report ("username/repo").
+---@param file string @The name of a file availabine in the provided repo's GitHub releases.
function M.use_github_release_file(repo, file)
return installers.pipe {
M.use_github_release(repo),
@@ -117,14 +123,20 @@ function M.use_github_release_file(repo, file)
}
end
+---Access the context ojbect to create a new installer.
+---@param fn fun(context: ServerInstallContext): ServerInstallerFunction
function M.capture(fn)
- return function(server, callback, context, ...)
+ ---@type ServerInstallerFunction
+ return function(server, callback, context)
local installer = fn(context)
- installer(server, callback, context, ...)
+ installer(server, callback, context)
end
end
+---Update the context object.
+---@param fn fun(context: ServerInstallContext): ServerInstallerFunction
function M.set(fn)
+ ---@type ServerInstallerFunction
return function(_, callback, context)
fn(context)
callback(true)