mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 16:15:41 +01:00
Configure auto closing pairs and on enter rules
This commit is contained in:
parent
92a1dad12d
commit
7755d67b8b
1 changed files with 46 additions and 2 deletions
|
|
@ -3,13 +3,57 @@
|
||||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import type { languages } from '../../fillers/monaco-editor-core';
|
import { languages } from '../../fillers/monaco-editor-core';
|
||||||
|
|
||||||
export const conf: languages.LanguageConfiguration = {
|
export const conf: languages.LanguageConfiguration = {
|
||||||
comments: {
|
comments: {
|
||||||
blockComment: ['{/*', '*/}']
|
blockComment: ['{/*', '*/}']
|
||||||
},
|
},
|
||||||
brackets: [['{', '}']]
|
brackets: [['{', '}']],
|
||||||
|
autoClosingPairs: [
|
||||||
|
{ open: '"', close: '"' },
|
||||||
|
{ open: "'", close: "'" },
|
||||||
|
{ open: '“', close: '”' },
|
||||||
|
{ open: '‘', close: '’' },
|
||||||
|
{ open: '`', close: '`' },
|
||||||
|
{ open: '{', close: '}' },
|
||||||
|
{ open: '_', close: '_' },
|
||||||
|
{ open: '**', close: '**' }
|
||||||
|
],
|
||||||
|
onEnterRules: [
|
||||||
|
{
|
||||||
|
beforeText: /^\s*- .+/,
|
||||||
|
action: { indentAction: languages.IndentAction.None, appendText: '- ' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
beforeText: /^\s*\+ .+/,
|
||||||
|
action: { indentAction: languages.IndentAction.None, appendText: '+ ' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
beforeText: /^\s*\* .+/,
|
||||||
|
action: { indentAction: languages.IndentAction.None, appendText: '* ' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
beforeText: /^> /,
|
||||||
|
action: { indentAction: languages.IndentAction.None, appendText: '> ' }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
beforeText: /<\w+/,
|
||||||
|
action: { indentAction: languages.IndentAction.Indent }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
beforeText: /\s+>\s*$/,
|
||||||
|
action: { indentAction: languages.IndentAction.Indent }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
beforeText: /<\/\w+>/,
|
||||||
|
action: { indentAction: languages.IndentAction.Outdent }
|
||||||
|
},
|
||||||
|
...Array.from({ length: 100 }, (_, index) => ({
|
||||||
|
beforeText: new RegExp(`^${index}\\. .+`),
|
||||||
|
action: { indentAction: languages.IndentAction.None, appendText: `${index + 1}. ` }
|
||||||
|
}))
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
export const language = <languages.IMonarchLanguage>{
|
export const language = <languages.IMonarchLanguage>{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue