Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nextjournal/clojure-mode

Clojure/Script mode for CodeMirror 6
https://github.com/nextjournal/clojure-mode

clojure clojurescript codemirror codemirror-editor codemirror6 lezer lezer-grammar

Last synced: 7 days ago
JSON representation

Clojure/Script mode for CodeMirror 6

Awesome Lists containing this project

README

        

# Clojure/Script mode for [CodeMirror 6](https://codemirror.net/6/)

Enabling a decent Clojure/Script editor experience in the browser. Built for and by [Nextjournal](https://nextjournal.com/).

* **[๐Ÿคนโ€โ™€๏ธ Live demo with in-browser eval](https://nextjournal.github.io/clojure-mode/)**
* [๐Ÿข Try it in Nextjournal](https://nextjournal.com/try/clojure?cm6=1)
* [๐Ÿ“ฆ Use it in your project](#-use-it-in-your-project)

## โœจ Features

**โšก๏ธ Lightning-fast thanks to [lezer incremental parsing](https://lezer.codemirror.net/)**
* Try pasting [`clojure/core.clj`](https://raw.githubusercontent.com/clojure/clojure/master/src/clj/clojure/core.clj) into the [live demo](https://nextjournal.github.io/clojure-mode/).

**๐Ÿฅค Slurping & ๐Ÿคฎ Barfing**
* Forward: Ctrl + โ† / โ†’ or Mod + โ‡ง + J / K
* Backward: Ctrl + Alt + โ† / โ†’

**๐Ÿ’— Semantic Selections**
* Expand/Contract: Alt + โ†‘ / โ†“ or Mod + 1 / 2

๐Ÿง™ **Prepared for evaluation**
* At Cursor: Mod + โŽ
* Top-level form: Mod + โ‡ง + โŽ
* Cell: Alt + โŽ

**๐Ÿงน Autoformatting** following [Tonskyโ€™s Better Clojure Formatting](https://tonsky.me/blog/clojurefmt/)

๐ŸŽน **And lots of more useful [key bindings](https://nextjournal.github.io/clojure-mode/#keybindings)**

## ๐Ÿ“ฆ Use it in your project

### Include it in your `deps.edn`

```clojure
{:deps {io.github.nextjournal/clojure-mode {:git/sha ""}}}
```

### Use it from [NPM](https://www.npmjs.com/package/@nextjournal/clojure-mode)

```js
import { default_extensions, complete_keymap } from '@nextjournal/clojure-mode';
import { EditorView, drawSelection, keymap } from '@codemirror/view';
import { EditorState } from '@codemirror/state';

let extensions = [keymap.of(complete_keymap),
...default_extensions
];

let state = EditorState.create({doc: "... some clojure code...",
extensions: extensions });
let editorElt = document.querySelector('#editor');
let editor = new EditorView({state: state,
parent: editorElt,
extensions: extensions });
```

## ๐Ÿ›  Development Setup

* Install JS dependencies: `yarn install`
* Start dev server: `yarn watch`
* Open the demo page at http://localhost:8002/

## โš–๏ธ License

Licensed under the EPL License, Copyright ยฉ 2020-present Nextjournal GmbH.

See [LICENSE](https://github.com/nextjournal/clojure-mode/blob/master/LICENSE) for more information.