summaryrefslogtreecommitdiff
path: root/lua/clever_f/composition_root.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/clever_f/composition_root.lua')
-rw-r--r--lua/clever_f/composition_root.lua27
1 files changed, 26 insertions, 1 deletions
diff --git a/lua/clever_f/composition_root.lua b/lua/clever_f/composition_root.lua
index 051520c..0ea9675 100644
--- a/lua/clever_f/composition_root.lua
+++ b/lua/clever_f/composition_root.lua
@@ -19,6 +19,13 @@ M.ACTION_NAMES = {
"RepeatSameDirection",
"RepeatOppositeDirection",
}
+M.DEFAULT_MAPPING_MODES = { "n", "x", "o" }
+M.DEFAULT_MAPPINGS = {
+ { lhs = "f", action = "StartFindForward" },
+ { lhs = "F", action = "StartFindBackward" },
+ { lhs = "t", action = "StartTillForward" },
+ { lhs = "T", action = "StartTillBackward" },
+}
local ACTION_INVOCATIONS = {
StartFindForward = function(facade)
@@ -124,6 +131,22 @@ local function register_logical_actions(record)
return registrations
end
+local function register_default_mappings(record, setup)
+ local registrations = {}
+ if not setup.install_default_mappings then
+ return registrations
+ end
+ for _, mapping in ipairs(M.DEFAULT_MAPPINGS) do
+ registrations[mapping.lhs] = record.host:register_mapping(
+ M.DEFAULT_MAPPING_MODES,
+ mapping.lhs,
+ mapping.action,
+ {}
+ )
+ end
+ return registrations
+end
+
function CompositionRoot:activate()
local record = root_records[self]
if record.activation == nil then
@@ -137,13 +160,15 @@ function CompositionRoot:activate()
end,
{ owner = "clever_f", lifecycle = "colorscheme" }
)
+ local actions = register_logical_actions(record)
record.activation = {
state = record.state,
setup = setup,
feedback = feedback_activation,
highlights = highlights,
colorscheme_registration = colorscheme_registration,
- actions = register_logical_actions(record),
+ actions = actions,
+ mappings = register_default_mappings(record, setup),
}
end
return record.activation