Skip to content

Commit

Permalink
ref(Layer): prefer rhs to callback
Browse files Browse the repository at this point in the history
  • Loading branch information
Iron-E committed May 17, 2022
1 parent a898124 commit 0786a9f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lua/libmodal/src/Layer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ end
--- @param keymap table
--- @return table normalized
local function normalize_keymap(keymap)
-- `buffer == 0` just means "not a buffer mapping"
-- Keys which must be manually edited
keymap.buffer = keymap.buffer > 0 and keymap.buffer or nil
keymap.rhs = keymap.callback or keymap.rhs

-- Keys which are `v:true` or `v:false`
keymap.expr = globals.is_true(keymap.expr)
Expand All @@ -27,11 +28,12 @@ local function normalize_keymap(keymap)
keymap.silent = globals.is_true(keymap.silent)

-- Keys which should not exist
keymap.callback = nil
keymap.lhs = nil
keymap.lnum = nil
keymap.mode = nil
keymap.script = nil
keymap.sid = nil
keymap.mode = nil

return keymap
end
Expand All @@ -46,7 +48,7 @@ end
--- @param keymap table the keymap to unpack
--- @return function|string rhs, table options
local function unpack_keymap_rhs(keymap)
local rhs = keymap.rhs or ''
local rhs = keymap.rhs
keymap.rhs = nil

return rhs, keymap
Expand Down

0 comments on commit 0786a9f

Please sign in to comment.