From 7cd5356a6f89a46d83bbba9b7f6496b67f054629 Mon Sep 17 00:00:00 2001 From: Tom Ampuero <46233260+tampueroc@users.noreply.github.com> Date: Sun, 13 Jul 2025 21:43:11 +0100 Subject: feat(net): vim.net.request(), :edit [url] #34140 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- runtime/lua/vim/_editor.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'runtime/lua/vim/_editor.lua') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index dd9fc221d1..50fac8cf9e 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -41,6 +41,7 @@ for k, v in pairs({ snippet = true, pack = true, _watch = true, + net = true, }) do vim._submodules[k] = v end -- cgit