Skip to content

Bug: actions.system doesn't work with custom routers #259

@theherk

Description

@theherk
  1. What's the output of git remote get-url origin?
ᐅ git remote get-url origin
https://github.com/linrongbin16/gitlinker.nvim.git
  1. what's the expect git host url you want to generate?

It is generated correctly, but it uses the clipboard action with either the command or API.

  1. how do you configure this plugin?
later(function()
  add({
    source = "linrongbin16/gitlinker.nvim",
    depends = { "nvim-lua/plenary.nvim" },
  })
  local gitlinker = require("gitlinker")
  local actions = require("gitlinker.actions")
  local routers = require("gitlinker.routers")
  local base_path = "{_A.PROTOCOL}://{_A.HOST}/"
  local repo_path = "{_A.ORG}/{_A.REPO}/"
  local file_path = repo_path .. "blob/{_A.REV}/{_A.FILE}"
  gitlinker.setup({
    router = {
      file = {
        ["gitlab%.com"] = base_path .. file_path,
        ["^github%.com"] = base_path .. file_path,
      },
      repo = {
        ["gitlab%.com"] = repo_path .. file_path,
        ["^github%.com"] = repo_path .. file_path,
      },
    },
    mappings = nil,
  })
  vim.keymap.set({ "n", "v" }, "<leader>glr", function() gitlinker.link({ router_type = "repo" }) end, { desc = "repo yank" })
  vim.keymap.set({ "n", "v" }, "<leader>glR", function() gitlinker.link({ router_type = "repo", action = actions.system }) end, { desc = "repo open" })
  vim.keymap.set({ "n", "v" }, "<leader>glf", function() gitlinker.link({ router_type = "file" }) end, { desc = "file yank" })
  vim.keymap.set({ "n", "v" }, "<leader>glF", function() gitlinker.link({ router_type = "file", action = actions.system }) end, { desc = "file open" })
  vim.keymap.set({ "n", "v" }, "<leader>gll", function() gitlinker.link({ router_type = "browse" }) end, { desc = "lines yank" })
  vim.keymap.set({ "n", "v" }, "<leader>glL", function() gitlinker.link({ router_type = "browse", action = actions.system }) end, { desc = "lines open" })
end)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions