Principle:2giosangmitom Sqmeow nvim Event Emission
| Knowledge Sources | |
|---|---|
| Domains | RPC, Event_Emission |
| Last Updated | 2026-10-16 14:00 GMT |
Overview
An event notification principle that communicates operation outcomes from the engine to the editor through named events carrying MessagePack payloads, with acceptance replies queued before completion events.
Description
Event Emission is the principle of reporting the outcome of long-running operations (query execution, edit application, view computation, schema introspection, export) through named event notifications sent from the engine to the Neovim editor. Short operations return values directly through the RPC reply; long operations return an acknowledgement first, then emit completion events.
This principle addresses the challenge of keeping the editor informed about async work: the reply names the accepted id, and subsequent events carry that id so the editor can correlate them. Failures after acceptance are reported through events, not RPC errors.
Standard events:
call:state— Query execution lifecycle: "executing", "done", "error", "cancelled".call:view— View computation result: row count, aggregated flag, summary.conn:state— Connection lifecycle: "connecting", "connected", "error".apply:done— Edit application outcome: success or error.schema:nodes— Schema tree level for the drawer.structure:done— Table columns, indexes, and details.export:done— Export outcome: text/path, rows, bytes, or error.
Usage
Use this principle when designing an async RPC system: short operations reply directly; long operations accept then emit. Every event carries the id from the acceptance reply for correlation.
Theoretical Basis
The principle follows the acceptance-before-work notification pattern:
- Acceptance: The RPC reply (e.g.,
Value::from(call_id)) is queued beforetokio::spawnstarts the work. - Events follow: Completion events (e.g.,
call:state) always arrive after the reply, carrying the same id. - Payload structure: Events carry a MessagePack map with standard fields (id, state) plus operation-specific fields (columns, rows, error).
- Error channel: Failures after acceptance are reported through events, not RPC errors. The event payload includes an
errorfield.
# Abstract pattern (NOT real implementation):
def on_request(method, params, reply):
call_id = next_id()
reply.ok(call_id) # acceptance first
spawn(work(call_id)) # events follow
def work(call_id):
result = execute(...)
emit("call:state", {
"call_id": call_id,
"state": "done" if result.ok else "error",
"columns": [...], "rows": result.row_count,
"error": result.error, # only on failure
})
Related Pages
Implemented By
- Implementation:2giosangmitom_Sqmeow_nvim_Core_emit
- Implementation:2giosangmitom_Sqmeow_nvim_summarize