Skip to main content

Module load

Module load 

Source
Expand description

TextMate JSON loader – the format VS Code uses and friendly-snippets ships in. Reading a friendly-snippets pack is a matter of pointing at its JSON files; no conversion or shim code.

Format:

{
    "for loop": {
        "prefix": "for",
        "body": [
            "for ${1:i} in ${2:iter} {",
            "\t$0",
            "}"
        ],
        "description": "for-in loop"
    },
    "impl Display": {
        "prefix": ["impl_display", "displ"],
        "body": ["impl Display for ${1:Ty} { ... }"],
        "description": "implement Display"
    }
}
  • prefix: string OR string array.
  • body: string OR string array (joined with \n).
  • description: optional string.
  • scope: optional string (comma-separated source scopes).

Top-level keys are snippet names (free-form). Unknown fields are ignored – forward-compatible with VS Code’s occasional extensions.

Enums§

LoadError
Snippet load error. Wraps JSON / parse failures so callers can surface a clear “snippet pack X failed” message.

Functions§

load_pack
Parse a friendly-snippets-style JSON pack. Each entry becomes a Snippet; the body is parsed eagerly so the per-keystroke gen:snippet source doesn’t pay re-parse cost.
load_pack_from_str
Convenience: parse a JSON string directly. Most loader call sites read a file then route through here.