From 47cf6d52eab408706f55cb159b2381a21f20f50c Mon Sep 17 00:00:00 2001 From: Christian Dietrich Date: Wed, 7 Aug 2024 14:03:17 +0200 Subject: [PATCH] Use languageId as key in prism generator (#1617) Signed-off-by: Christian Dietrich --- .../src/generator/highlighting/prism-generator.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/langium-cli/src/generator/highlighting/prism-generator.ts b/packages/langium-cli/src/generator/highlighting/prism-generator.ts index 8cb436048..31036eb57 100644 --- a/packages/langium-cli/src/generator/highlighting/prism-generator.ts +++ b/packages/langium-cli/src/generator/highlighting/prism-generator.ts @@ -5,7 +5,6 @@ ******************************************************************************/ import { GrammarAST, type Grammar, GrammarUtils, RegExpUtils } from 'langium'; import { expandToNode, joinToNode, toString, type Generated } from 'langium/generate'; -import _ from 'lodash'; import type { LangiumLanguageConfig } from '../../package-types.js'; import { collectKeywords } from '../langium-util.js'; @@ -47,17 +46,17 @@ export function generatePrismHighlighting(grammar: Grammar, config: LangiumLangu pattern: `/\\b(${filteredKeywords.join('|')})\\b/${modifier}` }; - return generate(highlighter, grammar.name ?? 'unknown'); + return generate(highlighter, config.id); } -function generate(highlighter: PrismHighlighter, grammarName: string): string { +function generate(highlighter: PrismHighlighter, languageId: string): string { /* eslint-disable @typescript-eslint/indent */ return toString( expandToNode` // This file is generated using a best effort guess for your language. // It is not guaranteed contain all expected prism syntax highlighting rules. // For more documentation, take a look at https://prismjs.com/extending.html' - Prism.languages.${_.camelCase(grammarName)} = { + Prism.languages["${languageId}"] = { ${joinToNode( Object.entries(highlighter), ([name, value]) => {