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

@kunstmusik/codemirror-lang-csound

v1.0.3

Published

CodeMirror 6 language support for Csound (CSD, ORC, SCO)

Readme

@kunstmusik/codemirror-lang-csound

CodeMirror 6 language support for Csound, covering CSD, ORC, and SCO files.

Features

  • One Lezer-based language package with modes for full .csd, orchestra .orc, and score .sco documents.
  • Syntax highlighting, indentation, folding, and comment support for Csound editing.
  • Opcode autocomplete backed by generated Csound opcode metadata.
  • Semantic highlighting for built-in opcodes, UDOs, p-fields, named instruments, and score fragments.
  • Hover info for built-in opcodes and document-local UDOs.

Install

npm install @kunstmusik/codemirror-lang-csound

Changelog

1.0.3

  • Add a language-only /compat entry for old mode and completion option names. Colors, panels, and evaluation remain in host code.
  • Add generated node names and grammar-owned identifier groups under /syntax, with type tests and stale-artifact checks.
  • Parse Csound 7 declarations, multiline UDO signatures, Unicode names, boolean rates, and array expression indexing.
  • Keep Unicode and multiline UDOs available to completion, hover, and semantic highlighting.
  • Allow hosts to disable the built-in completion source with csound({ completion: false }).
  • Let browser bundlers load the rich help catalog as a separate chunk.
  • Add language-interface tests and a command to scan a Csound test checkout. Build the package automatically before packing it.

1.0.2

  • Fix reading pfields to tokens with lower-case p.

1.0.1

  • Fixed the package exports condition ordering so newer Vite and Rolldown-based builds do not fail on the published package metadata.
  • No runtime API changes. This is a packaging and compatibility release on top of 1.0.0.

1.0.0

  • Initial public release of the Csound CodeMirror 6 language package.
  • Shipped CSD, ORC, and SCO modes with autocomplete, semantic highlighting, hover info, and the rich opcode metadata entrypoint.

Quick Start

import { EditorState } from "@codemirror/state"
import { EditorView } from "@codemirror/view"
import { basicSetup } from "codemirror"
import { csound } from "@kunstmusik/codemirror-lang-csound"

const doc = `<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
instr 1
  a1 oscil 0.2, 440
  out a1
endin
</CsInstruments>
<CsScore>
i1 0 1
e
</CsScore>
</CsoundSynthesizer>`

const state = EditorState.create({
  doc,
  extensions: [
    basicSetup,
    csound({ mode: "csd" }),
  ],
})

new EditorView({
  state,
  parent: document.querySelector("#editor")!,
})

csound() defaults to mode: "csd". It also enables semantic highlighting and hover support by default.

Modes

import { csound } from "@kunstmusik/codemirror-lang-csound"

csound({ mode: "csd" })
csound({ mode: "orc" })
csound({ mode: "sco" })

If you need the bare languages instead of the bundled LanguageSupport, the package also exports csoundCsdLanguage, csoundOrcLanguage, and csoundScoLanguage.

Optional Configuration

csound({
  mode: "orc",
  completion: false,
  semanticHighlighting: false,
  hover: false,
})

Rich Metadata Entry Point

The package exposes a separate rich metadata bundle at @kunstmusik/codemirror-lang-csound/rich for consumers that want direct access to the manual-derived opcode catalog.

import { csoundRichOpcodeCatalog } from "@kunstmusik/codemirror-lang-csound/rich"

Hover support lazy-loads that richer catalog automatically when it needs manual metadata.

V1 Scope

Some ambiguous opcode/assignment lines still fall back to generic-line parsing. Some alternate score-bin dialects remain follow-up work.

Migrating from @hlolli/codemirror-lang-csound

New integrations should use csound({ mode }). A temporary, language-only adapter keeps the old mode and completion option names:

import { csoundMode } from "@kunstmusik/codemirror-lang-csound/compat"

csoundMode({
  fileType: "csd",             // "csd" (default), "orc", or "sco"
  enableCompletion: true,
})

Completion defaults to true. This adapter adds no semantic colors, hover UI, synopsis panel, legacy CSS, or indentation preference. Hosts must supply their own presentation and evaluation behavior. The old enableSynopsis and enableDefaultTheme options do not belong to this adapter.

The /compat entry also exports csdLanguage, orcLanguage, and scoLanguage as aliases for the bare languages. None of these compatibility names appear in the main entry. csound() keeps its existing defaults.

Checked syntax adapters

Use semantic and hover results where possible. Hosts that need syntax-tree access can import the current parser's checked names and groups:

import {
  csoundNodeNames as nodes,
  csoundNodeGroups,
  csoundNodeSet,
  type CsoundNodeName,
} from "@kunstmusik/codemirror-lang-csound/syntax"

const identifiers = csoundNodeSet(csoundNodeGroups.CsoundIdentifier)
const statements = csoundNodeSet([nodes.OrcStatement, nodes.ScoStatement])
identifiers.has(node.name) // Raw Lezer names remain strings.
// csoundNodeSet(["TypedIndentifier"]) // Type error.

The grammar marks identifier tokens with group=CsoundIdentifier. The build derives frozen names, root names, and group members from parser.nodeSet, including @name aliases. Hosts do not need to copy the identifier list. Numeric parser IDs and anonymous/error nodes are not part of this entry.

Highlight, fold, and indent maps in the package check their keys against CsoundNodeName. Semantic and hover code use the same generated names. This catches misspellings and removed names, not changes in tree structure or host evaluation policy; keep integration tests for those.

After editing the grammar, run npm run build:grammar and commit the generated parser and src/syntax-nodes.ts. npm test checks that these files match the grammar before rebuilding, then runs declaration-level tests that must reject invalid names. CI runs the same checks.

Csound corpus tests

npm run test:csound -- /path/to/csound/tests

The scanner also reads CSOUND_TESTS_DIR. It checks .csd, .orc, .sco, and .udo files and exits with an error on unexpected parser recovery. It allows named or explicitly marked error fixtures. This checks editor parsing, not whether Csound can compile or run a file.