@exercism/codemirror-lang-clojure 0.0.0-stage → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md ADDED
@@ -0,0 +1,34 @@
1
+ ## 1.0.1
2
+
3
+ The README is restructured. This release is the first published from GitHub Actions, with npm provenance.
4
+
5
+ # Changelog
6
+
7
+ ## 1.0.0
8
+
9
+ This is Exercism's first release of the package, published as
10
+ `@exercism/codemirror-lang-clojure`. It adds CodeMirror support with
11
+ highlighting, indentation, folding and completion, and grammar nodes for the
12
+ names bound by forms such as `defn`, `let` and `fn`.
13
+
14
+ ## 1.0.0-rc.2 (2022-07-06)
15
+ * Add namespace forms
16
+
17
+ ## 1.0.0-rc.1 (2022-07-05)
18
+ * Reintroduce constructor call Syntax
19
+ * Refine allowed Reader Tags
20
+ * Make skip-next-form play well with prefixed expressions
21
+
22
+ ## 1.0.0-rc.0 (2022-06-30)
23
+ * Upgrade to Lezer parser to v1.0.0
24
+ * Remove constructor call syntax
25
+ * Improve char detection (#17)
26
+
27
+ ## 0.1.10 (2020-12-07)
28
+ * Upgrade Lezer to v0.13
29
+ * Extend grammar to include more #-prefixed expressions (#5)
30
+ * Deflike expressions with metadata
31
+ * Operator for first element in a list
32
+
33
+ ## 0.1.0 (2020-10-20)
34
+ * First release
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2022 Nextjournal GmbH.
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any purpose
4
+ with or without fee is hereby granted, provided that the above copyright notice
5
+ and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
9
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
11
+ OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
12
+ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
13
+ THIS SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,82 @@
1
- # Temporary Holding Version
1
+ # @nextjournal/lezer-clojure [![NPM version](https://img.shields.io/npm/v/@nextjournal/lezer-clojure.svg)](https://www.npmjs.com/package/@nextjournal/lezer-clojure)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ ## Exercism's fork
4
+
5
+ This is Exercism's fork of [nextjournal/lezer-clojure](https://github.com/nextjournal/lezer-clojure), by Martin Kavalar and Andrea Amantini at Nextjournal.
6
+ Exercism uses it in the Clojure editor on [exercism.org](https://exercism.org).
7
+ It is published on npm as `@exercism/codemirror-lang-clojure`.
8
+ Our changes are on the `exercism` branch, and the `main` branch follows upstream.
9
+ Below this section, the README is upstream's.
10
+
11
+ The fork turns the grammar into a full CodeMirror 6 language package, with highlighting, indentation, folding and autocompletion.
12
+ The highlighting and indentation come from [nextjournal/lang-clojure](https://github.com/nextjournal/lang-clojure) by Andrea Amantini.
13
+ Both projects are licensed under the ISC licence, and so is this fork.
14
+
15
+ The grammar has nodes for the names bound by a form, so the editor can highlight them and offer them as completions:
16
+
17
+ - `defn`, `defn-`, `defmacro` and `definline` have their parameters marked, including each arity of a multi-arity function.
18
+ - `let`, `loop`, `for`, `doseq`, `when-let`, `if-let` and the other binding macros have their bindings marked, including `:let` inside `for` and `doseq`.
19
+ - `fn` has its name and parameters marked, `letfn` its functions, `catch` its exception, and `defrecord` and `deftype` their fields.
20
+ - Destructuring works in all of these, for example `[{:keys [a b] :as m} & more]`.
21
+ - Special forms and the core macros (`if`, `when`, `cond`, `->` and so on) are highlighted as keywords when they start a list. Other symbols that start a list are highlighted as function calls.
22
+
23
+ If a form does not have the shape expected by the grammar (for example while it is still being typed), it parses as a plain list.
24
+
25
+ The completion offers:
26
+
27
+ - special forms, and the public functions, macros and vars of `clojure.core`.
28
+ - snippets for `defn`, `fn`, `let`, `if`, `when`, `cond`, `case`, `loop`, `doseq`, `for`, `ns`, `defrecord`, `defprotocol`, `defmulti`, `defmethod`, `try` and the threading macros. If the word follows an open paren, the snippet goes inside that paren. Otherwise the snippet includes its own parens.
29
+ - the names defined with `def`, `defn` and the like anywhere in the file, and the `->Name` and `map->Name` constructors of each record.
30
+ - local names (bindings and parameters) inside the form that binds them, once they are bound.
31
+ - `clojure.string` and `clojure.set` functions, both with the full namespace (`clojure.string/join`) and with the alias given in the `ns` form (`str/join`).
32
+
33
+ It offers nothing inside strings, comments, keywords or numbers, or while a new name is being typed.
34
+
35
+ The lists in `src/builtins.js` come from the public vars of Clojure 1.12.7.
36
+
37
+ ### Install and use
38
+
39
+ To install it, run:
40
+
41
+ ```sh
42
+ npm install @exercism/codemirror-lang-clojure
43
+ ```
44
+
45
+ Then add `clojure()` to the editor's extensions:
46
+
47
+ ```js
48
+ import {EditorView, basicSetup} from "codemirror"
49
+ import {clojure} from "@exercism/codemirror-lang-clojure"
50
+
51
+ new EditorView({
52
+ doc: "(defn hello [name]\n (str \"Hello, \" name))",
53
+ extensions: [basicSetup, clojure()],
54
+ parent: document.body
55
+ })
56
+ ```
57
+
58
+ The package also exports `parser` (the Lezer parser), `clojureLanguage`, the two completion sources (`localCompletionSource` and `builtinCompletionSource`) and the lists of `builtins`.
59
+
60
+ ### Building and testing
61
+
62
+ Run `npm install`, then `npm run build` to build the parser and the package, and `npm test` to run the tests. The grammar tests are in `test/*.txt`, and the completion and language tests are in `test/test-completion.js` and `test/test-language.js`.
63
+
64
+ ### Contributing
65
+
66
+ Contributions to this fork follow the Exercism [Code of Conduct](https://exercism.org/docs/using/legal/code-of-conduct).
67
+ Please read about how to [contribute to Exercism](https://exercism.org/docs/building).
68
+
69
+ ---
70
+
71
+ This is a Clojure grammar for the
72
+ [lezer](https://lezer.codemirror.net/) parser system.
73
+
74
+ The code is licensed under an ISC license.
75
+
76
+ # Dev
77
+
78
+ To watch & test, with [entr](http://eradman.com/entrproject/) installed run `npm run watch`
79
+
80
+ # Previous Package Name
81
+
82
+ This package has been previously released (unscoped) as [lezer-clojure](https://www.npmjs.com/package/lezer-clojure).