Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:2giosangmitom Sqmeow nvim Core emit

From Leeroopedia
Knowledge Sources
Domains RPC, Event_Emission
Last Updated 2026-10-16 14:00 GMT

Overview

Concrete tool for sending event notifications from the engine to Neovim through MessagePack RPC provided by the sqmeow-core engine.

Description

The Core::emit method sends a named event with a MessagePack payload to the Neovim instance through the Nvim client. It is the primary mechanism for communicating completion of long operations back to the editor. Short operations return values directly through the RPC reply; long operations return an acknowledgement first, then spawn async work that emits completion events. The reply is queued before the work starts so Lua can record the accepted id before handling its events.

emit_call is a convenience wrapper that builds a standard call:state event payload with call_id, conn_id, state, and extra fields. emit_export builds an export:done event.

Usage

  • Connection lifecycle: Emits conn:state with "connecting", "connected", or "error".
  • Query execution: emit_call emits call:state with "executing", "done", "error", or "cancelled".
  • In-grid editing: Emits apply:done with apply outcome.
  • Local result processing: Emits call:view with view metadata.
  • Result export: emit_export emits export:done.
  • Schema discovery: Emits schema:nodes and structure:done.

Code Reference

Source Location

  • Repository: sqmeow.nvim
  • File: core/sqmeow-core/src/server/mod.rs
  • Lines: L142-146 (emit), calls.rs L807-815 (emit_call), exports.rs L153-160 (emit_export)

Signature

impl Core {
    fn emit(&self, event: &str, payload: Value);

    // In calls.rs:
    fn emit_call(&self, call_id: CallId, conn_id: ConnId, state: &str, extra: Vec<(&str, Value)>);

    // In exports.rs:
    fn emit_export(&self, call_id: CallId, outcome: Result<Vec<(&str, Value)>, String>);
}

Import

// Internal to Core; called from handler modules.

I/O Contract

Inputs

Name Type Required Description
event &str Yes Event name (e.g. "call:state", "conn:state", "apply:done")
payload Value Yes MessagePack map with event data
call_id CallId Yes (emit_call/emit_export) Result id
conn_id ConnId Yes /// (emit_call) Connection id
state &str Yes /// (emit_call) State string

Outputs

Name Type Description
(side effect) () /// Notification sent to Neovim; logged on failure

Usage Examples

Emitting a call state event

self.emit_call(call_id, conn_id, "done", vec![
    ("columns", Value::Array(columns)),
    ("rows", Value::from(row_count)),
    ("elapsed_ms", Value::from(elapsed)),
]);
// Sends: call:state { call_id, conn_id, state: "done", columns, rows, elapsed_ms }

Emitting a custom event

self.emit("schema:nodes", map(vec![
    ("conn_id", Value::from(conn_id)),
    ("path", strings(path)),
    ("nodes", Value::Array(nodes)),
]));

Related Pages

Implements Principle

Requires Environment

Uses Heuristic

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment