@exercism/codemirror-lang-cpp 0.0.0-stage → 1.0.0

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,68 @@
1
+ ## 1.0.0
2
+
3
+ This is Exercism's first release of the package, published as
4
+ `@exercism/codemirror-lang-cpp`. It adds completion and snippets through
5
+ `cpp()`, `c()` and the new `objc()`, and uses Exercism's fork of the grammar,
6
+ `@exercism/lezer-cpp`.
7
+
8
+ ## 6.0.3 (2025-06-19)
9
+
10
+ ### Bug fixes
11
+
12
+ Add a .d.cts file to make TypeScript happy.
13
+ ## 6.0.2 (2022-10-24)
14
+
15
+ ### Bug fixes
16
+
17
+ Fix (non-)auto indentation in template strings and comments.
18
+
19
+ Allow prefixed strings to be closed by `closeBrackets`.
20
+
21
+ ## 6.0.1 (2022-06-17)
22
+
23
+ ### Bug fixes
24
+
25
+ Add the appropriate indentation metadata for blocks.
26
+
27
+ ## 6.0.0 (2022-06-08)
28
+
29
+ ### Breaking changes
30
+
31
+ Update dependencies to 6.0.0
32
+
33
+ ## 0.20.0 (2022-04-20)
34
+
35
+ ### Breaking changes
36
+
37
+ Update dependencies to 0.20.0
38
+
39
+ ## 0.19.1 (2021-08-11)
40
+
41
+ ### Bug fixes
42
+
43
+ Fix incorrect versions for @lezer dependencies.
44
+
45
+ ## 0.19.0 (2021-08-11)
46
+
47
+ ### Breaking changes
48
+
49
+ Update dependencies to 0.19.0
50
+
51
+ ## 0.18.0 (2021-03-03)
52
+
53
+ ### Breaking changes
54
+
55
+ Update dependencies to 0.18.
56
+
57
+ ## 0.17.1 (2021-01-06)
58
+
59
+ ### New features
60
+
61
+ The package now also exports a CommonJS module.
62
+
63
+ ## 0.17.0 (2020-12-29)
64
+
65
+ ### Breaking changes
66
+
67
+ First numbered release.
68
+
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,155 @@
1
- # Temporary Holding Version
1
+ <!-- NOTE: README.md is generated from src/README.md -->
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/codemirror-lang-cpp
4
+
5
+ This is Exercism's fork of
6
+ [@codemirror/lang-cpp](https://code.haverbeke.berlin/codemirror/lang-cpp).
7
+ It powers the C, C++ and Objective-C editors on [exercism.org](https://exercism.org).
8
+ Our changes live on the `exercism` branch. The `main` branch follows upstream.
9
+
10
+ The fork adds autocomplete to the upstream package. Use `cpp()` for C++
11
+ and `c()` for C. Both use the same parser, `@exercism/lezer-cpp`, and offer different names.
12
+
13
+ - `cpp()` offers C++ keywords, fundamental types and literals, the
14
+ fixed-width integer types, and snippets for `main`, functions, `if`,
15
+ the loops (including range `for`), `switch`, classes, structs,
16
+ `enum class`, namespaces, `try`/`catch`, lambdas, templates,
17
+ `#include`, `#define`, include guards and `#pragma once`. After
18
+ `std::` it offers the common members of the standard library. If the
19
+ file says `using namespace std;`, it offers them without the prefix
20
+ too.
21
+ - `c()` offers C99 keywords and types, `bool`, `true`, `false` and
22
+ `NULL`, the common functions, types and macros of the C standard
23
+ library, and snippets for `main`, functions, `if`, the loops,
24
+ `switch`, structs, `typedef struct`, enums, `#include`, `#define`
25
+ and include guards.
26
+ - Inside `#include <...>`, both offer the standard header names.
27
+ - Both offer the names declared in the file that are in scope at the
28
+ cursor: functions, structs, classes, unions, enums and their
29
+ enumerators, typedefs and `using` aliases, template parameters,
30
+ fields (inside the class), namespaces, macros, parameters, and local,
31
+ loop and catch variables. A local variable is offered only after its
32
+ declaration.
33
+
34
+ `objc()` gives Objective-C support. It uses the parser's `objc`
35
+ dialect, which adds classes, protocols, methods, properties, message
36
+ sends, `@` literals and blocks to C.
37
+
38
+ - It offers C's keywords and library, Objective-C's keywords and types
39
+ (`self`, `nil`, `YES`, `id`, `instancetype`, `BOOL`, `NSInteger` and
40
+ others), and the common Foundation classes, functions and constants.
41
+ - When the word starts with `@`, it offers the `@` directives, with
42
+ snippets for `@interface`, `@implementation`, `@protocol`,
43
+ `@property`, `@try`/`@catch`, `@autoreleasepool`, `@selector` and the
44
+ array and dictionary literals.
45
+ - Its other snippets cover C's constructs, `#import`, `for ... in`,
46
+ instance and class methods, `init`, `NS_ENUM` and blocks.
47
+ - Where a message names its method, as in `[list add|`, it offers the
48
+ common Foundation selectors and the selectors of the methods declared
49
+ in the file. Completing `setObject:forKey:` inserts `setObject:`.
50
+ - It offers the names declared in the file where they are in scope:
51
+ classes, protocols, `NS_ENUM` types and their values, properties and
52
+ their `_name` instance variables, instance variables, C functions and
53
+ variables, and the parameters of methods, blocks and functions, and
54
+ `for ... in` loop variables.
55
+ - Inside `#import <...>`, it offers `Foundation/Foundation.h` and the C
56
+ headers.
57
+
58
+ Completion stays quiet in strings and comments, and after `.`, `->`
59
+ or `::` (apart from `std::`).
60
+
61
+ To use it, install it from npm:
62
+
63
+ ```
64
+ npm install @exercism/codemirror-lang-cpp
65
+ ```
66
+
67
+ To build and test it from a checkout, run `npm install` (which also builds the package), then `npm test`.
68
+
69
+ The upstream README follows.
70
+
71
+ ## @codemirror/lang-cpp [![NPM version](https://img.shields.io/npm/v/@codemirror/lang-cpp.svg)](https://www.npmjs.org/package/@codemirror/lang-cpp)
72
+
73
+ [ [**WEBSITE**](https://codemirror.net/) | [**ISSUES**](https://code.haverbeke.berlin/codemirror/dev/issues) | [**FORUM**](https://discuss.codemirror.net/) | [**CHANGELOG**](https://code.haverbeke.berlin/codemirror/lang-cpp/src/branch/main/CHANGELOG.md) ]
74
+
75
+ This package implements C++ language support for the
76
+ [CodeMirror](https://codemirror.net/) code editor.
77
+
78
+ The [project page](https://codemirror.net/) has more information, a
79
+ number of [examples](https://codemirror.net/examples/) and the
80
+ [documentation](https://codemirror.net/docs/).
81
+
82
+ This code is released under an
83
+ [MIT license](https://code.haverbeke.berlin/codemirror/lang-cpp/tree/main/LICENSE).
84
+
85
+ We aim to be an inclusive, welcoming community. To make that explicit,
86
+ we have a [code of
87
+ conduct](http://contributor-covenant.org/version/1/1/0/) that applies
88
+ to communication around the project.
89
+
90
+ ### Usage
91
+
92
+ ```javascript
93
+ import {EditorView, basicSetup} from "codemirror"
94
+ import {cpp} from "@exercism/codemirror-lang-cpp"
95
+
96
+ const view = new EditorView({
97
+ parent: document.body,
98
+ doc: `for (int i = 0; i < 1024; i++)\n cout << elt[i] << "\\n";`,
99
+ extensions: [basicSetup, cpp()]
100
+ })
101
+ ```
102
+
103
+ ### API Reference
104
+
105
+ <dl>
106
+ <dt id="user-content-cpp">
107
+ <code><strong><a href="#user-content-cpp">cpp</a></strong>() → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
108
+
109
+ <dd><p>Language support for C++. Includes snippet, keyword, standard library and
110
+ local name completion.</p>
111
+ </dd>
112
+ <dt id="user-content-c">
113
+ <code><strong><a href="#user-content-c">c</a></strong>() → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
114
+
115
+ <dd><p>Language support for C. It uses the C++ parser, which also parses
116
+ C, and completes C's keywords, standard library and snippets along with local names.</p>
117
+ </dd>
118
+ <dt id="user-content-objc">
119
+ <code><strong><a href="#user-content-objc">objc</a></strong>() → <a href="https://codemirror.net/docs/ref#language.LanguageSupport">LanguageSupport</a></code></dt>
120
+
121
+ <dd><p>Language support for Objective-C. Includes C's keywords and
122
+ library, the Objective-C keywords, types and <code>@</code> directives, the
123
+ common Foundation classes, functions and methods, snippets, and local names.</p>
124
+ </dd>
125
+ <dt id="user-content-cpplanguage">
126
+ <code><strong><a href="#user-content-cpplanguage">cppLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
127
+
128
+ <dd><p>A language provider based on the <a href="https://code.haverbeke.berlin/lezer/cpp">Lezer C++
129
+ parser</a>, extended with
130
+ highlighting and indentation information.</p>
131
+ </dd>
132
+ <dt id="user-content-objclanguage">
133
+ <code><strong><a href="#user-content-objclanguage">objcLanguage</a></strong>: <a href="https://codemirror.net/docs/ref#language.LRLanguage">LRLanguage</a></code></dt>
134
+
135
+ <dd><p>A language provider for Objective-C, using the parser's <code>objc</code>
136
+ dialect.</p>
137
+ </dd>
138
+ <dt id="user-content-cppsnippets">
139
+ <code><strong><a href="#user-content-cppsnippets">cppSnippets</a></strong>: readonly <a href="https://codemirror.net/docs/ref#autocomplete.Completion">Completion</a>[]</code></dt>
140
+
141
+ <dd><p>A collection of C++-related snippets.</p>
142
+ </dd>
143
+ <dt id="user-content-csnippets">
144
+ <code><strong><a href="#user-content-csnippets">cSnippets</a></strong>: readonly <a href="https://codemirror.net/docs/ref#autocomplete.Completion">Completion</a>[]</code></dt>
145
+
146
+ <dd><p>A collection of C-related snippets.</p>
147
+ </dd>
148
+ <dt id="user-content-localcompletionsource">
149
+ <code><strong><a href="#user-content-localcompletionsource">localCompletionSource</a></strong>: <a href="https://codemirror.net/docs/ref#autocomplete.CompletionSource">CompletionSource</a></code></dt>
150
+
151
+ <dd><p>Completion source that looks up the names declared in the file
152
+ (functions, types, variables, parameters, fields and macros), and
153
+ offers each one where it is in scope.</p>
154
+ </dd>
155
+ </dl>