@bhsd/lezer-json 2.1.3 → 2.2.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/dist/index.js +17 -2
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { continuedIndent, indentNodeProp, foldNodeProp, foldInside, LRLanguage, LanguageSupport, } from '@codemirror/language';
|
|
1
|
+
import { continuedIndent, indentNodeProp, foldNodeProp, foldInside, LRLanguage, LanguageSupport, syntaxTree, } from '@codemirror/language';
|
|
2
2
|
import { lintJSON, lintJSONC } from '@bhsd/common';
|
|
3
3
|
import { parser } from './parser.js';
|
|
4
4
|
const props = [
|
|
@@ -9,9 +9,24 @@ const props = [
|
|
|
9
9
|
foldNodeProp.add({
|
|
10
10
|
'Object Array': foldInside,
|
|
11
11
|
}),
|
|
12
|
-
], languageData = {
|
|
12
|
+
], options = ['true', 'false', 'null'].map((label) => ({ label, type: 'keyword' })), languageData = {
|
|
13
13
|
closeBrackets: { brackts: ['[', '{', '"'] },
|
|
14
14
|
indentOnInput: /^\s*[}\]]$/u,
|
|
15
|
+
autocomplete(context) {
|
|
16
|
+
const mt = context.matchBefore(/(?:^|[[,:])\s*[a-z]+$/u);
|
|
17
|
+
if (!mt) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
const { state, pos } = context, { name: n, parent: p } = syntaxTree(state).resolveInner(pos, -1), { from, text } = mt;
|
|
21
|
+
return (p === null || p === void 0 ? void 0 : p.name) === 'Array' && !text.startsWith(':')
|
|
22
|
+
|| n !== 'PropertyName' && (p === null || p === void 0 ? void 0 : p.name) === 'Property' && !/^[[,]/u.test(text)
|
|
23
|
+
? {
|
|
24
|
+
from: from + text.search(/[a-z]/iu),
|
|
25
|
+
options,
|
|
26
|
+
validFor: /^[a-z]*$/iu,
|
|
27
|
+
}
|
|
28
|
+
: null;
|
|
29
|
+
},
|
|
15
30
|
};
|
|
16
31
|
/** LR language for JSON. */
|
|
17
32
|
export const jsonLanguage = /* #__PURE__ */ (() => LRLanguage.define({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bhsd/lezer-json",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Lezer-based JSON/JSONC grammar",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemirror",
|
|
@@ -54,11 +54,12 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@bhsd/code-standard": "^4.2.0",
|
|
57
|
+
"@codemirror/autocomplete": "^6.20.3",
|
|
57
58
|
"@codemirror/language": "^6.12.4",
|
|
58
59
|
"@codemirror/lint": "^6.9.7",
|
|
59
60
|
"@lezer/generator": "^1.8.0",
|
|
60
|
-
"eslint": "^10.
|
|
61
|
-
"markdownlint-cli2": "^0.23.
|
|
61
|
+
"eslint": "^10.11.0",
|
|
62
|
+
"markdownlint-cli2": "^0.23.3",
|
|
62
63
|
"typescript": "^6.0.3"
|
|
63
64
|
}
|
|
64
65
|
}
|