Skip to content

Commit

Permalink
Add auto pairing rules for Tact language
Browse files Browse the repository at this point in the history
  • Loading branch information
rahulyadav-57 committed Apr 9, 2024
1 parent 492992f commit ee7ac9c
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion src/utility/syntaxHighlighter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

3 comments on commit ee7ac9c

@rahulyadav-57
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolves #23

@novusnota
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, but one thing though — Tact doesn't use square brackets [] anywhere

@rahulyadav-57
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@novusnota Thank you for pointing out the mistake. I have removed it.

Please sign in to comment.