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

@herb-tools/language-service

v0.10.1

Published

HTML+ERB language service built on the Herb parser, providing a compatible API with vscode-html-languageservice

Readme

Herb Language Service

Package: @herb-tools/language-service


HTML+ERB language service built on the Herb parser, providing a compatible API with vscode-html-languageservice but with full HTML+ERB template understanding, including ActionView tag helpers.

::: tip This package is intended for tooling developers building language servers, editor extensions, or other developer tools on top of Herb. If you're looking to use Herb in your editor, see the Herb Language Server instead. :::

Installation

:::code-group

npm add @herb-tools/language-service
pnpm add @herb-tools/language-service
yarn add @herb-tools/language-service
bun add @herb-tools/language-service

:::

Features

  • Drop-in replacement for vscode-html-languageservice with the same API
  • Parses HTML+ERB using the Herb parser instead of a plain HTML scanner
  • ActionView tag helpers like <%= tag.div data: { controller: "scroll" } %> are treated as <div data-controller="scroll"> for completions and diagnostics
  • Extensible via IHTMLDataProvider for framework-specific attributes and values
  • Token list support for space-separated attributes (class, data-controller, etc.)
  • Falls back to the upstream HTML parser when Herb is not available

Migrating from vscode-html-languageservice

- import { getLanguageService } from "vscode-html-languageservice"
+ import { Herb } from "@herb-tools/node-wasm"
+ import { getLanguageService } from "@herb-tools/language-service"

+ await Herb.load()

  const service = getLanguageService({
+   herb: Herb,
    customDataProviders: [myDataProvider],
  })

All types and functions from vscode-html-languageservice are re-exported, so no other import changes are needed.

Usage

Pass a Herb instance to get HTML+ERB support:

import { Herb } from "@herb-tools/node-wasm"
import { getLanguageService } from "@herb-tools/language-service"

await Herb.load()

const service = getLanguageService({
  herb: Herb,
  customDataProviders: [myDataProvider],
})

const document = service.parseHTMLDocument(textDocument)
const completions = service.doComplete(textDocument, position, document)

Without Herb (HTML-only)

When no Herb instance is provided, the service falls back to the upstream vscode-html-languageservice parser:

import { getLanguageService } from "@herb-tools/language-service"

const service = getLanguageService({
  customDataProviders: [myDataProvider],
})

Custom Data Providers

Custom data providers let you add framework-specific tags, attributes, and values to the completion and hover engines. The interface is the same IHTMLDataProvider from vscode-html-languageservice:

import { getLanguageService, type IHTMLDataProvider } from "@herb-tools/language-service"

const stimulusProvider: IHTMLDataProvider = {
  getId: () => "stimulus",
  isApplicable: () => true,

  provideTags: () => [],

  provideAttributes: (tag) => [
    { name: "data-controller" },
    { name: "data-action" },
  ],

  provideValues: (tag, attribute) => {
    if (attribute === "data-controller") {
      return [{ name: "scroll" }, { name: "search" }]
    }

    return []
  },
}

const service = getLanguageService({
  herb: Herb,
  customDataProviders: [stimulusProvider],
  tokenListAttributes: ["data-controller", "data-action"],
})

Multiple providers can be composed. The language service queries all applicable providers and merges their results.

Token List Attributes

Some attributes contain space-separated token lists (e.g., class="foo bar" or data-controller="scroll search"). Pass tokenListAttributes so the language service can provide per-token completions and accurate per-token diagnostic ranges:

const service = getLanguageService({
  herb: Herb,
  tokenListAttributes: ["data-controller", "data-action"],
})

The defaults from @herb-tools/core's TOKEN_LIST_ATTRIBUTES (including class) are always included.

API Compatibility

This package provides the same LanguageService interface as vscode-html-languageservice:

  • parseHTMLDocument(document)
  • doComplete(document, position, htmlDocument)
  • doHover(document, position, htmlDocument)
  • format(document, range, options)
  • findDocumentHighlights(document, position, htmlDocument)
  • findDocumentLinks(document, documentContext)
  • findDocumentSymbols(document, htmlDocument)
  • getFoldingRanges(document, context)
  • getSelectionRanges(document, positions)
  • doRename(document, position, newName, htmlDocument)
  • findMatchingTagPosition(document, position, htmlDocument)
  • findLinkedEditingRanges(document, position, htmlDocument)
  • createScanner(input, initialOffset)
  • setDataProviders(useDefault, providers)
  • setCompletionParticipants(participants)