diff options
| author | Elizabeth Hunt <me@liz.coffee> | 2026-01-04 22:15:20 -0800 |
|---|---|---|
| committer | Elizabeth Hunt <me@liz.coffee> | 2026-01-04 22:15:20 -0800 |
| commit | 686c6f90d7a3c2bc0f8b89619c5d91ee8fb320e4 (patch) | |
| tree | 4813432a71edb425fe453316e3e07f637690a0b1 /src/index.ts | |
| download | codemirror-lang-tabloid-686c6f90d7a3c2bc0f8b89619c5d91ee8fb320e4.tar.gz codemirror-lang-tabloid-686c6f90d7a3c2bc0f8b89619c5d91ee8fb320e4.zip | |
Add tabloid language support
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) +} |
