🚀 New Engine and Exit Event System in SmartMotion.nvim #56
FluxxField
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey everyone! I’ve just pushed a major internal refactor to SmartMotion that lays the foundation for powerful new features going forward. This post is a deep dive into what’s changed, why it matters, and where we’re headed next.
🔧 Why Refactor the Old Dispatcher?
Previously, SmartMotion used a module called
dispatcher.lua
to run motions. But over time it became clear that:trigger_motion
andtrigger_action
) doing very similar things.To fix this, I completely overhauled the system and introduced a brand new engine architecture.
🧠 The New Engine Structure
The motion runner is now broken into clean, single-responsibility modules under
lua/smart_motion/engine/
:init.lua
: Entry point for triggering motionssetup.lua
: Gathers and prepares all necessary datainfer.lua
: Handles module inference (e.g. choosing extractor based on input)loop.lua
: Core execution loop that processes generatorspipeline.lua
: Runs the motion’s pipeline of modulesexit.lua
: Handles all exit conditions and behaviorThis structure makes the logic easier to follow, easier to test, and dramatically more flexible for future features.
📦 Exit Events — A Game-Changer
Alongside the engine overhaul, I introduced a new exit event system.
Instead of forcing every layer of the pipeline to manually bubble up an
exit_type
, we now use a declarative event-based exit system.Any part of the engine can now do something like:
This cleanly and instantly exits the motion, regardless of where it’s called from.
🔍 Why this is powerful:
##🔮 The Future of Events
Right now, the system only supports a handful of exit types like:
early_exit
abort
continue_to_selection
But this system was built with extensibility in mind.
Possible future uses:
events.show_message(...)
)Think of this as a low-level event bus for motion lifecycle control.
##🧼 Cleanup & Performance Wins
This refactor also led to:
Motions like "repeat previous", "flow chain", and "dot-repeat" now have a cleaner foundation to build on.
##🗣️ Let’s Discuss
I’d love your feedback on:
Thanks again for trying out SmartMotion and for all the incredible support so far. This plugin has grown way beyond my original idea, and I can’t wait to share what’s coming next.
— Keenan
Beta Was this translation helpful? Give feedback.
All reactions