codemirror-mode-zig 0.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/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
@@ -0,0 +1,25 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ workflow_dispatch:
8
+ release:
9
+ types: [created]
10
+
11
+ jobs:
12
+ publish-gpr:
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ contents: read
16
+ packages: write
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: actions/setup-node@v4
20
+ with:
21
+ node-version: 20
22
+ registry-url: https://npm.pkg.github.com/
23
+ - run: npm publish
24
+ env:
25
+ NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -0,0 +1,22 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages
3
+
4
+ name: Node.js Package
5
+
6
+ on:
7
+ workflow_dispatch:
8
+ release:
9
+ types: [created]
10
+
11
+ jobs:
12
+ publish-npm:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-node@v4
17
+ with:
18
+ node-version: 20
19
+ registry-url: https://registry.npmjs.org/
20
+ - run: npm publish
21
+ env:
22
+ NODE_AUTH_TOKEN: ${{secrets.npm_token}}
package/.prettierrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "tabWidth": 4
3
+ }
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ declare module '@imkylecat/codemirror-mode-zig';
package/index.js ADDED
@@ -0,0 +1,98 @@
1
+ import CodeMirror from "codemirror";
2
+
3
+ CodeMirror.defineMode("zig", function () {
4
+ var keywords = {
5
+ const: true,
6
+ var: true,
7
+ extern: true,
8
+ packed: true,
9
+ export: true,
10
+ pub: true,
11
+ noalias: true,
12
+ inline: true,
13
+ comptime: true,
14
+ test: true,
15
+ fn: true,
16
+ usingnamespace: true,
17
+ struct: true,
18
+ enum: true,
19
+ union: true,
20
+ if: true,
21
+ else: true,
22
+ switch: true,
23
+ while: true,
24
+ for: true,
25
+ break: true,
26
+ continue: true,
27
+ return: true,
28
+ defer: true,
29
+ errdefer: true,
30
+ as: true,
31
+ null: true,
32
+ };
33
+
34
+ var isOperatorChar = /[+\-*&%=<>!?|]/;
35
+
36
+ function tokenBase(stream, state) {
37
+ var ch = stream.next();
38
+ if (ch == '"') {
39
+ state.tokenize = tokenString(ch);
40
+ return state.tokenize(stream, state);
41
+ }
42
+ if (/[\d]/.test(ch)) {
43
+ stream.eatWhile(/[\w\.]/);
44
+ return "number";
45
+ }
46
+ if (/[\w_]/.test(ch)) {
47
+ stream.eatWhile(/[\w_]/);
48
+ var cur = stream.current();
49
+ if (keywords.propertyIsEnumerable(cur)) {
50
+ return "keyword";
51
+ }
52
+ return "variable";
53
+ }
54
+ if (isOperatorChar.test(ch)) {
55
+ stream.eatWhile(isOperatorChar);
56
+ return "operator";
57
+ }
58
+ if (ch == "/" && stream.eat("/")) {
59
+ stream.skipToEnd();
60
+ return "comment";
61
+ }
62
+ return null;
63
+ }
64
+
65
+ function tokenString(quote) {
66
+ return function (stream, state) {
67
+ var escaped = false,
68
+ next,
69
+ end = false;
70
+ while ((next = stream.next()) != null) {
71
+ if (next == quote && !escaped) {
72
+ end = true;
73
+ break;
74
+ }
75
+ escaped = !escaped && next == "\\";
76
+ }
77
+ if (end || !escaped) {
78
+ state.tokenize = tokenBase;
79
+ }
80
+ return "string";
81
+ };
82
+ }
83
+
84
+ return {
85
+ startState: function () {
86
+ return { tokenize: tokenBase };
87
+ },
88
+ token: function (stream, state) {
89
+ if (stream.eatSpace()) {
90
+ return null;
91
+ }
92
+ var style = state.tokenize(stream, state);
93
+ return style;
94
+ },
95
+ };
96
+ });
97
+
98
+ CodeMirror.defineMIME("text/x-zig", "zig");
package/package.json ADDED
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "codemirror-mode-zig",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/imkylecat/codemirror-mode-zig.git"
12
+ },
13
+ "author": "imkylecat",
14
+ "license": "ISC",
15
+ "bugs": {
16
+ "url": "https://github.com/imkylecat/codemirror-mode-zig/issues"
17
+ },
18
+ "homepage": "https://github.com/imkylecat/codemirror-mode-zig#readme"
19
+ }