rossi-cli 0.1.0

Command-line interface for the Rossi Event-B toolchain
//! Neovim snippet library (LuaSnip `from_vscode`-loadable package).
//!
//! Multi-file: LuaSnip's `from_vscode` loader reads a VS Code-style snippet
//! *package* — a `package.json` whose `contributes.snippets` points at one or
//! more snippet files, each in the VS Code snippet format. We emit both:
//!
//! - `editors/neovim/snippets/package.json` — the contribution manifest.
//! - `editors/neovim/snippets/eventb.json`  — the snippets themselves, in the
//!   exact same VS Code format the VS Code extension ships (rendered by
//!   [`super::snippets_vscode`] so the two never drift).
//!
//! The hand-written Neovim setup loads this directory with
//! `require("luasnip.loaders.from_vscode").lazy_load { paths = { … } }`.

use super::{paths, snippets_vscode};

/// Render the `(relative path, content)` pairs for the Neovim snippet package.
pub fn render() -> Vec<(String, String)> {
    vec![
        (paths::NVIM_SNIPPETS_PACKAGE.to_string(), package_json()),
        (
            paths::NVIM_SNIPPETS_JSON.to_string(),
            snippets_vscode::render(),
        ),
    ]
}

/// The LuaSnip `from_vscode` contribution manifest. Mirrors the relevant
/// fields of a VS Code extension manifest: `contributes.snippets` maps the
/// `eventb` language to the sibling snippet file. Hand-laid (not `serde_json`,
/// whose default `Map` would sort keys alphabetically) for a deterministic,
/// declaration-ordered 2-space layout matching the snippet file.
fn package_json() -> String {
    let body = r#"{
  "name": "eventb-snippets",
  "version": "1.0.0",
  "description": "Event-B snippets for LuaSnip (generated by rossi gen-grammars).",
  "contributes": {
    "snippets": [
      {
        "language": "eventb",
        "path": "./eventb.json"
      }
    ]
  }
}
"#;
    body.to_string()
}