Skip to content

Resolve hostname set in ssh config #53

@joaodubas

Description

@joaodubas

Is your feature request related to a problem? Please describe.

Usually, I configure access to git hosts through ssh config. This makes it easier to set different keys for my work and personal projects, as well as it simplifies setup remote hosts.

However, the current parser expects remote uri to be set as https://<hostname>/<user>/<repo>.git, or ssh://git@<hostname>/<user>/<repo>.git, or git@<hostname>:<user>/<repo>.git, and in my case, the remote uri is set as <alias>:<user>/<repo>.git, which causes the following error:

E5108: Error executing lua ...e/pack/packer/start/gitlinker.nvim/lua/gitlinker/git.lua:86: attempt to index local 'uri' (a nil value)
stack traceback:
        ...e/pack/packer/start/gitlinker.nvim/lua/gitlinker/git.lua:86: in function 'strip_uri'
        ...e/pack/packer/start/gitlinker.nvim/lua/gitlinker/git.lua:140: in function 'parse_uri'
        ...e/pack/packer/start/gitlinker.nvim/lua/gitlinker/git.lua:219: in function 'get_repo_data'
        .../site/pack/packer/start/gitlinker.nvim/lua/gitlinker.lua:55: in function 'get_buf_range_url_data'
        .../site/pack/packer/start/gitlinker.nvim/lua/gitlinker.lua:115: in function 'get_buf_range_url'
        [string ":lua"]:1: in main chunk

Describe the solution you'd like

It's possible to resolve the hostname using ssh -G <alias>, which returns a parseable result:

user git
hostname <hostname>
port <port>
...

Describe alternatives you've considered

  1. I changed my host alias to match the hostname without success.
  2. gitlinker could have a hook for the parser, making it possible to override the default implementation.

Additional context

--

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions