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 summarize

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

Overview

Concrete tool for describing retained results to the Neovim editor as MessagePack payloads provided by the sqmeow-core engine.

Description

The summarize function produces the metadata the editor needs to describe a result and lay out its columns: column names, type names, classes, null/numeric stats, key flags, editability, row count, SQL text, truncation flag, source table metadata, and affected row counts. It reads the active view (aggregate or row selection) under one lock, then uses the underlying ResultSet for data.

Companion functions:

  • capabilities — Returns a map of {query, memory, filter} capability flags. query requires a live connection (for refresh); memory and filter are always true (local processing on retained rows).
  • cell_value — Encodes a single cell as a MessagePack value (Nil, Bool, Int, Float, or escaped text). NaN and infinities stay as text.
  • page_values — Dispatches native column types once per page (string, i64, f64, bool), falling back to cell_value for Object/binary columns. Only requested rows are formatted, in their original selection order.

Usage

  • Query execution: summarize builds the payload for call:state "done" events.
  • Local result processing: summarize builds the summary inside call:view events; capabilities for result_capabilities.
  • Query execution paging: page_values formats rows for the rows RPC method.

Code Reference

Source Location

  • Repository: sqmeow.nvim
  • File: core/sqmeow-core/src/server/summary.rs
  • Lines: L12-18 (capabilities), L21-51 (cell_value), L55-93 (page_values), L96-175 (summarize)

Signature

pub(super) fn capabilities(connected: bool) -> Value;
pub(super) fn cell_value(result: &ResultSet, row: usize, column: usize) -> Value;
pub(super) fn page_values(result: &ResultSet, chosen: &[usize]) -> Vec<Value>;
pub(super) fn summarize(call: &Call, connected: bool) -> Vec<(&'static str, Value)>;

Import

use super::summary::{capabilities, page_values, summarize};

I/O Contract

Inputs

Name Type Required Description
call &Call Yes /// Retained result with optional view
connected bool Yes /// Whether source connection is still open
result &ResultSet Yes /// (cell_value/page_values) Retained data
row/column usize Yes /// (cell_value) Cell position
chosen &[usize] Yes /// (page_values) Row indices to format

Outputs

Name Type Description
summarize Vec<(&str, Value)> /// MessagePack payload pairs for event
capabilities Value /// Map of {query, memory, filter} flags
page_values Vec<Value> /// Array of row arrays (MessagePack values)

Usage Examples

Summarizing a result for an event

let payload = summarize(&call, true);
// → [("columns", Array[...]), ("call_id", 1), ("conn_id", 1),
//    ("rows", 42), ("sql", "SELECT ..."), ("truncated", false),
//    ("capabilities", {query: true, memory: true, filter: true})]
self.emit_call(call_id, conn_id, "done", payload);

Formatting a page of rows

let rows = page_values(&result, &[0, 1, 2]);
// → [Array[Nil, Int(1)], Array[Text("Alice"), Int(2)], ...]

Related Pages

Implements Principle

Requires Environment

  • (None — reads from in-memory ResultSet)

Page Connections

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