Skip to content

Commit

Permalink
fix: mappings (#51)
Browse files Browse the repository at this point in the history
* fix: mappings

* fix: mappings=false

* wording

* fix: mappings=false
  • Loading branch information
linrongbin16 committed Jul 14, 2023
1 parent b039e13 commit 85794a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
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

0 comments on commit 85794a7

Please sign in to comment.