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

@jurjanpaul/codemirror6-clojure-smart-indent

v0.1.1

Published

Clojure Smart Indent extension for CodeMirror 6

Readme

codemirror6-clojure-smart-indent

Clojure Smart Indentation extension for CodeMirror 6.

The indentation follows the Clojure Styleguide in case the last line of code before the cursor contains any unmatched open or close delimiter character, i.e. (, [, {, }, ] or ). Otherwise, the current (custom) indentation is followed. Comments are skipped and no smart indentation is applied within strings.

For simplicity's sake no distinction is made between the different types of open and closing delimiters. (A form of structural editing is assumed - tested with Parinfer - that forces each open delimiter to be properly closed with a matching closing delimiter.) The use of tab characters is not supported: they are counted as single spaces.

Usage

This package provides a CodeMirror 6 extension for smart Clojure indentation.

import { EditorState } from "@codemirror/state";
import { EditorView } from "@codemirror/view";
import { clojure } from "@nextjournal/lang-clojure";
import { indentService } from "@codemirror/language";
import { clojureSmartIndentExtension } from "@jurjanpaul/codemirror6-clojure-smart-indent";

new EditorView({
  state: EditorState.create({
    doc: "(defn foo [bar]\n  (println bar))",
    extensions: [
      clojure(),
      clojureSmartIndentExtension(indentService)
    ],
  }),
  parent: document.getElementById("editor")
});

Note the need to pass in the indentService (to prevent ending up with separate instances).

Demo

A demo editor is provided in demo/index.html. (Run npm run build first.)

Alternatively, see it in action in the Away from Preferred Editor ClojureScript Playground or in the demo page for codemirror6-parinfer.

Motivation

After upgrading Away from Preferred Editor ClojureScript Playground from CodeMirror 5 to CodeMirror 6 (and making Parinfer work), it became clear that the de facto standard Clojure language extension by Nextjournal did not provide Smart Indentation the way the original Clojure mode had. With a fork I got it to somewhat work, but given the fact that these days a number of competing indentation styles are in use within the Clojure community it always seemed better to make this into its own extension.

Future

Nothing planned, but if the need arises I can imagine adding an option that allows specifying custom 'body form' symbols.

Approach

Indentation is determined by scanning characters in the text before the cursor.

Originally, I hoped to be able to take advantage of the existing Clojure Lezer parser. This worked quite well in a fork of @nextjournal/lang-clojure, but I wanted this to be a separate extension and in that context using the existing parser and syntax tree to determine smart indentation proved a lot more involved than I expected. Perhaps I will revisit the approach at some point.