@exercism/codemirror-lang-cpp 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 +72 -0
- package/LICENSE +21 -0
- package/README.md +162 -2
- package/dist/index.cjs +1018 -0
- package/dist/index.d.cts +64 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +1007 -0
- package/package.json +54 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
## 1.0.1
|
|
2
|
+
|
|
3
|
+
The README is restructured. This release is the first published from GitHub Actions, with npm provenance.
|
|
4
|
+
|
|
5
|
+
## 1.0.0
|
|
6
|
+
|
|
7
|
+
This is Exercism's first release of the package, published as
|
|
8
|
+
`@exercism/codemirror-lang-cpp`. It adds completion and snippets through
|
|
9
|
+
`cpp()`, `c()` and the new `objc()`, and uses Exercism's fork of the grammar,
|
|
10
|
+
`@exercism/lezer-cpp`.
|
|
11
|
+
|
|
12
|
+
## 6.0.3 (2025-06-19)
|
|
13
|
+
|
|
14
|
+
### Bug fixes
|
|
15
|
+
|
|
16
|
+
Add a .d.cts file to make TypeScript happy.
|
|
17
|
+
## 6.0.2 (2022-10-24)
|
|
18
|
+
|
|
19
|
+
### Bug fixes
|
|
20
|
+
|
|
21
|
+
Fix (non-)auto indentation in template strings and comments.
|
|
22
|
+
|
|
23
|
+
Allow prefixed strings to be closed by `closeBrackets`.
|
|
24
|
+
|
|
25
|
+
## 6.0.1 (2022-06-17)
|
|
26
|
+
|
|
27
|
+
### Bug fixes
|
|
28
|
+
|
|
29
|
+
Add the appropriate indentation metadata for blocks.
|
|
30
|
+
|
|
31
|
+
## 6.0.0 (2022-06-08)
|
|
32
|
+
|
|
33
|
+
### Breaking changes
|
|
34
|
+
|
|
35
|
+
Update dependencies to 6.0.0
|
|
36
|
+
|
|
37
|
+
## 0.20.0 (2022-04-20)
|
|
38
|
+
|
|
39
|
+
### Breaking changes
|
|
40
|
+
|
|
41
|
+
Update dependencies to 0.20.0
|
|
42
|
+
|
|
43
|
+
## 0.19.1 (2021-08-11)
|
|
44
|
+
|
|
45
|
+
### Bug fixes
|
|
46
|
+
|
|
47
|
+
Fix incorrect versions for @lezer dependencies.
|
|
48
|
+
|
|
49
|
+
## 0.19.0 (2021-08-11)
|
|
50
|
+
|
|
51
|
+
### Breaking changes
|
|
52
|
+
|
|
53
|
+
Update dependencies to 0.19.0
|
|
54
|
+
|
|
55
|
+
## 0.18.0 (2021-03-03)
|
|
56
|
+
|
|
57
|
+
### Breaking changes
|
|
58
|
+
|
|
59
|
+
Update dependencies to 0.18.
|
|
60
|
+
|
|
61
|
+
## 0.17.1 (2021-01-06)
|
|
62
|
+
|
|
63
|
+
### New features
|
|
64
|
+
|
|
65
|
+
The package now also exports a CommonJS module.
|
|
66
|
+
|
|
67
|
+
## 0.17.0 (2020-12-29)
|
|
68
|
+
|
|
69
|
+
### Breaking changes
|
|
70
|
+
|
|
71
|
+
First numbered release.
|
|
72
|
+
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2018-2021 by Marijn Haverbeke <marijn@haverbeke.berlin> and others
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,163 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- NOTE: README.md is generated from src/README.md -->
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# @codemirror/lang-cpp [](https://www.npmjs.org/package/@codemirror/lang-cpp)
|
|
4
|
+
|
|
5
|
+
## Exercism's fork
|
|
6
|
+
|
|
7
|
+
This is Exercism's fork of [@codemirror/lang-cpp](https://code.haverbeke.berlin/codemirror/lang-cpp).
|
|
8
|
+
Exercism uses it in the C, C++ and Objective-C editors on [exercism.org](https://exercism.org).
|
|
9
|
+
It is published on npm as `@exercism/codemirror-lang-cpp`.
|
|
10
|
+
Our changes are on the `exercism` branch, and the `main` branch follows upstream.
|
|
11
|
+
Below this section, the README is upstream's.
|
|
12
|
+
|
|
13
|
+
The fork adds autocomplete to the upstream package. Use `cpp()` for C++
|
|
14
|
+
and `c()` for C. Both use the same parser, `@exercism/lezer-cpp`, and offer different names.
|
|
15
|
+
|
|
16
|
+
- `cpp()` offers C++ keywords, fundamental types and literals, the
|
|
17
|
+
fixed-width integer types, and snippets for `main`, functions, `if`,
|
|
18
|
+
the loops (including range `for`), `switch`, classes, structs,
|
|
19
|
+
`enum class`, namespaces, `try`/`catch`, lambdas, templates,
|
|
20
|
+
`#include`, `#define`, include guards and `#pragma once`. After
|
|
21
|
+
`std::` it offers the common members of the standard library. If the
|
|
22
|
+
file says `using namespace std;`, it offers them without the prefix
|
|
23
|
+
too.
|
|
24
|
+
- `c()` offers C99 keywords and types, `bool`, `true`, `false` and
|
|
25
|
+
`NULL`, the common functions, types and macros of the C standard
|
|
26
|
+
library, and snippets for `main`, functions, `if`, the loops,
|
|
27
|
+
`switch`, structs, `typedef struct`, enums, `#include`, `#define`
|
|
28
|
+
and include guards.
|
|
29
|
+
- Inside `#include <...>`, both offer the standard header names.
|
|
30
|
+
- Both offer the names declared in the file that are in scope at the
|
|
31
|
+
cursor: functions, structs, classes, unions, enums and their
|
|
32
|
+
enumerators, typedefs and `using` aliases, template parameters,
|
|
33
|
+
fields (inside the class), namespaces, macros, parameters, and local,
|
|
34
|
+
loop and catch variables. A local variable is offered only after its
|
|
35
|
+
declaration.
|
|
36
|
+
|
|
37
|
+
`objc()` gives Objective-C support. It uses the parser's `objc`
|
|
38
|
+
dialect, which adds classes, protocols, methods, properties, message
|
|
39
|
+
sends, `@` literals and blocks to C.
|
|
40
|
+
|
|
41
|
+
- It offers C's keywords and library, Objective-C's keywords and types
|
|
42
|
+
(`self`, `nil`, `YES`, `id`, `instancetype`, `BOOL`, `NSInteger` and
|
|
43
|
+
others), and the common Foundation classes, functions and constants.
|
|
44
|
+
- When the word starts with `@`, it offers the `@` directives, with
|
|
45
|
+
snippets for `@interface`, `@implementation`, `@protocol`,
|
|
46
|
+
`@property`, `@try`/`@catch`, `@autoreleasepool`, `@selector` and the
|
|
47
|
+
array and dictionary literals.
|
|
48
|
+
- Its other snippets cover C's constructs, `#import`, `for ... in`,
|
|
49
|
+
instance and class methods, `init`, `NS_ENUM` and blocks.
|
|
50
|
+
- Where a message names its method, as in `[list add|`, it offers the
|
|
51
|
+
common Foundation selectors and the selectors of the methods declared
|
|
52
|
+
in the file. Completing `setObject:forKey:` inserts `setObject:`.
|
|
53
|
+
- It offers the names declared in the file where they are in scope:
|
|
54
|
+
classes, protocols, `NS_ENUM` types and their values, properties and
|
|
55
|
+
their `_name` instance variables, instance variables, C functions and
|
|
56
|
+
variables, `for ... in` loop variables, and the parameters of methods,
|
|
57
|
+
blocks and functions.
|
|
58
|
+
- Inside `#import <...>`, it offers `Foundation/Foundation.h` and the C
|
|
59
|
+
headers.
|
|
60
|
+
|
|
61
|
+
Completion stays quiet in strings and comments, and after `.`, `->`
|
|
62
|
+
or `::` (apart from `std::`).
|
|
63
|
+
|
|
64
|
+
### Install
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
npm install @exercism/codemirror-lang-cpp
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Building and testing
|
|
71
|
+
|
|
72
|
+
To build and test it from a checkout, run `npm install` (which also builds the package), then `npm test`.
|
|
73
|
+
|
|
74
|
+
### Contributing
|
|
75
|
+
|
|
76
|
+
Contributions to this fork follow the Exercism [Code of Conduct](https://exercism.org/docs/using/legal/code-of-conduct).
|
|
77
|
+
Please read about how to [contribute to Exercism](https://exercism.org/docs/building).
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
[ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://code.haverbeke.berlin/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/c/next/) | [**CHANGELOG**](https://code.haverbeke.berlin/codemirror/lang-cpp/src/branch/main/CHANGELOG.md) ]
|
|
82
|
+
|
|
83
|
+
This package implements C++ language support for the
|
|
84
|
+
[CodeMirror](https://codemirror.net/) code editor.
|
|
85
|
+
|
|
86
|
+
The [project page](https://codemirror.net/) has more information, a
|
|
87
|
+
number of [examples](https://codemirror.net/examples/) and the
|
|
88
|
+
[documentation](https://codemirror.net/docs/).
|
|
89
|
+
|
|
90
|
+
This code is released under an
|
|
91
|
+
[MIT license](https://code.haverbeke.berlin/codemirror/lang-cpp/tree/main/LICENSE).
|
|
92
|
+
|
|
93
|
+
We aim to be an inclusive, welcoming community. To make that explicit,
|
|
94
|
+
we have a [code of
|
|
95
|
+
conduct](http://contributor-covenant.org/version/1/1/0/) that applies
|
|
96
|
+
to communication around the project.
|
|
97
|
+
|
|
98
|
+
## Usage
|
|
99
|
+
|
|
100
|
+
```javascript
|
|
101
|
+
import {EditorView, basicSetup} from "codemirror"
|
|
102
|
+
import {cpp} from "@exercism/codemirror-lang-cpp"
|
|
103
|
+
|
|
104
|
+
const view = new EditorView({
|
|
105
|
+
parent: document.body,
|
|
106
|
+
doc: `for (int i = 0; i < 1024; i++)\n cout << elt[i] << "\\n";`,
|
|
107
|
+
extensions: [basicSetup, cpp()]
|
|
108
|
+
})
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## API Reference
|
|
112
|
+
|
|
113
|
+
<dl>
|
|
114
|
+
<dt id="user-content-cpp">
|
|
115
|
+
<code><strong><a href="#user-content-cpp">cpp</a></strong>() → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
|
|
116
|
+
|
|
117
|
+
<dd><p>Language support for C++. Includes snippet, keyword, standard library and
|
|
118
|
+
local name completion.</p>
|
|
119
|
+
</dd>
|
|
120
|
+
<dt id="user-content-c">
|
|
121
|
+
<code><strong><a href="#user-content-c">c</a></strong>() → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
|
|
122
|
+
|
|
123
|
+
<dd><p>Language support for C. It uses the C++ parser, which also parses
|
|
124
|
+
C, and completes C's keywords, standard library and snippets along with local names.</p>
|
|
125
|
+
</dd>
|
|
126
|
+
<dt id="user-content-objc">
|
|
127
|
+
<code><strong><a href="#user-content-objc">objc</a></strong>() → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
|
|
128
|
+
|
|
129
|
+
<dd><p>Language support for Objective-C. Includes C's keywords and
|
|
130
|
+
library, the Objective-C keywords, types and <code>@</code> directives, the
|
|
131
|
+
common Foundation classes, functions and methods, snippets, and local names.</p>
|
|
132
|
+
</dd>
|
|
133
|
+
<dt id="user-content-cpplanguage">
|
|
134
|
+
<code><strong><a href="#user-content-cpplanguage">cppLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
|
|
135
|
+
|
|
136
|
+
<dd><p>A language provider based on the <a href="https://code.haverbeke.berlin/lezer/cpp">Lezer C++
|
|
137
|
+
parser</a>, extended with
|
|
138
|
+
highlighting and indentation information.</p>
|
|
139
|
+
</dd>
|
|
140
|
+
<dt id="user-content-objclanguage">
|
|
141
|
+
<code><strong><a href="#user-content-objclanguage">objcLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
|
|
142
|
+
|
|
143
|
+
<dd><p>A language provider for Objective-C, using the parser's <code>objc</code>
|
|
144
|
+
dialect.</p>
|
|
145
|
+
</dd>
|
|
146
|
+
<dt id="user-content-cppsnippets">
|
|
147
|
+
<code><strong><a href="#user-content-cppsnippets">cppSnippets</a></strong>: readonly <a href="https://codemirror.net/docs/ref#autocomplete.Completion">Completion</a>[]</code></dt>
|
|
148
|
+
|
|
149
|
+
<dd><p>A collection of C++-related snippets.</p>
|
|
150
|
+
</dd>
|
|
151
|
+
<dt id="user-content-csnippets">
|
|
152
|
+
<code><strong><a href="#user-content-csnippets">cSnippets</a></strong>: readonly <a href="https://codemirror.net/docs/ref#autocomplete.Completion">Completion</a>[]</code></dt>
|
|
153
|
+
|
|
154
|
+
<dd><p>A collection of C-related snippets.</p>
|
|
155
|
+
</dd>
|
|
156
|
+
<dt id="user-content-localcompletionsource">
|
|
157
|
+
<code><strong><a href="#user-content-localcompletionsource">localCompletionSource</a></strong>: <a href="https://codemirror.net/docs/ref#autocomplete.CompletionSource">CompletionSource</a></code></dt>
|
|
158
|
+
|
|
159
|
+
<dd><p>Completion source that looks up the names declared in the file
|
|
160
|
+
(functions, types, variables, parameters, fields and macros), and
|
|
161
|
+
offers each one where it is in scope.</p>
|
|
162
|
+
</dd>
|
|
163
|
+
</dl>
|