@exercism/codemirror-lang-ocaml 1.0.0 → 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 +4 -0
- package/README.md +35 -35
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,50 +1,23 @@
|
|
|
1
1
|
# @exercism/codemirror-lang-ocaml
|
|
2
2
|
|
|
3
|
-
This is Exercism's fork of
|
|
4
|
-
[@codincod/codemirror-lang-ocaml](https://codeberg.org/reeven/codemirror-lang-ocaml),
|
|
5
|
-
written by CodinCod. Exercism uses it in the OCaml editor on
|
|
6
|
-
[exercism.org](https://exercism.org). Our changes are on the `main` branch.
|
|
7
|
-
|
|
8
|
-
The fork adds four things:
|
|
9
|
-
|
|
10
|
-
- The parser puts the function being called into a `Callee` node, so `f` in
|
|
11
|
-
`f x` and `map` in `List.map f xs` are highlighted as function calls.
|
|
12
|
-
- Completion offers the names declared in the file that are in scope at the
|
|
13
|
-
cursor. That covers top-level values and functions, types, constructors,
|
|
14
|
-
record fields, exceptions, modules and `val` declarations, and also
|
|
15
|
-
parameters, the names bound by `let ... in`, and the variables bound by match
|
|
16
|
-
arms, `fun` and `for` loops. Inside a `module ... = struct ... end`, it offers
|
|
17
|
-
that module's own definitions too.
|
|
18
|
-
- Completion offers snippets for `let`, `let rec`, `let ... in`, `match`,
|
|
19
|
-
`function`, `fun`, `if`, `try`, `for`, `while`, variant and record types,
|
|
20
|
-
modules, module types, exceptions and `List.fold_left`. It offers nothing
|
|
21
|
-
inside strings and comments.
|
|
22
|
-
- A definition that runs over several lines folds from the end of its first
|
|
23
|
-
line, and loops and `begin ... end` fold between their keywords.
|
|
24
|
-
|
|
25
|
-
## Install
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
npm install @exercism/codemirror-lang-ocaml
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
The rest of this README is upstream's.
|
|
32
|
-
|
|
33
3
|
This package implements [OCaml](https://ocaml.org/) language support for the
|
|
34
4
|
[CodeMirror](https://codemirror.net/) code editor: a
|
|
35
5
|
[Lezer](https://lezer.codemirror.net/) grammar, highlighting, indentation,
|
|
36
|
-
folding and completion for the standard library.
|
|
6
|
+
folding and completion for the standard library. Exercism uses it in the
|
|
7
|
+
OCaml editor on [exercism.org](https://exercism.org).
|
|
37
8
|
|
|
38
9
|
The grammar is written from scratch. OCaml has never had a Lezer grammar, and
|
|
39
10
|
what a CodeMirror 6 editor could reach for until now was the `mllike` stream
|
|
40
11
|
mode in `@codemirror/legacy-modes`, which reads one keyword list for OCaml,
|
|
41
12
|
F# and Standard ML and has no idea where a definition ends.
|
|
42
13
|
|
|
43
|
-
|
|
44
|
-
|
|
14
|
+
This code is released under an [MIT license](LICENSE).
|
|
15
|
+
|
|
16
|
+
## Install
|
|
45
17
|
|
|
46
|
-
|
|
47
|
-
|
|
18
|
+
```
|
|
19
|
+
npm install @exercism/codemirror-lang-ocaml
|
|
20
|
+
```
|
|
48
21
|
|
|
49
22
|
## Usage
|
|
50
23
|
|
|
@@ -71,6 +44,25 @@ let () =
|
|
|
71
44
|
})
|
|
72
45
|
```
|
|
73
46
|
|
|
47
|
+
## Completion
|
|
48
|
+
|
|
49
|
+
As well as the standard library, completion offers the names declared in the
|
|
50
|
+
file that are in scope at the cursor. That covers top-level values and functions,
|
|
51
|
+
types, constructors, record fields, exceptions, modules and `val`
|
|
52
|
+
declarations, and also parameters, the names bound by `let ... in`, and the
|
|
53
|
+
variables bound by match arms, `fun` and `for` loops. Inside a
|
|
54
|
+
`module ... = struct ... end`, it offers that module's own definitions too.
|
|
55
|
+
|
|
56
|
+
Completion also offers snippets for `let`, `let rec`, `let ... in`, `match`,
|
|
57
|
+
`function`, `fun`, `if`, `try`, `for`, `while`, variant and record types,
|
|
58
|
+
modules, module types, exceptions and `List.fold_left`. It offers nothing
|
|
59
|
+
inside strings and comments.
|
|
60
|
+
|
|
61
|
+
## Folding
|
|
62
|
+
|
|
63
|
+
A definition that runs over several lines folds from the end of its first
|
|
64
|
+
line, and loops and `begin ... end` fold between their keywords.
|
|
65
|
+
|
|
74
66
|
## What it reads
|
|
75
67
|
|
|
76
68
|
Measured against the stream mode it replaces, over 1011 files of OCaml from
|
|
@@ -121,6 +113,9 @@ Four things took most of the work.
|
|
|
121
113
|
|
|
122
114
|
Smaller things worth naming.
|
|
123
115
|
|
|
116
|
+
* **The function being called has its own node.** The parser puts it into a
|
|
117
|
+
`Callee` node, so `f` in `f x` and `map` in `List.map f xs` are highlighted
|
|
118
|
+
as function calls.
|
|
124
119
|
* **Operators are not declared.** `>>=`, `|>` and `+.` are ordinary names in
|
|
125
120
|
OCaml and a library may write its own, so they are classified by their first
|
|
126
121
|
character rather than listed. A leading `!`, `~` or `?` binds tighter than
|
|
@@ -168,3 +163,8 @@ npm install # installs the dependencies and builds the package into dist/
|
|
|
168
163
|
npm run build # regenerates the parser, then rebuilds the package
|
|
169
164
|
npm test # builds the package, then runs the tests
|
|
170
165
|
```
|
|
166
|
+
|
|
167
|
+
## Contributing
|
|
168
|
+
|
|
169
|
+
Please read about how to [contribute to Exercism](https://exercism.org/docs/building).
|
|
170
|
+
Be sure to read the Exercism [Code of Conduct](https://exercism.org/docs/using/legal/code-of-conduct).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exercism/codemirror-lang-ocaml",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "OCaml language support for the CodeMirror code editor",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemirror",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"homepage": "https://github.com/exercism/codemirror-lang-ocaml",
|
|
47
47
|
"repository": {
|
|
48
48
|
"type": "git",
|
|
49
|
-
"url": "https://github.com/exercism/codemirror-lang-ocaml"
|
|
49
|
+
"url": "git+https://github.com/exercism/codemirror-lang-ocaml.git"
|
|
50
50
|
},
|
|
51
51
|
"bugs": {
|
|
52
52
|
"url": "https://github.com/exercism/codemirror-lang-ocaml/issues"
|