New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request: Opposite of :GBrowse #2223
Comments
I too have wanted this, but it's a lot easier said than done. For starters, parsing the URL is nontrivial. Is the example you gave for But even if we solve that, or just ignore nested refs, that's just the first challenge of many. How do we find the repository on disk? What's the user interface? What lives in Rhubarb, what lives in Fugitive, and what lives in a hypothetical new plugin? How do these plugins talk to each other? I don't see working on this in the foreseeable future. And unfortunately, I don't really have much advice to give for someone attempting to tackle this themselves. I suppose one could start with the "find on disk" problem, as that will probably dictate much of the rest of the design. |
FWIW the workaround I use for this is navigating through some related commit. It is easy to grab hash for some commit touching the file on Github – i.e. last commit modified the file is displayed in the header. Then I It's many steps and does not solve jumping to a specific line – but I find it easier and more reliable than manually extracting file path from URL |
@tpope @markis I came across this issue and wanted to let you know that there is an undocumented API for the ref/path disambiguation part (I work at GitHub but am not speaking on behalf of the company, just a happy fugitive/rhubarb user)
This could likely be promoted to a supported API if someone expressed interest. In terms of figuring out which repo to open, why not just assume the path is for the repo opened by the current buffer? |
Color me interested. Ideally it would also include the commit SHA, to save us a second request, but even without that it's perfectly adequate to solve the problem at hand.
Verify, not assume, but this would be an adequate starting point, yes. |
Related, could someone save me the trouble and tell me the API for converting a ref to a commit SHA? We could get it from |
That would be this one. |
The |
Use `:Gedit https://github.com/...` (or any other URL supported by an installed :GBrowse provider) to edit the corresponding `fugitive://` URL. The dictionary g:fugitive_url_origins maps between homepage URLs and local repositories: let g:fugitive_url_origins = { 'https://github.com/me/my-repo': '~/Projects/my-repo'} It also checks the remotes of the repository that the currently edited buffer belongs to. This is an experimental prototype. That means no documentation, and no guarantees about behavior. In particular, g:fugitive_url_origins and the current contortions to leverage the existing :GBrowse API will likely be dropped once a better API has been developed. References: #2223
Not long after my last comment I prototyped this, settling on Over a year later, that hasn't happened, so I am shipping the prototype as is in df36d19. The interface is simply to pass the URL to one of Fugitive's edit commands, like A big limitation of using edit commands as an interface is that if you give it an unrecognized URL, it silently falls back to using netrw to edit the raw HTML, which is annoying to say the least. This is something a new API could address, as that would allow the adapter to recognize arbitrary URLs from a provider without knowledge of the specific repository. (I don't want to throw out the netrw fallback entirely.) I'll leave this issue open until it's officially supported and documented. |
I would like to take a url and navigate to the file. Given a github url, then vim would open the file and potentially go the line that's being highlighted in the url.
For example, if I had this repo open and I executed a command such as
:GBrowse https://github.com/tpope/vim-rhubarb/blob/master/autoload/rhubarb.vim#L2
. Then vim would openautoload/rhubarb.vim
and go to line 2.The text was updated successfully, but these errors were encountered: