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

@exercism/codemirror-lang-unison

v1.0.2

Published

Unison language support for CodeMirror

Readme

Unison language support for CodeMirror

NPM Version

This package gives the CodeMirror 6 editor a Lezer grammar for Unison, with highlighting, folding, indentation and autocompletion. Exercism uses it in the in-browser editor for the Unison track.

⚠️ To ensure that the package can be integrated on the Exercism website, don't change the packages' versions:

"@codemirror/language": "^6.10.1",
"@lezer/highlight": "^1.2.0",
"@lezer/lr": "^1.4.0"

Install

  • NPM: npm install @exercism/codemirror-lang-unison
  • Yarn: yarn add @exercism/codemirror-lang-unison
  • Bun: bun add @exercism/codemirror-lang-unison

Usage

import { EditorView, basicSetup } from "codemirror";
import { unison } from "@exercism/codemirror-lang-unison";

new EditorView({
  doc: 'main = do printLine "Hello"',
  extensions: [basicSetup, unison()],
  parent: document.body,
});

What it supports

The grammar reads type signatures and definitions, including namespaced names such as List.map, operator definitions and bindings that take a value apart, such as (a, b) = pair. It reads cases, match ... with (with several patterns and guards), if ... then ... else, lambdas, do, let, handle ... with, delayed computations ('expr) and forcing them (!expr). It also reads use clauses, type declarations with constructors or records, ability declarations, handler patterns such as { ask -> resume }, watches (> expr), tests (test> ...), docs ({{ ... }}) and the --- line that folds away the rest of a file. In types, it reads functions, ability lists such as {IO, Exception}, delayed types such as '{Random} Nat, lists, tuples and forall.

Unison uses indentation to open and close blocks. The tokenizer in src/tokens.ts follows the indentation and tells the grammar where each block opens, where each item starts and where each block ends.

Completion offers:

  • the keywords
  • snippets for functions, cases, match, guards, if, do, let, lambdas, folds, types, records, abilities, handlers, use and tests
  • common functions, types and constructors from base, such as printLine, Optional and Some
  • the common members of List, Text, Nat, Int, Optional, Map, Char and Set after their name and a dot, as in List.
  • the names declared in the file that are in scope at the cursor, such as definitions, types, constructors, ability operations, parameters, pattern variables, lambda arguments and the bindings in blocks
  • a definition's short name as well as its full name. For example, sublist.isSuperlist is offered in full, as isSuperlist on its own, and as isSuperlist after typing sublist.

Completion switches off inside texts, comments and docs.

Credits

The layout tokenizer follows the approach of the PureScript grammar. That grammar is adapted from codemirror-lang-haskell by CodinCod, which is released under the MIT licence.

Prerequisites

Structure

.
├── src
│   ├── index.ts (the language support: highlighting, folding and indentation)
│   ├── complete.ts (the completion sources and snippets)
│   ├── syntax.grammar (the Lezer grammar)
│   ├── tokens.ts (the layout, comment, name and doc tokenizers)
│   └── syntax.grammar*.d.ts (the grammar typings)
├── test
│   ├── cases (grammar test cases)
│   ├── grammar.test.ts (runs the grammar test cases)
│   ├── complete.test.ts (completion tests)
│   └── editor.test.ts (folding, indentation and highlighting tests)
├── index.html (dev server file)
├── rollup.config.js (bundling config)
├── tsconfig.json (TypeScript config)
└── vite.config.js (Vite dev server config)

Setup

Run bun install to install all dependencies.

Developing

Run bun run dev to start a Vite dev server, usually at http://localhost:5173/. It shows index.html, which loads some sample Unison into an editor that uses this package. The page reloads when the grammar changes.

Building

Run bun run prepare to build the package into dist. bun install also runs this script.

Testing

Run bun run test. It builds the package and then runs the tests, because the grammar tests use the built parser. Each file in test/cases holds grammar test cases. Keep each case small and about one feature.

Publishing

To publish a new version, set version in package.json and commit it. Then push a git tag named v followed by that version, such as v1.0.1 for version 1.0.1. The publish workflow builds and tests the package, then publishes it to npm.