ruifm / gitlinker.nvim

A lua neovim plugin to generate shareable file permalinks (with line ranges) for several git web frontend hosts. Inspired by tpope/vim-fugitive's :GBrowse
GNU General Public License v3.0
525 stars 44 forks source link

get_cgit_type_url produces wrong URLs without project #66

Open tastytea opened 2 years ago

tastytea commented 2 years ago

Describe the bug

URLs for repositories managed with cgit, for example https://git.kernel.org/, are missing the repository part. The URLs are <host>/tree/file instead of <host>/<repo>/tree/file.

To Reproduce

minimal init.lua:

local install_path = vim.fn.stdpath('data') ..
    '/site/pack/packer/start/packer.nvim'
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
    vim.fn.system({
        'git', 'clone',
        'https://github.com/wbthomason/packer.nvim', install_path
    })
    vim.cmd [[packadd packer.nvim]]
end

require('packer').startup({ function(use)
    use { 'https://github.com/wbthomason/packer.nvim' }
    use {
        'https://github.com/ruifm/gitlinker.nvim',
        requires = { 'https://github.com/nvim-lua/plenary.nvim' }
    }
end})

require("packer").sync()

require"gitlinker".setup()
  1. git clone https://git.kernel.org/pub/scm/docs/man-pages/man-pages-posix.git
  2. cd man-pages-posix && nvim README
  3. generate permalink
  4. permalink is https://git.kernel.org/tree/README?id=3032a293a74969989e3ed4921b690cf9442ac674#n1

Expected behavior

The permalink should be https://git.kernel.org/pub/scm/docs/man-pages/man-pages-posix.git/tree/README?id=3032a293a74969989e3ed4921b690cf9442ac674#n1

System (please complete the following information):