mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
feat(net): vim.net.request(), :edit [url] #34140
Problem: Nvim depends on netrw to download/request URL contents. Solution: - Add `vim.net.request()` as a thin curl wrapper: - Basic GET with --silent, --show-error, --fail, --location, --retry - Optional `opts.outpath` to save to a file - Operates asynchronously. Pass an `on_response` handler to get the result. - Add integ tests (requires NVIM_TEST_INTEG to be set) to test success and 404 failure. - Health check for missing `curl`. - Handle `:edit https://…` using `vim.net.request()`. API Usage: 1. Asynchronous request: vim.net.request('https://httpbingo.org/get', { retry = 2 }, function(err, response) if err then print('Fetch failed:', err) else print('Got body of length:', #response.body) end end) 2. Download to file: vim.net.request('https://httpbingo.org/get', { outpath = 'out_async.txt' }, function(err) if err then print('Error:', err) end end) 3. Remote :edit integration (in runtime/plugin/net.lua) fetches into buffer: :edit https://httpbingo.org/get
This commit is contained in:
@ -161,6 +161,7 @@ local config = {
|
||||
'snippet.lua',
|
||||
'text.lua',
|
||||
'tohtml.lua',
|
||||
'net.lua',
|
||||
},
|
||||
files = {
|
||||
'runtime/lua/vim/iter.lua',
|
||||
@ -192,6 +193,7 @@ local config = {
|
||||
'runtime/lua/vim/_meta/re.lua',
|
||||
'runtime/lua/vim/_meta/spell.lua',
|
||||
'runtime/lua/tohtml.lua',
|
||||
'runtime/lua/vim/net.lua',
|
||||
},
|
||||
fn_xform = function(fun)
|
||||
if contains(fun.module, { 'vim.uri', 'vim.shared', 'vim._editor' }) then
|
||||
|
Reference in New Issue
Block a user