摩纳哥编辑器定义的语言不会括在方括号中

问题描述 投票:1回答:1

这是我定义的摩纳哥语言,不会自动将方括号括起来:在用于初始化语言的参数中,有autoclosingbrackets为“ true”。我也尝试过autoclosingbrackets =“ always”,但不起作用

monaco.languages.setMonarchTokensProvider('CustomExpressionLanguage', {


                brackets: [
                    { open: '{', close: '}', token: 'delimiter.curly' },
                    { open: '[', close: ']', token: 'delimiter.square' },
                    { open: '(', close: ')', token: 'delimiter.parenthesis' },
                    { open: '<', close: '>', token: 'delimiter.angle' }
                ],
                surroundingPairs: [
                    { open: '{', close: '}' },
                    { open: '[', close: ']' },
                    { open: '(', close: ')' },
                    { open: '<', close: '>' },
                    { open: '\'', close: '\'' },
                    { open: '"', close: '"' },
                ],
                autoClosingPairs: [
                    { open: '{', close: '}' },
                    { open: '[', close: ']' },
                    { open: '(', close: ')' },
                    { open: '\'', close: '\'', notIn: ['string', 'comment'] },
                    { open: '"', close: '"', notIn: ['string', 'comment'] },
                ],

            });
monaco-editor
1个回答
0
投票
我相信您正在寻找的方法setLanguageConfiguration

此外,我不确定这是否是配置brackets的正确方法。

这是一个可行的示例

const config = { surroundingPairs: [ { open: '{', close: '}' }, { open: '[', close: ']' }, { open: '(', close: ')' }, { open: '<', close: '>' }, { open: "'", close: "'" }, { open: '"', close: '"' }, ], autoClosingPairs: [ { open: '{', close: '}' }, { open: '[', close: ']' }, { open: '(', close: ')' }, { open: "'", close: "'", notIn: ['string', 'comment'] }, { open: '"', close: '"', notIn: ['string', 'comment'] }, ], }; monaco.languages.setLanguageConfiguration('YOUR_CUSTOM_LANGUAGE', config);
© www.soinside.com 2019 - 2024. All rights reserved.