Implementation:2giosangmitom Sqmeow nvim project parse
| Knowledge Sources | |
|---|---|
| Domains | Configuration, Connection_Management |
| Last Updated | 2026-10-16 14:00 GMT |
Overview
Concrete tool for parsing project-local TOML connection definitions into a MessagePack map provided by the sqmeow-core engine.
Description
The project::parse function converts named TOML connection tables from a project's connections.toml file into a MessagePack map of scalar fields. Lua locates and reads the file, then sends its raw contents through the project_connections RPC method. This function validates TOML syntax and the flat connection table shape, rejects shell exec directives, and preserves type information (strings, integers, booleans) across RPC so Lua can distinguish a port from a string.
No filesystem, environment, shell, or database access occurs during parsing. Parsing is all-or-nothing: syntax errors identify the line number without including the source line, which may contain credentials.
Usage
Import this function when you need to decode project-local connection definitions sent from the Neovim plugin before secret expansion or adapter selection.
Code Reference
Source Location
- Repository: sqmeow.nvim
- File: core/sqmeow-core/src/server/project.rs
- Lines: L21-67
Signature
pub(super) fn parse(contents: &str) -> Result<Value, String>
Import
// Called via Core::answer dispatch in mod.rs:
"project_connections" => project::parse(&args.string("contents")?),
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| contents | &str | Yes | Raw TOML text of connections.toml read by Lua |
Outputs
| Name | Type | Description |
|---|---|---|
| Ok | rmpv::Value::Map | Map of connection name → scalar field map (strings, integers, booleans) |
| Err | String | Error message identifying the TOML line without source content |
Usage Examples
Parsing a connections.toml
// Lua reads the file and sends contents through RPC:
// TOML input:
// [dev]
// url = "postgres://app@localhost/dev"
// port = 5432
// read_only = true
let result = project::parse(contents)?;
// Returns Value::Map with:
// "dev" => { "url" => "postgres://app@localhost/dev",
// "port" => 5432 (integer),
// "read_only" => true (boolean) }
Rejecting exec directives
// Project connections must not contain exec directives:
let contents = r#"
[prod]
url = "{{ exec "pass show db/prod" }}"
"#;
assert!(project::parse(contents).is_err());
// Error: "exec directives are not allowed in project connections"
Related Pages
Implements Principle
Requires Environment
- (None — pure parsing, no I/O)