netrw from neovim
(Neo)vim -- yeah, it's not specific to neovim -- supports opening random file types that aren't actually located locally. It does this via netrw. This makes it possible to connect to and edit remote files or at the very least to view them. This is accomplished through identifying the resource type and then walking through a prioritized list of handlers for fetching (and later saving) the remote content.
My addon, Neopunk, was created to pull remote content into the current document, not to do the same thing that netrw does but to dump content into the current document. This is similar to :Nread but I have no idea how to add new protocol schemes (like gemini:) to neovim. So the addon is filling this gap.
Use offpunk for netrw, gf, etc. for http/https
If all I wanted was a method for opening remote (http/https) content, I could have set a handler and then gf on any http/https link would get opened in offpunk or openk.
Here's how to do that.
The goal is to set T383838netrw_http_cmd to a command that will write the content of a link to a file. Netrw makes an invocation based on the T383838netrw_http_cmd value. So put something in that value that can be replaced with the url (T383838%s) and make it take an argument of the temporary file that will receive the output. Or, more simply put:
let g:netrwhttpcmd="openk.py %s >"
Put that into T383838.vimrc or the following into T383838init.lua:
vim.g.netrwhttpcmd="openk.py %s >"
The result is that now using T383838gf on an http or https link will render that link in neovim by calling offpunk's openk on the target.
Tags: neovim
Tags
Navigation