Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ EOF
There're two key mappings defined by default:

- `<leader>gl` (normal/visual mode): copy git link to clipboard.
- `<leader>gL` (normal/visual mode): open git link in default browser.
- `<leader>gL` (normal/visual mode): open git link in browser.

To disable the default key mappings, set `mapping = false` in `setup()` function
(see [Configuration](#configuration)).
Expand All @@ -116,9 +116,9 @@ require('gitlinker').setup({
desc = "Copy git link to clipboard",
},
["<leader>gL"] = {
-- open git link in default browser
-- open git link in browser
action = require("gitlinker.actions").system,
desc = "Open git link in default browser",
desc = "Open git link in browser",
},
},

Expand Down
15 changes: 12 additions & 3 deletions lua/gitlinker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ local Defaults = {
},
["<leader>gL"] = {
action = require("gitlinker.actions").system,
desc = "Open git link in default browser",
desc = "Open git link in browser",
},
},

Expand Down Expand Up @@ -106,9 +106,18 @@ local function setup(option)
file = Configs.file_log,
})

local key_mappings = nil
if type(option) == "table" and option["mapping"] ~= nil then
if type(option["mapping"]) == "table" then
key_mappings = option["mapping"]
end
else
key_mappings = Defaults.mapping
end

-- key mapping
if Configs.mapping and #Configs.mapping > 0 then
for k, v in pairs(Configs.mapping) do
if key_mappings then
for k, v in pairs(key_mappings) do
local opt = {
noremap = true,
silent = true,
Expand Down