From ee7ac9c18e4a1f4dd00774404d202c0f8b4830e4 Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Tue, 9 Apr 2024 15:13:28 +0530 Subject: [PATCH] Add auto pairing rules for Tact language --- src/utility/syntaxHighlighter.ts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/utility/syntaxHighlighter.ts b/src/utility/syntaxHighlighter.ts index 8bc0ae3..249b0e0 100644 --- a/src/utility/syntaxHighlighter.ts +++ b/src/utility/syntaxHighlighter.ts @@ -56,9 +56,37 @@ export async function highlightCodeSnippets( }, }; - const languageConfiguration: monaco.languages.LanguageConfiguration = { + const autoPairingRules = { + func: {}, + tact: { + surroundingPairs: [ + { open: '{', close: '}' }, + { open: '[', close: ']' }, + { open: '(', close: ')' }, + { open: '<', close: '>' }, + { open: '"', close: '"' }, + ], + autoClosingPairs: [ + { open: '{', close: '}' }, + { open: '[', close: ']' }, + { open: '(', close: ')' }, + { open: '<', close: '>' }, + { open: '"', close: '"', notIn: ['string', 'comment'] }, + ], + }, + }; + + let languageConfiguration: monaco.languages.LanguageConfiguration = { comments: commentRules[language] as any, }; + + if (language === 'tact') { + languageConfiguration = { + ...languageConfiguration, + ...autoPairingRules.tact, + }; + } + monaco.languages.setLanguageConfiguration( language, languageConfiguration