Skip to content

Commit

Permalink
fixup! gen vimdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLeoP committed Jun 21, 2024
1 parent fd68322 commit bc95b53
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 33 deletions.
88 changes: 57 additions & 31 deletions runtime/doc/lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4436,50 +4436,76 @@ tohtml.tohtml({winid}, {opt}) *tohtml.tohtml.tohtml()*
==============================================================================
Lua module: vim.net *vim.net*

vim.net.download({url}, {opts}) *vim.net.download()*
Asynchronously download a file
*vim.net.Request*

Fields: ~
{wait} (`fun(self: vim.net.Requesttimeout: integer?)`)
{kill} (`fun(self: vim.net.Requestsignal: integer|string)`)


Request:kill({signal}) *Request:kill()*

Parameters: ~
{signal} (`integer|string`)

Request:wait({timeout}) *Request:wait()*

Parameters: ~
{timeout} (`integer?`)

vim.net.request({url}, {opts}) *vim.net.request()*
Download a file

Parameters: ~
{url} (`string`) Request URL
{opts} (`table?`) Additional options

Example: >lua
-- Download a file
-- The file will be saved in the `cwd` with the name `anything`
vim.net.download("https://httpbingo.org/anything")

-- Download a file to a path
-- The file will be saved in `/tmp/somefile`
vim.net.download("https://httpbingo.org/anything", {
as = "tmp/somefile",
})

-- Download a file while sending headers
vim.net.download("https://httpbingo.org/anything", {
headers = {
Authorization = { "Bearer foo" },
},
})

-- Download a file while handling basic auth
vim.net.download("https://httpbingo.org/basic-auth/user/password", {
credentials = "user:password",
})
<
{as}? (`string`) Path to write the downloaded file to. If
{file}? (`string`) Path to write the downloaded file to. If
not provided, the one inferred from the URL will be used.
Defaults to `nil`
{credentials}? (`string`) Credentials with the format
{user}? (`string`) Credentials with the format
`username:password`. Defaults to `nil`
{raw}? (`boolean`) Disables all internal HTTP decoding of
content or transfer encodings. Unaltered, raw, data is
passed. Defaults to `false`
{headers}? (`table<string, string[]>`) Request headers.
Defaults to `nil`
• {redirect_credentials}? (`boolean`) Whether `credentials`
should be send to host after a redirect. Defaults to `false`
• {location_trusted}? (`boolean`) Whether `user` should be
send to host after a redirect. Defaults to `false`
• {on_exit}? (`fun(err: string?)`) Optional callback. Defaults
to showing a notification when the file has been downloaded.
to `nil`

Return: ~
(`vim.net.Request`) request

Example: >lua
-- Download a file (async)
-- The file will be saved in the `cwd` with the name `anything`
vim.net.request("https://httpbingo.org/anything")

-- Download a file (sync)
-- The file will be saved in the `cwd` with the name `anything`
vim.net.request("https://httpbingo.org/anything"):wait(500)

-- Download a file to a path (async)
-- The file will be saved in `/tmp/somefile`
vim.net.request("https://httpbingo.org/anything", {
file = "/tmp/somefile",
})

-- Download a file while sending headers (async)
vim.net.request("https://httpbingo.org/anything", {
headers = {
Authorization = { "Bearer foo" },
},
})

-- Download a file while handling basic auth (async)
vim.net.request("https://httpbingo.org/basic-auth/user/password", {
user = "user:password",
})

```. See |vim.net.Request|.
<


vim:tw=78:ts=8:sw=4:sts=4:et:ft=help:norl:
2 changes: 0 additions & 2 deletions runtime/lua/vim/net.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ local M = {}

---@class vim.net.Request
---@field private _system vim.SystemObj
---@field wait fun(self: vim.net.Request, timeout?: integer): string?
---@field kill fun(self: vim.net.Request, signal: integer|string)
local Request = {}

--- @param system vim.SystemObj
Expand Down

0 comments on commit bc95b53

Please sign in to comment.