aboutsummaryrefslogtreecommitdiff
path: root/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.ts')
-rw-r--r--src/index.ts76
1 files changed, 40 insertions, 36 deletions
diff --git a/src/index.ts b/src/index.ts
index 14b4ffe..690572b 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,51 +1,55 @@
-import {parser} from "./syntax.grammar"
-import {LRLanguage, LanguageSupport, indentNodeProp, foldNodeProp, foldInside, delimitedIndent} from "@codemirror/language"
-import {styleTags, tags as t} from "@lezer/highlight"
+import { parser } from "./syntax.grammar";
+import {
+ LRLanguage,
+ LanguageSupport,
+ indentNodeProp,
+ foldNodeProp,
+ foldInside,
+ delimitedIndent,
+} from "@codemirror/language";
+import { highlighting } from "./highlight";
+import { tabloidCompletion } from "./autocomplete";
+import { autocompletion } from "@codemirror/autocomplete";
+
+// Wrap parser to debug
+const originalParse = parser.parse.bind(parser);
+parser.parse = function (input, fragments, ranges) {
+ console.log(
+ "[PARSER] parse called with input:",
+ typeof input === "string" ? input.substring(0, 100) : input,
+ );
+ const result = originalParse(input, fragments, ranges);
+ console.log("[PARSER] parse result:", result.toString());
+ return result;
+};
export const tabloidLanguage = LRLanguage.define({
parser: parser.configure({
props: [
indentNodeProp.add({
- Block: delimitedIndent({closing: "endOfStory", align: false}),
- ParenBlock: delimitedIndent({closing: ")", align: false}),
- FunctionDecl: context => context.baseIndent + context.unit,
- IfStatement: context => context.baseIndent + context.unit,
+ Block: delimitedIndent({ closing: "endOfStory", align: false }),
+ ParenBlock: delimitedIndent({ closing: ")", align: false }),
+ FunctionDecl: (context) => context.baseIndent + context.unit,
+ IfStatement: (context) => context.baseIndent + context.unit,
}),
foldNodeProp.add({
Block: foldInside,
ParenBlock: foldInside,
}),
- styleTags({
- Identifier: t.variableName,
- NumberLiteral: t.number,
- StringLiteral: t.string,
- BooleanLiteral: t.bool,
- FunctionCall: t.function(t.variableName),
- discoverHowTo: t.definitionKeyword,
- expertsClaim: t.definitionKeyword,
- toBe: t.operatorKeyword,
- rumorHasIt: t.keyword,
- endOfStory: t.keyword,
- whatIf: t.controlKeyword,
- liesBang: t.controlKeyword,
- shockingDevelopment: t.controlKeyword,
- youWontWantToMiss: t.keyword,
- latestNewsOn: t.keyword,
- pleaseLikeAndSubscribe: t.keyword,
- "with of": t.keyword,
- "isActually beats smallerThan": t.compareOperator,
- "and or": t.logicOperator,
- "plus minus times dividedBy modulo": t.arithmeticOperator,
- "( )": t.paren,
- ",": t.separator
- })
- ]
+ highlighting,
+ ],
}),
languageData: {
- commentTokens: {}
- }
-})
+ commentTokens: {},
+ closeBrackets: { brackets: ["(", '"', "'"] },
+ autocomplete: tabloidCompletion,
+ },
+});
export function tabloid() {
- return new LanguageSupport(tabloidLanguage)
+ return new LanguageSupport(tabloidLanguage, [
+ autocompletion({ override: [tabloidCompletion] }),
+ ]);
}
+
+export { tabloidCompletion };