~tomleb/repo-url.nvim

5780578ad26278c7fd70e76cebc4eece6db63fe9 — Tom Lebreux 6 months ago f3730c5
Add support for cgit repository
1 files changed, 14 insertions(+), 0 deletions(-)

M lua/repo-url/init.lua
M lua/repo-url/init.lua => lua/repo-url/init.lua +14 -0
@@ 106,6 106,19 @@ M.urls = {
      return string.format('%s/+log/%s/%s', opts.base_url, opts.ref, opts.filepath)
    end,
  },
  cgit = {
    blob_url = function(opts)
      local position = pos_to_path(opts, '#n%d')
      return string.format('%s/tree/%s?id=%s%s', opts.base_url, opts.filepath, opts.ref, position)
    end,
    blame_url = function(opts)
      local position = pos_to_path(opts, '#n%d')
      return string.format('%s/blame/%s?id=%s%s', opts.base_url, opts.filepath, opts.ref, position)
    end,
    raw_url = function(opts)
      return string.format('%s/plain/%s?id=%s', opts.base_url, opts.filepath, opts.ref)
    end,
  },
}

--- @class RepoUrl.Config


@@ 122,6 135,7 @@ local config = {
    ['gitlab.alpinelinux.org'] = M.urls.gitlab,
    ['codeberg.org'] = M.urls.codeberg,
    ['go.googlesource.com'] = M.urls.gitiles,
    ['git.zx2c4.com'] = M.urls.cgit,
  },
}