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

abcls-kak

v0.1.0

Published

ABC notation editing for Kakoune

Readme

ABC Kakoune Plugin

This plugin integrates ABC notation selectors with Kakoune, enabling AST-level pattern matching as native multi-selections.

Features

  • AST-based selection of ABC musical elements (notes, chords, rests)
  • Selector narrowing and composition
  • Integration with kak-lsp for standard LSP features (diagnostics, completions, hover, formatting)

Installation

  1. Build the bundled LSP server:
cd /path/to/abc_parse
npm install
npm run build:kak

This creates abc-kak/dist/server.js, a self-contained bundle with all dependencies.

  1. Add to your kakrc:
hook -once global WinSetOption filetype=(abc|abcx) %{
    source "/path/to/abc-kak/rc/abc.kak"
}

The plugin auto-configures kak-lsp with the bundled server.

Configuration

To customize options, pre-declare them in your kakrc before the plugin is sourced. Kakoune's declare-option is idempotent, so your values are preserved when the plugin loads.

declare-option str abc_client_path ""       # Path to abc-kak-client.js (auto-detected)
declare-option str abc_server_path ""       # Path to LSP server (auto-detected)
declare-option str abc_socket_path ""       # Unix socket path (auto-computed)
declare-option int abc_timeout 5000         # Request timeout in milliseconds
declare-option bool abc_auto_preview false  # Open browser preview on file open
declare-option str abc_select_key "h"       # Key for select mode (empty to disable)
declare-option str abc_transform_key "k"    # Key for transform mode (empty to disable)

Commands

Type Selectors

  • abc-select-chords: Select all chord nodes
  • abc-select-notes: Select all note nodes
  • abc-select-non-chord-notes: Select notes not inside chords
  • abc-select-chord-notes: Select notes inside chords
  • abc-select-rests: Select all rest nodes

Rhythm Selectors

  • abc-select-rhythm: Select all rhythm expressions (e.g., /2, 3, 3/2)
  • abc-select-rhythm-parent: Select notes, chords, rests, or spacers with explicit rhythm

Structure Selectors

  • abc-select-tune: Select individual tunes (for multi-tune files)

Chord Note Selectors

  • abc-select-top: Select the top note of each chord
  • abc-select-bottom: Select the bottom note of each chord
  • abc-select-nth-from-top N: Select the Nth note from top (0-indexed)
  • abc-select-all-but-top: Select all notes except the top of each chord
  • abc-select-all-but-bottom: Select all notes except the bottom of each chord

State Management

  • abc-select-reset: Clear stored cursor node IDs (breaks narrowing chain)

Selector Narrowing

Selectors can be chained to narrow results:

  1. abc-select-chords - Select all chords
  2. abc-select-top - Narrow to top note of each selected chord
  3. (edit as needed)

The narrowing chain is automatically cleared when:

  • The buffer is modified
  • Selections change (user moves cursor or uses standard Kakoune motions)

Use abc-select-reset to manually clear the narrowing state.

Limitations

  • Selectors only work with .abc files, not .abcx files
  • Requires kak-lsp for full LSP integration
  • The first Kakoune session to open an ABC file owns the socket; closing that session may affect selectors in other sessions

Testing

Tests use Mocha/Chai with a custom KakouneSession helper that runs Kakoune in headless daemon mode.

Running Tests

# From monorepo root
npm test -w abc-kak

# Or from abc-kak directory
npm test

How It Works

Because Kakoune requires a TTY for its UI, we cannot run it directly for automated testing. Instead, we use a headless daemon pattern:

  1. Start a Kakoune daemon: kak -d -s <session>
  2. Send commands via: kak -p <session>
  3. Capture results via a named FIFO (blocking read for synchronization)

The KakouneSession class in test/helpers/kakoune-session.ts wraps this pattern:

import { KakouneSession } from './helpers/kakoune-session';

describe('my test', () => {
  let kak: KakouneSession;
  let testFile: string;

  beforeEach(() => {
    kak = new KakouneSession();
    testFile = `/tmp/test-${kak.session}.abc`;
    kak.start();
  });

  afterEach(() => {
    kak.cleanup();
    unlinkSync(testFile);
  });

  it('selects a note', () => {
    writeFileSync(testFile, 'X:1\nK:C\nCDEF\n');
    kak.edit(testFile);

    // executeAndQuery combines key execution with state query
    // in a single call to preserve selection state
    const selection = kak.executeAndQuery('gg2j', '$kak_selection');

    expect(selection).to.equal('C');
  });
});

Key Methods

  • start() / cleanup() - session lifecycle
  • edit(path) - open a file (sets current buffer context)
  • executeKeys(keys) - run execute-keys in buffer context
  • executeAndQuery(keys, expr) - execute keys and query state in a single call
  • getSelection() / getSelections() / getSelectionsDesc() - query helpers

Legacy kak-spec Tests

The spec/ directory contains older kak-spec tests. To run them:

kak-spec spec/*.kak-spec