Skip to content

Commit 85794a7

Browse files
authored
fix: mappings (ruifm#51)
* fix: mappings * fix: mappings=false * wording * fix: mappings=false
1 parent b039e13 commit 85794a7

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ EOF
9393
There're two key mappings defined by default:
9494

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

9898
To disable the default key mappings, set `mapping = false` in `setup()` function
9999
(see [Configuration](#configuration)).
@@ -116,9 +116,9 @@ require('gitlinker').setup({
116116
desc = "Copy git link to clipboard",
117117
},
118118
["<leader>gL"] = {
119-
-- open git link in default browser
119+
-- open git link in browser
120120
action = require("gitlinker.actions").system,
121-
desc = "Open git link in default browser",
121+
desc = "Open git link in browser",
122122
},
123123
},
124124

lua/gitlinker.lua

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ local Defaults = {
2323
},
2424
["<leader>gL"] = {
2525
action = require("gitlinker.actions").system,
26-
desc = "Open git link in default browser",
26+
desc = "Open git link in browser",
2727
},
2828
},
2929

@@ -106,9 +106,18 @@ local function setup(option)
106106
file = Configs.file_log,
107107
})
108108

109+
local key_mappings = nil
110+
if type(option) == "table" and option["mapping"] ~= nil then
111+
if type(option["mapping"]) == "table" then
112+
key_mappings = option["mapping"]
113+
end
114+
else
115+
key_mappings = Defaults.mapping
116+
end
117+
109118
-- key mapping
110-
if Configs.mapping and #Configs.mapping > 0 then
111-
for k, v in pairs(Configs.mapping) do
119+
if key_mappings then
120+
for k, v in pairs(key_mappings) do
112121
local opt = {
113122
noremap = true,
114123
silent = true,

0 commit comments

Comments
 (0)