Closed KaitlynEthylia closed 4 months ago
Opening a lib.rs page seems useful, but why not add a separate open_lib_rs
function?
Otherwise most other config fields accept format strings as a convention. That would also make the configuration a bit more flexible. So the default value could be "https://crates.io/crates/%s"
.
I like the format string but I'm not sure about a open_lib_rs
function. at the moment open_crates_io
does open the selected frontend, i just didn't rename the function. Maybe an open_frontend
function but i don't see why somebody would want to have both open_frontend
and open_crates_io
at the same time.
Maybe open_crate_index
would be a more fitting name, and then the config option could be named crate_index_url
.
But I'm still more in favor of adding a open_lib_rs
function, because I can't see a downside of having both of these functions. As opposed to having just one function, that would limit, or at least make it harder to have key mappings to open both lib.rs and crates.io.
Even though it's the most popular, i'm still not a huge fan of treating lib.rs as a special front end compared to any others. this has open_crates_io still exist, and always set to crates.io, and adds an extra open_crates_index which will open whatever the frontend is set to.
So this would mean that the default configuration would have two things that do exactly the same things: open_crates_io
and open_crates_index
. I'm not a fan of that.
If it's really necessary that this is freely configurable, then make it a table like this:
open_urls = {
["lib.rs"] = "https://lib.rs/crates/%s",
}
or this:
open_urls = {
{ name = "lib.rs", url = "https://lib.rs/crates/%s"},
}
Since lib.rs is pretty popular, it should be a default value.
Items from this table can be added as actions with name "open_"..key
and instead of the open_crates_index
api function there should be:
function M.open_url(key: string)
...
end
where key
references the configuration and could be used like this:
require("crates").open_url("lib.rs")
should there be a special open_urls.default
key then or something? what url should the popup show?
should the default value maybe be
open_urls = {
default = 'https://crates.io/crates/%s',
['crates.io'] = 'https://crates.io/crates/%s',
['lib.rs'] = 'https://lib.rs/%s'
}
or perhaps default shouldn't be a url and should be another key into open_urls, i.e. open_urls.default = 'crates.io'
And should there be two seperate actions, one for opening crates.io and one for open_urls
. or a single one for opening in whatever open_urls.default
is
I think if we allow it to accept a list, we should retire (or deprecate) crates.open_crates_io, and have the action just perform crates.open_url()
(which would use the default when unspecified)
I've just added a hardcoded lib.rs api function, action and popup entry
As it's such a small edition, i decided to go ahead and do #122. I decided not to mess with any references to crates.io / crates_io internally as that would just add unecessary extra work, and it's too small an edition to justify breaking the
crates.open_crates_io
api