lambdalisue / vim-gina

👣 Asynchronously control git repositories in Neovim/Vim 8
http://www.vim.org/scripts/script.php?script_id=5531
MIT License
689 stars 27 forks source link

How to setup Gina browse using a different host name for github.com ? #296

Closed thecontinium closed 2 years ago

thecontinium commented 2 years ago

Hi

I have different ssh host names setup for different GitHub users so that I can clone a GitHub repo as a specific user using a different host name. Using IncludeIf I switch automatically between users depending on the project ( directory) I am working in.

e.g. In .ssh config

Host user.one
HostName github.com
User git
IdentityFile user.one

which means I can clone a (this) repo using user.one ssh credentials with

git clone git@user.one:lambdalisue/gina.vim

When I use gina browse for repo's cloned in this way I get the following message: [gina] No url translation pattern for "" is found.

I can see that there is an option g:gina#command#browse#translation_patterns but it's not immediately obvious how to use it in this case.

How can I setup gina so that gina browse will work with repo's cloned in this way ?

Thanks

lambdalisue commented 2 years ago

Not sure but try

    call extend(g:gina#command#browse#translation_patterns, {
        \ 'user.one': [
        \   [
        \     '\vhttps?://(%domain)/(.{-})/(.{-})%(\.git)?$',
        \     '\vgit://(%domain)/(.{-})/(.{-})%(\.git)?$',
        \     '\vgit\@(%domain):(.{-})/(.{-})%(\.git)?$',
        \     '\vssh://git\@(%domain)/(.{-})/(.{-})%(\.git)?$',
        \   ], {
        \     'root':  'https://github.com/\2/\3/tree/%r1/',
        \     '_':     'https://github.com/\2/\3/blob/%r1/%pt%{#L|}ls%{-}le',
        \     'exact': 'https://github.com/\2/\3/blob/%h1/%pt%{#L|}ls%{-}le',
        \   },
        \ ],
        \})
thecontinium commented 2 years ago

Cheers - does the trick !