Skip to content

Commit

Permalink
refactor: change callback name of submode.create
Browse files Browse the repository at this point in the history
  • Loading branch information
pogyomo committed Jun 14, 2024
1 parent a57db05 commit 57bc7d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,8 @@ The following user events will be triggered.
- `"error"` Throw error. This is default.
- `"keep"` Keep current submode.
- `"override"` Override old submode.
- `register?: function` Callback to register default mappings. Take a following value:
- `default: fun(lhs: string, rhs: string | function, opts?: table)` When called, register given default mapping to this submode.
- `default?: function` Callback to register default mappings. Take a following value:
- `register: fun(lhs: string, rhs: string | function, opts?: table)` When called, register given default mapping to this submode.

- `set(name, lhs, rhs, opts)`
- Add a mapping to `name`. Same interface as `vim.keymap.set`.
Expand Down
10 changes: 5 additions & 5 deletions lua/submode/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ local M = {
---Create a new submode.
---@param name string Name of this submode.
---@param opts SubmodeOpts Options of this submode.
---@param register? fun(default: SubmodeDefaultMappingRegister) Default mappings register
function M.create(name, opts, register)
---@param default? fun(register: SubmodeDefaultMappingRegister) Default mappings register
function M.create(name, opts, default)
vim.validate {
name = { name, "string" },
opts = { opts, "table" },
register = { register, "function", true },
default = { default, "function", true },
}

local state = M.state
Expand Down Expand Up @@ -69,10 +69,10 @@ function M.create(name, opts, register)
})
end

if not register then
if not default then
return
end
register(function(lhs, rhs, opts_)
default(function(lhs, rhs, opts_)
M.state.submode_to_default_mappings[name][lhs] = {
rhs = rhs,
opts = opts_,
Expand Down

0 comments on commit 57bc7d9

Please sign in to comment.