codemirror-lang-glimmer 0.0.0-beta.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/.eslintignore +2 -0
- package/.eslintrc.cjs +5 -0
- package/.prettierignore +2 -0
- package/.prettierrc.cjs +20 -0
- package/CHANGELOG.md +7 -0
- package/README.md +20 -0
- package/dev/.eslintrc.cjs +5 -0
- package/dev/index.html +42 -0
- package/dev/index.ts +175 -0
- package/dev/node_modules/.bin/eslint +17 -0
- package/dev/node_modules/.bin/prettier +17 -0
- package/dev/node_modules/.bin/tsc +17 -0
- package/dev/node_modules/.bin/tsserver +17 -0
- package/dev/node_modules/.bin/vite +17 -0
- package/dev/package.json +30 -0
- package/dev/vite.config.js +10 -0
- package/dev/watch.cjs +11 -0
- package/package.json +54 -0
- package/src/highlight.ts +57 -0
- package/src/index.ts +154 -0
- package/src/syntax.grammar +139 -0
- package/src/syntax.grammar.d.ts +3 -0
- package/src/syntax.grammar.terms.d.ts +14 -0
- package/src/tokens.ts +277 -0
- package/tests/.eslintrc.cjs +5 -0
- package/tests/comments.txt +116 -0
- package/tests/complex.txt +24 -0
- package/tests/expression.txt +95 -0
- package/tests/literals.txt +78 -0
- package/tests/node_modules/.bin/eslint +17 -0
- package/tests/node_modules/.bin/prettier +17 -0
- package/tests/node_modules/.bin/tsc +17 -0
- package/tests/node_modules/.bin/tsserver +17 -0
- package/tests/numbers.txt +88 -0
- package/tests/package.json +25 -0
- package/tests/property-paths.txt +79 -0
- package/tests/strings.txt +64 -0
package/.eslintignore
ADDED
package/.eslintrc.cjs
ADDED
package/.prettierignore
ADDED
package/.prettierrc.cjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
printWidth: 100,
|
|
5
|
+
overrides: [
|
|
6
|
+
{
|
|
7
|
+
files: ["*.js", "*.ts"],
|
|
8
|
+
options: {
|
|
9
|
+
singleQuote: true,
|
|
10
|
+
trailingComma: "es5",
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
files: ["*.json"],
|
|
15
|
+
options: {
|
|
16
|
+
singleQuote: false,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
};
|
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# CodeMirror Glimmer
|
|
2
|
+
|
|
3
|
+
This is a CodeMirror 6 plugin that adds support for Glimmer (gjs and gts).
|
|
4
|
+
|
|
5
|
+
### Usage
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { EditorState } from '@codemirror/state';
|
|
9
|
+
import { EditorView } from '@codemirror/view';
|
|
10
|
+
import { glimmer } from 'tbd';
|
|
11
|
+
import { basicSetup } from 'codemirror';
|
|
12
|
+
|
|
13
|
+
new EditorView({
|
|
14
|
+
state: EditorState.create({
|
|
15
|
+
doc: `<script>let a = "hello world";</script> <div>{a}</div>`,
|
|
16
|
+
extensions: [basicSetup, glimmer()],
|
|
17
|
+
}),
|
|
18
|
+
parent: document.querySelector('#editor'),
|
|
19
|
+
});
|
|
20
|
+
```
|
package/dev/index.html
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>Vite App</title>
|
|
7
|
+
|
|
8
|
+
<style>
|
|
9
|
+
body {
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
background-color: #282c34;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.layout {
|
|
16
|
+
height: 100vh;
|
|
17
|
+
width: 100%;
|
|
18
|
+
display: grid;
|
|
19
|
+
grid-template-columns: 1fr 1fr;
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
}
|
|
22
|
+
#editor {
|
|
23
|
+
height: 100vh;
|
|
24
|
+
overflow: scroll;
|
|
25
|
+
border-right: solid 0.125rem #111;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
#editor-ast {
|
|
29
|
+
height: 100vh;
|
|
30
|
+
overflow: scroll;
|
|
31
|
+
}
|
|
32
|
+
</style>
|
|
33
|
+
</head>
|
|
34
|
+
<body class="replit-ui-theme-root dark">
|
|
35
|
+
<div class="layout">
|
|
36
|
+
<div id="editor"></div>
|
|
37
|
+
<div id="editor-ast"></div>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<script type="module" src="./index.ts"></script>
|
|
41
|
+
</body>
|
|
42
|
+
</html>
|
package/dev/index.ts
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { syntaxTree } from '@codemirror/language';
|
|
2
|
+
import { EditorState } from '@codemirror/state';
|
|
3
|
+
import { oneDark } from '@codemirror/theme-one-dark';
|
|
4
|
+
import { EditorView } from '@codemirror/view';
|
|
5
|
+
import { basicSetup } from 'codemirror';
|
|
6
|
+
|
|
7
|
+
import { printTree } from '@glimdown/codemirror-dev-preview/print-tree';
|
|
8
|
+
|
|
9
|
+
import { glimmer, glimmerParser } from '../dist/';
|
|
10
|
+
|
|
11
|
+
const testDoc = `
|
|
12
|
+
{{!
|
|
13
|
+
simple comment
|
|
14
|
+
}}
|
|
15
|
+
|
|
16
|
+
just some text
|
|
17
|
+
{{call expression}}
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
{{!--
|
|
21
|
+
long comment
|
|
22
|
+
--}}
|
|
23
|
+
|
|
24
|
+
<!--
|
|
25
|
+
HTML Comment
|
|
26
|
+
{{not a comment}}
|
|
27
|
+
{{!still a comment}}
|
|
28
|
+
{{!--still a comment--}}
|
|
29
|
+
-->
|
|
30
|
+
|
|
31
|
+
{{foo.bar}}
|
|
32
|
+
{{this.foo}}
|
|
33
|
+
{{this.foo.bar}}
|
|
34
|
+
|
|
35
|
+
{{#let greeting as |value|}}
|
|
36
|
+
{{value}}
|
|
37
|
+
{{/let}}
|
|
38
|
+
|
|
39
|
+
{{#if (nested (condition))}}
|
|
40
|
+
bar
|
|
41
|
+
{{else}}
|
|
42
|
+
foo
|
|
43
|
+
{{/if}}
|
|
44
|
+
|
|
45
|
+
{{#unless (nested (condition))}}
|
|
46
|
+
bar
|
|
47
|
+
{{else}}
|
|
48
|
+
foo
|
|
49
|
+
{{/unless}}
|
|
50
|
+
|
|
51
|
+
Hello {{this.name}}!
|
|
52
|
+
|
|
53
|
+
{{! inline simple }}
|
|
54
|
+
{{!-- inline long }}
|
|
55
|
+
|
|
56
|
+
<OneLine ...attributes />
|
|
57
|
+
<OneLine />
|
|
58
|
+
<Inline />
|
|
59
|
+
<Empty
|
|
60
|
+
attribute="value"
|
|
61
|
+
foo=bar
|
|
62
|
+
bar={{foo}}
|
|
63
|
+
@arg="str"
|
|
64
|
+
@arg1={{value}}
|
|
65
|
+
@arg2={{call something}}
|
|
66
|
+
@arg3={{ (call something) }}
|
|
67
|
+
@arg4={{ (call (nested @thing named=@arg)) }}
|
|
68
|
+
{{someModifier}}
|
|
69
|
+
{{someModifier 1 (two) three=(four)}}
|
|
70
|
+
/>
|
|
71
|
+
<WithNamedBlocks @arg="str" @foo={{value}} {{on 'click' this.foo}}>
|
|
72
|
+
<:loading>
|
|
73
|
+
Loading...
|
|
74
|
+
</:loading>
|
|
75
|
+
<:resolved as |value|>
|
|
76
|
+
{{value.data.property}}
|
|
77
|
+
</:resolved>
|
|
78
|
+
</WithNamedBlocks>
|
|
79
|
+
|
|
80
|
+
{{hash foo="hello" bar=(component Inline arg="hi")}}
|
|
81
|
+
|
|
82
|
+
{{array 1 2 @foo @bar}}
|
|
83
|
+
|
|
84
|
+
<ul {{someModifier}}>
|
|
85
|
+
{{#each (array 1 2 (concat "hi" "there")) as |item|}}
|
|
86
|
+
|
|
87
|
+
<li>{{item}}</li>
|
|
88
|
+
|
|
89
|
+
{{/each}}
|
|
90
|
+
</ul>
|
|
91
|
+
|
|
92
|
+
<button {{on 'click' handler}}>click me</button>
|
|
93
|
+
|
|
94
|
+
<div class="string {{value}}"></div>
|
|
95
|
+
<div class="string {{value}} still string"></div>
|
|
96
|
+
<div class='{{if condition "class-name"}}'></div>
|
|
97
|
+
<div class="{{if condition 'class-name'}}"></div>
|
|
98
|
+
<div class="{{if condition "class-name"}}"></div>
|
|
99
|
+
|
|
100
|
+
{{yield}}
|
|
101
|
+
{{yield to="elsewhere"}}
|
|
102
|
+
{{yield foo}}
|
|
103
|
+
{{yield (hash foo="bar")}}
|
|
104
|
+
{{yield (hash
|
|
105
|
+
c=(component "foo" named=2)
|
|
106
|
+
m=(modifier "foo" named=2)
|
|
107
|
+
h=(helper "foo" named=2)
|
|
108
|
+
)}}
|
|
109
|
+
|
|
110
|
+
{{outlet}}
|
|
111
|
+
`;
|
|
112
|
+
|
|
113
|
+
const doc = testDoc;
|
|
114
|
+
|
|
115
|
+
const syncAST = EditorView.updateListener.of((update) => {
|
|
116
|
+
if (update.docChanged || update.selectionSet) {
|
|
117
|
+
const { from: oldFrom, to: oldTo } = update.startState.selection.ranges[0];
|
|
118
|
+
let { from, to } = update.state.selection.ranges[0];
|
|
119
|
+
|
|
120
|
+
const docChanged = update.docChanged;
|
|
121
|
+
const selectionChanged = !(
|
|
122
|
+
(from === to && oldFrom === oldTo) ||
|
|
123
|
+
(from === oldFrom && to === oldTo)
|
|
124
|
+
);
|
|
125
|
+
const hasSelection = from !== to;
|
|
126
|
+
|
|
127
|
+
if (docChanged || selectionChanged) {
|
|
128
|
+
const glimmerAST = printTree(
|
|
129
|
+
syntaxTree(update.view.state),
|
|
130
|
+
update.state.doc.toString(),
|
|
131
|
+
hasSelection ? { from, to } : undefined
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
queueMicrotask(() => {
|
|
135
|
+
glimmerTree.dispatch({
|
|
136
|
+
changes: {
|
|
137
|
+
from: 0,
|
|
138
|
+
to: glimmerTree.state.doc.length,
|
|
139
|
+
insert: glimmerAST,
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// Text Input
|
|
148
|
+
export const mainView = new EditorView({
|
|
149
|
+
state: EditorState.create({
|
|
150
|
+
doc,
|
|
151
|
+
extensions: [
|
|
152
|
+
basicSetup,
|
|
153
|
+
glimmer(),
|
|
154
|
+
// We can't use HTML as the hosting language
|
|
155
|
+
// (to overlay Glimmer on top of)
|
|
156
|
+
// Because in Glimmer, we can have spaces within double curlies,
|
|
157
|
+
// and in the HTML parser, this ends up escaping the attribute valuse, and other things
|
|
158
|
+
// htmlLanguage,
|
|
159
|
+
oneDark,
|
|
160
|
+
EditorView.lineWrapping,
|
|
161
|
+
syncAST,
|
|
162
|
+
],
|
|
163
|
+
}),
|
|
164
|
+
parent: document.querySelector('#editor'),
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Glimmer Tree
|
|
168
|
+
const glimmerState = EditorState.create({
|
|
169
|
+
doc: printTree(glimmerParser.parse(doc), doc),
|
|
170
|
+
extensions: [basicSetup, oneDark, EditorView.lineWrapping, EditorState.readOnly.of(true)],
|
|
171
|
+
});
|
|
172
|
+
const glimmerTree = new EditorView({
|
|
173
|
+
state: glimmerState,
|
|
174
|
+
parent: document.querySelector('#editor-ast'),
|
|
175
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/glimdown/glimdown/node_modules/.pnpm/eslint@8.40.0/node_modules/eslint/bin/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/eslint@8.40.0/node_modules/eslint/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/eslint@8.40.0/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/runner/work/glimdown/glimdown/node_modules/.pnpm/eslint@8.40.0/node_modules/eslint/bin/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/eslint@8.40.0/node_modules/eslint/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/eslint@8.40.0/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/eslint@8.40.0/node_modules/eslint/bin/eslint.js" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../../../../../../node_modules/.pnpm/eslint@8.40.0/node_modules/eslint/bin/eslint.js" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/glimdown/glimdown/node_modules/.pnpm/prettier@2.8.8/node_modules/prettier/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/prettier@2.8.8/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/runner/work/glimdown/glimdown/node_modules/.pnpm/prettier@2.8.8/node_modules/prettier/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/prettier@2.8.8/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/prettier@2.8.8/node_modules/prettier/bin-prettier.js" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../../../../../../node_modules/.pnpm/prettier@2.8.8/node_modules/prettier/bin-prettier.js" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/glimdown/glimdown/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/bin/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/typescript@5.0.4/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/runner/work/glimdown/glimdown/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/bin/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/typescript@5.0.4/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/bin/tsc" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../../../../../../node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/bin/tsc" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/glimdown/glimdown/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/bin/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/typescript@5.0.4/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/runner/work/glimdown/glimdown/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/bin/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/typescript@5.0.4/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/bin/tsserver" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../../../../../../node_modules/.pnpm/typescript@5.0.4/node_modules/typescript/bin/tsserver" "$@"
|
|
17
|
+
fi
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
+
|
|
4
|
+
case `uname` in
|
|
5
|
+
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
|
|
6
|
+
esac
|
|
7
|
+
|
|
8
|
+
if [ -z "$NODE_PATH" ]; then
|
|
9
|
+
export NODE_PATH="/home/runner/work/glimdown/glimdown/node_modules/.pnpm/vite@4.3.5_@types+node@20.1.0/node_modules/vite/bin/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/vite@4.3.5_@types+node@20.1.0/node_modules/vite/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/vite@4.3.5_@types+node@20.1.0/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/node_modules"
|
|
10
|
+
else
|
|
11
|
+
export NODE_PATH="/home/runner/work/glimdown/glimdown/node_modules/.pnpm/vite@4.3.5_@types+node@20.1.0/node_modules/vite/bin/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/vite@4.3.5_@types+node@20.1.0/node_modules/vite/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/vite@4.3.5_@types+node@20.1.0/node_modules:/home/runner/work/glimdown/glimdown/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
|
+
fi
|
|
13
|
+
if [ -x "$basedir/node" ]; then
|
|
14
|
+
exec "$basedir/node" "$basedir/../../../../../../node_modules/.pnpm/vite@4.3.5_@types+node@20.1.0/node_modules/vite/bin/vite.js" "$@"
|
|
15
|
+
else
|
|
16
|
+
exec node "$basedir/../../../../../../node_modules/.pnpm/vite@4.3.5_@types+node@20.1.0/node_modules/vite/bin/vite.js" "$@"
|
|
17
|
+
fi
|
package/dev/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@glimdown/glimmer-dev-preview",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"dev": "vite .",
|
|
7
|
+
"_:lint:js": "pnpm -w exec lint js",
|
|
8
|
+
"_:lint:js:fix": "pnpm -w exec lint js:fix",
|
|
9
|
+
"_:lint:prettier:fix": "pnpm -w exec lint prettier:fix",
|
|
10
|
+
"_:lint:prettier": "pnpm -w exec lint prettier",
|
|
11
|
+
"lint": "pnpm -w exec lint",
|
|
12
|
+
"lint:fix": "pnpm -w exec lint fix"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@glimdown/codemirror-dev-preview": "workspace:*",
|
|
16
|
+
"@codemirror/language": "^6.6.0",
|
|
17
|
+
"@codemirror/state": "^6.2.0",
|
|
18
|
+
"@codemirror/theme-one-dark": "^6.1.2",
|
|
19
|
+
"@codemirror/view": "^6.11.0",
|
|
20
|
+
"vite": "^4.3.5",
|
|
21
|
+
"@babel/eslint-parser": "^7.21.8",
|
|
22
|
+
"@nullvoxpopuli/eslint-configs": "^3.1.3",
|
|
23
|
+
"@typescript-eslint/eslint-plugin": "^5.59.2",
|
|
24
|
+
"@typescript-eslint/parser": "^5.59.2",
|
|
25
|
+
"eslint": "^8.40.0",
|
|
26
|
+
"prettier": "^2.8.8",
|
|
27
|
+
"typescript": "^5.0.4",
|
|
28
|
+
"@babel/core": "^7.21.8"
|
|
29
|
+
}
|
|
30
|
+
}
|
package/dev/watch.cjs
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const { watch } = require("@codemirror/buildhelper");
|
|
2
|
+
const { resolve } = require("path");
|
|
3
|
+
|
|
4
|
+
let args = process.argv.slice(2);
|
|
5
|
+
|
|
6
|
+
if (args.length != 1) {
|
|
7
|
+
console.debug("Usage: cm-buildhelper src/mainfile.ts");
|
|
8
|
+
process.exit(1);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
watch([resolve(args[0])]);
|
package/package.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "codemirror-lang-glimmer",
|
|
3
|
+
"version": "0.0.0-beta.1",
|
|
4
|
+
"author": "NullVoxPopuli",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"require": "./dist/index.cjs"
|
|
10
|
+
},
|
|
11
|
+
"main": "dist/index.cjs",
|
|
12
|
+
"module": "dist/index.js",
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/nullvoxpopuli/glimdown.git",
|
|
17
|
+
"path": "packages/lezer/glimmer"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@babel/core": "^7.21.8",
|
|
21
|
+
"@babel/eslint-parser": "^7.21.8",
|
|
22
|
+
"@codemirror/buildhelper": "^0.1.16",
|
|
23
|
+
"@lezer/generator": "^1.2.3",
|
|
24
|
+
"@nullvoxpopuli/eslint-configs": "^3.1.3",
|
|
25
|
+
"@typescript-eslint/eslint-plugin": "^5.59.2",
|
|
26
|
+
"@typescript-eslint/parser": "^5.59.2",
|
|
27
|
+
"codemirror": "^6.0.1",
|
|
28
|
+
"concurrently": "^8.0.1",
|
|
29
|
+
"eslint": "^8.40.0",
|
|
30
|
+
"prettier": "^2.8.8",
|
|
31
|
+
"typescript": "^5.0.4"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@codemirror/lang-html": "^6.4.3",
|
|
35
|
+
"@lezer/common": "^1.0.2",
|
|
36
|
+
"@lezer/highlight": "^1.1.4",
|
|
37
|
+
"@lezer/html": "^1.3.4",
|
|
38
|
+
"@lezer/javascript": "^1.4.3",
|
|
39
|
+
"@lezer/lr": "^1.3.4"
|
|
40
|
+
},
|
|
41
|
+
"volta": {
|
|
42
|
+
"extends": "../../../package.json"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"dev": "node ./dev/watch.cjs src/index.ts",
|
|
46
|
+
"build": "cm-buildhelper src/index.ts",
|
|
47
|
+
"lint": "pnpm -w exec lint",
|
|
48
|
+
"_:lint:js": "pnpm -w exec lint js",
|
|
49
|
+
"_:lint:js:fix": "pnpm -w exec lint js:fix",
|
|
50
|
+
"_:lint:prettier:fix": "pnpm -w exec lint prettier:fix",
|
|
51
|
+
"_:lint:prettier": "pnpm -w exec lint prettier",
|
|
52
|
+
"lint:fix": "pnpm -w exec lint fix"
|
|
53
|
+
}
|
|
54
|
+
}
|
package/src/highlight.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { styleTags, tags as t } from '@lezer/highlight';
|
|
2
|
+
|
|
3
|
+
export const glimmerHighlighting = styleTags({
|
|
4
|
+
'Text RawText': t.content,
|
|
5
|
+
'StartTag StartCloseTag SelfClosingEndTag EndTag': t.angleBracket,
|
|
6
|
+
TagName: t.tagName,
|
|
7
|
+
'MismatchedCloseTag/TagName': [t.tagName, t.invalid],
|
|
8
|
+
AttributeName: t.attributeName,
|
|
9
|
+
|
|
10
|
+
// Glimmer
|
|
11
|
+
TemplateTag: t.definition(t.annotation),
|
|
12
|
+
'{{ }}': t.bracket,
|
|
13
|
+
'( )': t.paren,
|
|
14
|
+
Function: t.function(t.name),
|
|
15
|
+
Splattributes: t.derefOperator,
|
|
16
|
+
Comment: t.blockComment,
|
|
17
|
+
ShortComment: t.blockComment,
|
|
18
|
+
LongComment: t.blockComment,
|
|
19
|
+
HtmlComment: t.blockComment,
|
|
20
|
+
ArgName: t.attributeName,
|
|
21
|
+
Argument: t.propertyName,
|
|
22
|
+
NamedBlock: t.tagName,
|
|
23
|
+
Is: t.definitionOperator,
|
|
24
|
+
Pipe: t.definitionOperator,
|
|
25
|
+
|
|
26
|
+
as: t.definitionOperator,
|
|
27
|
+
let: t.function(t.definitionOperator),
|
|
28
|
+
this: t.self,
|
|
29
|
+
yield: t.operatorKeyword,
|
|
30
|
+
outlet: t.operatorKeyword,
|
|
31
|
+
|
|
32
|
+
component: t.function(t.definitionKeyword),
|
|
33
|
+
modifier: t.function(t.definitionKeyword),
|
|
34
|
+
helper: t.function(t.definitionKeyword),
|
|
35
|
+
hash: t.function(t.definitionKeyword),
|
|
36
|
+
array: t.function(t.definitionKeyword),
|
|
37
|
+
on: t.function(t.definitionKeyword),
|
|
38
|
+
concat: t.function(t.operatorKeyword),
|
|
39
|
+
'if then catch unless else each each-in': t.controlKeyword,
|
|
40
|
+
|
|
41
|
+
// TODO:
|
|
42
|
+
UnquotedAttributeValue: t.attributeValue,
|
|
43
|
+
'DoubleQuote SingleQuote AttributeValueContent': t.attributeValue,
|
|
44
|
+
'EntityReference CharacterReference': t.character,
|
|
45
|
+
'[ ]': t.squareBracket,
|
|
46
|
+
|
|
47
|
+
ComponentName: t.className,
|
|
48
|
+
StyleAttributeName: t.propertyName,
|
|
49
|
+
BlockType: t.controlKeyword,
|
|
50
|
+
BlockPrefix: t.typeOperator,
|
|
51
|
+
'UnknownBlock/BlockType': t.invalid,
|
|
52
|
+
UnknownBlockContent: t.invalid,
|
|
53
|
+
|
|
54
|
+
Variable: t.variableName,
|
|
55
|
+
Modifier: t.modifier,
|
|
56
|
+
ModifierValue: t.function(t.modifier),
|
|
57
|
+
});
|