tyru / open-browser-github.vim

Open GitHub URL of current file, etc. from Vim editor (supported GitHub Enterprise)
BSD 3-Clause "New" or "Revised" License
173 stars 14 forks source link

Support ssh remote urls without git@ #39

Closed k0kubun closed 3 years ago

k0kubun commented 3 years ago

Problem

If you have an ssh config like:

Host github.com
  HostName github.com
  User git
  Port 22
  IdentityFile ~/.ssh/id_rsa

you can use some URLs which are currently not handled by open-browser-github.vim, such as:

$ git remote -v
origin  github.com:tyru/open-browser-github.vim (fetch)
origin  github.com:tyru/open-browser-github.vim (push)

$ git remote -v
origin  ssh://github.com/tyru/open-browser-github.vim (fetch)
origin  ssh://github.com/tyru/open-browser-github.vim (push)

and it shows "Could not detect repos user" to me. I personally use the first format and one of the tools I use uses the second format, so I want open-browser-github.vim to allow these as well.

Solution

I added ssh2_re and ssh3_re for these. I tried to use \%( and \) to simplify the implementation, but somehow ssh ended up captured as m[1] when I tried it. So I added them separately.

k0kubun commented 3 years ago

Thank you!