From f60d78a29fbe772e0724ee0853a13894b9765fdf Mon Sep 17 00:00:00 2001 From: William Boman Date: Mon, 25 Oct 2021 14:55:47 +0200 Subject: add proper emmylua annotations (#196) --- lua/nvim-lsp-installer/installers/context.lua | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'lua/nvim-lsp-installer/installers/context.lua') 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) -- cgit v1.2.3-70-g09d2