From 57bc7d950a5652bebd8492a8688630c5ab59220d Mon Sep 17 00:00:00 2001 From: pogyomo Date: Sat, 15 Jun 2024 04:26:30 +0900 Subject: [PATCH] refactor: change callback name of `submode.create` --- README.md | 4 ++-- lua/submode/init.lua | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6a00dcf..b5b82a8 100644 --- a/README.md +++ b/README.md @@ -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`. diff --git a/lua/submode/init.lua b/lua/submode/init.lua index 006c519..c38c4a7 100644 --- a/lua/submode/init.lua +++ b/lua/submode/init.lua @@ -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 @@ -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_,