diff options
Diffstat (limited to 'src/index.ts')
| -rw-r--r-- | src/index.ts | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..14b4ffe --- /dev/null +++ b/src/index.ts @@ -0,0 +1,51 @@ +import {parser} from "./syntax.grammar" +import {LRLanguage, LanguageSupport, indentNodeProp, foldNodeProp, foldInside, delimitedIndent} from "@codemirror/language" +import {styleTags, tags as t} from "@lezer/highlight" + +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, + }), + 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 + }) + ] + }), + languageData: { + commentTokens: {} + } +}) + +export function tabloid() { + return new LanguageSupport(tabloidLanguage) +} |
