langium-cli

CLI for Langium - the language engineering tool

MIT 64 个版本
安装
npm install langium-cli
yarn add langium-cli
pnpm add langium-cli
bun add langium-cli
README

Langium CLI

This package provides a command line interface for Langium.

Usage: langium [options] [command]

Options:

  • -V, --version — output the version number
  • -h, --help — display help for command

Commands:

  • generate [options] — generate code for a Langium grammar
  • help [command] — display help for command

Generating Language Infrastructure

The main purpose of this tool is to generate the infrastructure for a language from its grammar declaration file. This command requires a configuration file langium-config.json.

Usage: langium generate [options]

Options:

  • -f, --file <file> — the configuration file or package.json setting up the generator
  • -w, --watch — enables watch mode
  • -h, --help — display help for command

Configuration

The configuration for the generate command is written into a file named langium-config.json. Alternatively, it can be embedded in the package.json using a property langium.

Schema:

{
    // Name of the language project
    projectName: string
    // Array of language configurations
    languages: {
        // The identifier of your language as used in vscode
        id: string
        // Path to the grammar file
        grammar: string
        // File extensions with leading `.`
        fileExtensions: string[]
        // Enable case-insensitive keywords parsing
        caseInsensitive: boolean
        // Enable generating a TextMate syntax highlighting file
        textMate: {
            // Output path to syntax highlighting file (json)
            out: string
        }
        // Enable generating a monarch syntax highlighting file
        monarch: {
            // Output path to syntax highlighting file (js)
            out: string
        }
        // Enable generating a prism syntax highlighting file
        prism: {
            // Output path to syntax highlighting file (js)
            out: string
        }
        // Enable generating railroad syntax diagram
        railroad: {
            // Output path to syntax diagrams
            out: string
            // Whether to print diagrams all into a single html file or in separate svg files (optional)
            mode: 'html' | 'svg'
        },
        // Enable generating a BNF-style grammar file
        bnf: {
            // Output path to BNF grammar file
            out: string
        },
        // Configure the chevrotain parser for a single language
        chevrotainParserConfig: IParserConfig
    }[]
    // Main output directory for TypeScript code
    out: string
    // Set the file extension for generated local imports (e.g. ".js")
    importExtension: string
    // Options to change grammar validation
    validation: {
        //  Normal to allow inferrred & declared types, or strict to only allow declared types
        types: 'normal' | 'strict'
    }
    // Configure the chevrotain parser for all languages
    chevrotainParserConfig: IParserConfig
}

Example:

{
    "projectName": "DomainModel",
    "languages": [{
        "id": "domain-model",
        "grammar": "src/language-server/domain-model.langium",
        "fileExtensions": [".dmodel"],
        "textMate": {
            "out": "syntaxes/domain-model.tmLanguage.json"
        },
        "railroad": {
            "out": "docs/syntax-diagram.html"
        }
    }],
    "out": "src/language-server/generated",
    "chevrotainParserConfig": {
        "recoveryEnabled": true,
        "nodeLocationTracking": "full",
        "maxLookahead": 3
    }
}
版本列表
4.3.0 2026-06-15
4.3.0-next.a52b426 2026-06-08
4.2.2-next.d9c47299 2026-04-30
4.2.1 2026-04-21
4.2.0 2026-01-27
4.1.0 2025-09-19
4.0.0 2025-07-31
3.5.2 2025-07-01
3.5.1 2025-07-01
3.5.0 2025-04-17
3.5.0-next.936a9d7 2025-07-03
3.5.0-next.91328d6 2025-07-22
3.4.0 2025-02-26
3.4.0-next.89c0a9d 2025-03-28
3.4.0-next.325db9f 2024-12-11
3.4.0-next.325db9e 2024-12-11
3.4.0-next.1409e5d 2024-12-11
3.4.0-next.10c0eb7 2025-03-04
3.3.0 2024-11-18
3.2.0 2024-09-06
3.2.0-next.2191297 2024-07-01
3.2.0-next.bb9f2d3 2024-07-02
3.2.0-next.9134e27 2024-07-02
3.2.0-next.5063a2b 2024-08-29
3.1.1 2024-08-07
3.1.0 2024-06-20
3.1.0-next.cbc5db3 2024-06-11
3.1.0-next.c8e01a2 2024-06-11
3.1.0-next.4bbc180 2024-06-18
3.0.3 2024-04-23
3.0.2 2024-04-22
3.0.1 2024-02-29
3.0.0 2024-02-29
3.0.0-next.e78aeba 2024-02-14
3.0.0-next.cc1a49c 2024-02-27
3.0.0-next.79e4301 2023-12-12
2.1.0 2023-11-02
2.0.1 2023-08-22
2.0.0 2023-08-17
2.0.0-next.a57102f 2023-08-08
2.0.0-next.239179f 2023-07-25
1.3.1 2023-08-21
1.3.0 2023-08-17
1.2.1 2023-06-05
1.2.0 2023-05-02
1.1.0 2023-02-15
1.0.0 2022-12-16
0.6.0-next.62c127c 2022-11-08
0.5.0 2022-10-05
0.5.0-next.f2b3802 2022-06-29
0.5.0-next.f150dbd 2022-09-02
0.5.0-next.52ab085 2022-09-16
0.4.0 2022-06-09
0.3.0 2022-03-17
0.3.0-next.ee4fc4e 2022-03-15
0.3.0-next.5e9d27d 2021-12-16
0.2.0 2021-11-03
0.2.0-next.1f60202 2021-10-18
0.2.0-next.17bdb70 2021-10-18
0.1.0 2021-06-24
0.1.0-next.b687a8a 2021-06-24
0.1.0-next.6f45aec 2021-06-24
0.1.0-next.0e84185 2021-06-24
0.1.0-next.00ebfd9 2021-06-16