Awesome
Clojure/Script mode for CodeMirror 6
Enabling a decent Clojure/Script editor experience in the browser. Built for and by Nextjournal.
โจ Features
โก๏ธ Lightning-fast thanks to lezer incremental parsing
- Try pasting
clojure/core.clj
into the live demo.
๐ฅค Slurping & ๐คฎ Barfing
- Forward: <kbd>Ctrl</kbd> + <kbd>โ</kbd> / <kbd>โ</kbd> or <kbd>Mod</kbd> + <kbd>โง</kbd> + <kbd>J</kbd> / <kbd>K</kbd>
- Backward: <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>โ</kbd> / <kbd>โ</kbd>
๐ Semantic Selections
- Expand/Contract: <kbd>Alt</kbd> + <kbd>โ</kbd> / <kbd>โ</kbd> or <kbd>Mod</kbd> + <kbd>1</kbd> / <kbd>2</kbd>
๐ง Prepared for evaluation
- At Cursor: <kbd>Mod</kbd> + <kbd>โ</kbd>
- Top-level form: <kbd>Mod</kbd> + <kbd>โง</kbd> + <kbd>โ</kbd>
- Cell: <kbd>Alt</kbd> + <kbd>โ</kbd>
๐งน Autoformatting following Tonskyโs Better Clojure Formatting
๐น And lots of more useful key bindings
๐ฆ Use it in your project
Include it in your deps.edn
{:deps {io.github.nextjournal/clojure-mode {:git/sha "<SHA>"}}}
Use it from NPM
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 for more information.