npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@treelsp/cli

v0.0.4

Published

CLI tool for treelsp - LSP generator using Tree-sitter

Downloads

396

Readme

@treelsp/cli

CLI tool for treelsp — generate parsers and language servers from TypeScript grammar definitions. Supports Tree-sitter and Lezer backends.

Installation

npm install -D @treelsp/cli
# or
pnpm add -D @treelsp/cli

Commands

treelsp init

Scaffold a new language project interactively.

treelsp init

Prompts for a language name, file extension, and parser backend (Tree-sitter or Lezer), then creates a pnpm monorepo with two packages:

  • packages/language/ — grammar definition (grammar.ts) and generated files
  • packages/extension/ — VS Code extension that launches the language server

Also generates root config files (treelsp-config.json, pnpm-workspace.yaml, .vscode/launch.json).

treelsp generate

Generate grammar files, AST types, manifest, and syntax highlighting queries from a language definition.

Usage: treelsp generate [options]

Options:
  -f, --file <file>  path to treelsp-config.json or package.json with treelsp field
  -w, --watch        watch for changes

Output files depend on the backend:

Tree-sitter (default, written to generated/):

  • grammar.js — Tree-sitter grammar (CommonJS)
  • ast.ts — typed AST interfaces
  • treelsp.json — manifest for VS Code extension discovery
  • syntax.tmLanguage.json — TextMate grammar
  • queries/highlights.scm — Tree-sitter syntax highlighting
  • queries/locals.scm — Tree-sitter scope/locals

Lezer (written to generated-lezer/ or custom out path):

  • grammar.lezer — Lezer grammar specification
  • parser-meta.json — field/node metadata
  • ast.ts — typed AST interfaces
  • treelsp.json — manifest for VS Code extension discovery
  • syntax.tmLanguage.json — TextMate grammar

treelsp build

Compile the generated grammar and bundle the language server.

Usage: treelsp build [options]

Options:
  -f, --file <file>  path to treelsp-config.json or package.json with treelsp field

Tree-sitter backend requires the tree-sitter CLI (npm install -g tree-sitter-cli or cargo install tree-sitter-cli).

Lezer backend requires no external tools (pure JavaScript compilation).

Output files:

Tree-sitter:

  • grammar.wasm — compiled WebAssembly parser
  • server.bundle.cjs — self-contained language server bundle
  • tree-sitter.wasm — web-tree-sitter runtime

Lezer:

  • parser.js — compiled Lezer parser
  • parser.bundle.js — self-contained parser bundle (includes @lezer/lr)
  • server.bundle.cjs — self-contained language server bundle

treelsp watch

Watch mode — re-runs generate + build automatically when grammar files change.

Usage: treelsp watch [options]

Options:
  -f, --file <file>  path to treelsp-config.json or package.json with treelsp field

Configuration

By default, treelsp looks for grammar.ts in the current directory and outputs to generated/ using the Tree-sitter backend. For multi-language or multi-backend projects, create a config file.

Config discovery order

When -f is not provided, the CLI searches from the current directory upward for:

  1. treelsp-config.json
  2. A "treelsp" field in package.json
  3. Falls back to legacy mode (grammar.ts in cwd)

treelsp-config.json

{
  "languages": [
    { "grammar": "packages/language/grammar.ts" },
    { "grammar": "packages/language/grammar.ts", "backend": "lezer", "out": "packages/language/generated-lezer" }
  ]
}

package.json

{
  "treelsp": {
    "languages": [
      { "grammar": "src/grammar.ts", "out": "src/generated" }
    ]
  }
}

Schema

| Field | Type | Required | Description | |-------|------|----------|-------------| | languages | array | yes | List of language projects | | languages[].grammar | string | yes | Path to grammar.ts, relative to the config file | | languages[].out | string | no | Output directory (default: <grammar dir>/generated) | | languages[].backend | string | no | Parser backend: "tree-sitter" (default) or "lezer" |

Typical Workflow

New project:

treelsp init           # scaffold project with language + extension packages
cd my-lang
pnpm install
pnpm build             # generate + compile + bundle
# Press F5 in VS Code to launch the extension

Generate for both backends:

{
  "languages": [
    { "grammar": "packages/language/grammar.ts" },
    { "grammar": "packages/language/grammar.ts", "backend": "lezer", "out": "packages/language/generated-lezer" }
  ]
}
treelsp generate       # generates for all configured backends
treelsp build          # builds all configured backends
treelsp watch          # watches all grammar files