tpope / vim-fugitive

fugitive.vim: A Git wrapper so awesome, it should be illegal
https://www.vim.org/scripts/script.php?script_id=2975
19.82k stars 1k forks source link

feat: support vim.ui.open for GBrowse on Neovim #2322

Closed stevearc closed 1 month ago

stevearc commented 1 month ago

It is not uncommon for Neovim users to have netrw disabled in favor of other file explorers. When this is the case, :GBrowse fails. Neovim 0.10 ships with a new [vim.ui.open](https://neovim.io/doc/user/lua.html#vim.ui.open()) helper method that is designed to replace this exact functionality.

This PR simply preferentially uses vim.ui.open in Neovim 0.10+ over netrw. I have tested it with a simple :GBrowse in a file and it appears to work well.

tpope commented 1 month ago

Netrw brings a bit more to the table than just opening a URL: It also displays an error message if something went wrong. Despite having ui in the name, vim.ui.open doesn't concern itself with this UI affordance, or indeed, any other UI at all. We'd need a dozen lines of Lua to achieve the same behavior as Netrw, and I don't want to add a _fugitive.lua just for that.

As a compromise, I have added support with more limited error handling, but given it a priority below Netrw.

stevearc commented 1 month ago

Works for me, thank you!