diff --git a/lua/config/git-linker.lua b/lua/config/git-linker.lua index e19f0a81..39f5ba21 100644 --- a/lua/config/git-linker.lua +++ b/lua/config/git-linker.lua @@ -2,24 +2,36 @@ local keymap = vim.keymap local gitlinker = require("gitlinker") gitlinker.setup { + callbacks = { + ["dev.azure.com"] = function(url_data) + vim.print(url_data) + local url = require"gitlinker.hosts".get_base_https_url(url_data) + + if url_data.lstart then + if url_data.lend == nil then + url_data.lend = url_data.lstart + end + url = url .. "?path=/" .. url_data.file .. "&version=GC" .. url_data.rev .. "&line=" .. url_data.lstart .. "&lineEnd=" .. url_data.lend .. "&lineStartColumn=1" .. "&lineEndColumn=120" + end + return url + end + }, mappings = nil, } -keymap.set({ "n", "v" }, "gl", "", { +keymap.set({ "n", "v" }, "gl", function() + local mode = string.lower(vim.fn.mode()) + gitlinker.get_buf_range_url(mode) +end, { silent = true, desc = "get git permlink", - callback = function() - local mode = string.lower(vim.fn.mode()) - gitlinker.get_buf_range_url(mode) - end, }) -keymap.set("n", "gb", "", { +keymap.set("n", "gb", function() + gitlinker.get_repo_url({ + action_callback = gitlinker.actions.open_in_browser + }) +end, { silent = true, desc = "browse repo in browser", - callback = function() - gitlinker.get_repo_url({ - action_callback = gitlinker.actions.open_in_browser - }) - end })