chrishrb / gx.nvim

Implementation of gx without the need of netrw
Apache License 2.0
186 stars 19 forks source link

Allow selecting handler if there are multiple handlers matching #54

Closed reegnz closed 3 months ago

reegnz commented 3 months ago

Right now the first handler that matches in the handlers table is accepted and no other handlers are evaluated. There might be some cases where there's overlap between handlers and multiple handlers are capable of handling a URL.

The https://github.com/rmagatti/gx-extended.nvim plugin handled this by presenting the user with a popup where you could select which handler you'd want to use if there's multiple matches.

Would be great if this feature could be adopted.

chrishrb commented 3 months ago

I've just submitted a PR for this feature request. Could you please take a look and provide your feedback? Any comments or suggestions would be greatly appreciated!

Thanks! 🙏

kevintraver commented 3 months ago

Now when I use gx on the text "chrishrb/gx.nvim", I get multiple selections:

Multiple patterns match. Select:

https://github.com/chrishrb/gx.nvim (nvim-plugin)
https://chrishrb/gx.nvim (url)

Is there a way to always default to github?

kevintraver commented 3 months ago

The issue looks to be with the pattern. Multiple patterns seem to show up when .nvim is at the end.

"chrishrb/gx" does not appear to match multiple patterns.

kevintraver commented 3 months ago

Perhaps url pattern matching without http(s) could be an opt-out feature?

https://github.com/chrishrb/gx.nvim/blob/ea4cc715326a8bd060a450c24c3c9831cdee2f59/lua/gx/handlers/url.lua#L15-L22

This could reduce the number of potential handler conflicts.