strboul/urlview.vim

Netrw gx problem

Closed this issue · 2 comments

Cool plug-in. I am using iVim on an iPad, and I'm trying to utilize the plug-in but I'm running into a problem with the netrw gx command because of Apple restrictions. I'd like to add the command ":iopenurl URL_Here" right below the call s:OpenLink(l:chosen_url)

How do I do that?

It is likely something simple. Below is the help section about iopenurl from iVim.

=====

iVim adds one command to support the URL scheme opening |ios-open-url|.

:io[penurl] {url} :io :iopenurl
Open the {url} to invoke the iOS URL scheme workflow.

	Example: >
		:io https://www.example.com/search?q={@*%[Q}

<
It will launch Safari and open the site "www.example.com" and
do a search with the contents in the clipboard as the query.

	Note that it opens only one URL at a time.

Variable token ~

You need to use variable tokens to include useful info into an URL. The format
for a variable token is "{expr%[encode}".

a. the "{" and "}" are the opening and closing delimiter respectively.

As a result, they need to be backslash-escaped if you want to use them
literally in the URL. Note that nested token is not supported.

b. the "expr" is a vim |expression| which will be replaced with its value when
the whole URL is opened.

This expression will be evaluated by vim and errors will be given if it is
invalid. Note a) only expressions with value type "string" and "number" are
supported. b) tokens are evaluated one by one from left to right.

c. the "%[" is the indicator for a following URL encoding type.

d. the "encode" is the URL encoding type which is explained in details below.

Backslash escape ~

Sometimes you need to put certain characters literally into an URL. You can
put a backslash character before each to achieve this. For example, "{expr}"
will be treated literally instead of a variable token.

Because of its special meaning, a literal backslash always needs to be
backslash escaped, e.g. "\".

URL encoding ~

Certain characters in an URL need to be percent encoded for a successful
opening. Moreover, in different parts of an URL, the characters that need
encoding differ. iVim provides an URL encoding type to help with this.

A typical URL skeleton is

scheme://user:password@host:port/path?query#fragment

<
The following encoding types are available:

U:	indicates encoding for "user" part
PW:	"password" part
H:	"host" part
PT:	"path" part
Q:	"query" part, it is the default
F:	"fragment" part

For example, if you will include a variable token into the "host" part, you
need to indicate it as "{expr%[H}". Then iVim will encode its value for the
specific part automatically. Omitting the encoding part, e.g. "{expr}", will
encode it for the default "query" part. Note that they are case insensitive.
e.g. "%[Q" and "%[q" mean the same encoding.

Debug errors ~

iVim provides some debug errors when you try to open an URL but it has some
problems.

"token open character { expected":
a closing delimiter is encountered before an opening one.
"token close character } expected":
one opening delimiter is expecting a closing one but none given.
"nested token not allowed":
you are trying to put a variable token inside another one.
"unfinished character escaping":
there is a backslash at the end of the URL.
"invalid path: ...":
the URL is invalid
"failed to open URL: ...":
the system failed to open the given URL.

If the position of the problem can be located in the URL, it will be
highlighted as ">...<".

==============================================================================

Unfortunately, gx command has been a problem in mac devices for a while. The issue is identified here: vim/vim#4738

Could you test if gx works when you move your cursor onto an URL?

If it doesn't work, maybe it's time to upgrade your Vim?

I'm on a Mac OSX machine and upgraded to the latest neovim (nightly) and have no problem whatsoever. Before that, I also had some problems.

My version:

NVIM v0.5.0-nightly-109-g0798ad3a3

Closing as it's not an issue of the urlview.