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

tree-sitter-spar

v0.1.0

Published

Tree-sitter grammar for the Spar configuration language (.spar files)

Readme

tree-sitter-spar

Tree-sitter grammar for the Spar configuration language.

Tree-sitter is a parser generator that produces fast, incremental, error-tolerant parse trees. Editors that use Tree-sitter for syntax highlighting — Neovim, Helix, Zed, and others — consume grammars like this one to understand the structure of source files.


What this provides

  • Full parse tree for all Spar constructs: variables, sections, imports, functions, expressions, schema declarations
  • Syntax highlighting via queries/highlights.scm
  • Auto-indent rules via queries/indents.scm
  • Scope tracking via queries/locals.scm (used by editors for rename and reference lookup)

Building from source

You need Node.js and the tree-sitter CLI:

npm install -g tree-sitter-cli

Then inside this repo:

npm install
tree-sitter generate   # produces src/parser.c from grammar.js
tree-sitter test       # runs the corpus tests in test/corpus/

The generated src/parser.c is excluded from version control — always build it locally or in CI.


Grammar coverage

The grammar covers the full Spar language as of v0.1:

| Construct | Example | |-----------|---------| | Variable declarations | var port: int = 8080; | | Export / dynamic | export var name: str = "x"; | | Section declarations | [Server] { ... }; | | Private sections | private [Defaults] { ... }; | | Schema sections | [Server]<Schema> { host: str; } | | Imports | import "file.spar" as alias; | | Schema imports | import schema "schema.spar"; | | Spread statements | ...OtherSection; | | Function declarations | function f(x: int) -> str { ... } | | String interpolation | "Hello ${name}!" | | Arithmetic | a + b * c | | Fallback operator | env("KEY") ?? "default" | | Function calls | env("HOST"), str(42) | | List literals | ["a", "b", "c"] | | Block and line comments | /* ... */ and // ... |


Editor integration

Neovim (nvim-treesitter)

Add the grammar to your nvim-treesitter config:

local parser_config = require('nvim-treesitter.parsers').get_parser_configs()

parser_config.spar = {
  install_info = {
    url           = 'https://github.com/oraclevs/tree-sitter-spar',
    files         = { 'src/parser.c' },
    branch        = 'main',
    generate_requires_npm = false,
    requires_generate_from_grammar = false,
  },
  filetype = 'spar',
}

vim.filetype.add({ extension = { spar = 'spar' } })

Then install:

:TSInstall spar

nvim-treesitter integration has not been formally tested by the project — contributions and reports are welcome.

Helix

Helix has built-in Tree-sitter support. To use this grammar before it is merged upstream, add to your languages.toml:

[[grammar]]
name   = "spar"
source = { git = "https://github.com/oraclevs/tree-sitter-spar", rev = "main" }

[[language]]
name          = "spar"
scope         = "source.spar"
file-types    = ["spar"]
roots         = [".git"]
comment-token = "//"
grammar       = "spar"
indent        = { tab-width = 4, unit = "    " }

Then fetch and build:

hx --grammar fetch
hx --grammar build

Helix integration has not been formally tested by the project — contributions and reports are welcome.

Zed

Community grammar support for Zed is possible once tree-sitter-spar is submitted to the zed-industries/extensions registry. This is planned but not yet done.


Relationship to spar and spar-ls

  • This grammar is independent of the spar compiler — it is used for editor display only, not for validation or evaluation.
  • spar-ls provides LSP-based diagnostics, hover, and completions; it runs alongside the Tree-sitter grammar in editors that support both.

License

MIT — see LICENSE.