mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 20:52:56 +01:00
Move language definition and configuration to monaco-languages
This commit is contained in:
parent
ff503e756e
commit
ad61b15585
2 changed files with 4 additions and 100 deletions
|
|
@ -13,84 +13,7 @@ import Promise = monaco.Promise;
|
|||
import Uri = monaco.Uri;
|
||||
import IDisposable = monaco.IDisposable;
|
||||
|
||||
export function setupCSS(defaults:LanguageServiceDefaultsImpl): void {
|
||||
const cssLanguageConfiguration: monaco.languages.LanguageConfiguration = {
|
||||
wordPattern: /(#?-?\d*\.\d\w*%?)|((::|[@#.!:])?[\w-?]+%?)|::|[@#.!:]/g,
|
||||
|
||||
comments: {
|
||||
blockComment: ['/*', '*/']
|
||||
},
|
||||
|
||||
brackets: [
|
||||
['{', '}'],
|
||||
['[', ']'],
|
||||
['(', ')']
|
||||
],
|
||||
|
||||
autoClosingPairs: [
|
||||
{ open: '{', close: '}' },
|
||||
{ open: '[', close: ']' },
|
||||
{ open: '(', close: ')' },
|
||||
{ open: '"', close: '"', notIn: ['string'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string'] }
|
||||
]
|
||||
};
|
||||
|
||||
setupMode(
|
||||
defaults,
|
||||
cssLanguageConfiguration
|
||||
);
|
||||
}
|
||||
|
||||
export function setupLESS(defaults:LanguageServiceDefaultsImpl): void {
|
||||
const lessLanguageConfiguration: monaco.languages.LanguageConfiguration = {
|
||||
wordPattern: /(#?-?\d*\.\d\w*%?)|([@#!.:]?[\w-?]+%?)|[@#!.]/g,
|
||||
comments: {
|
||||
blockComment: ['/*', '*/'],
|
||||
lineComment: '//'
|
||||
},
|
||||
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
|
||||
autoClosingPairs: [
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: '{', close: '}', notIn: ['string', 'comment'] },
|
||||
{ open: '[', close: ']', notIn: ['string', 'comment'] },
|
||||
{ open: '(', close: ')', notIn: ['string', 'comment'] },
|
||||
{ open: '<', close: '>', notIn: ['string', 'comment'] },
|
||||
]
|
||||
};
|
||||
|
||||
setupMode(
|
||||
defaults,
|
||||
lessLanguageConfiguration
|
||||
);
|
||||
}
|
||||
|
||||
export function setupSCSS(defaults:LanguageServiceDefaultsImpl): void {
|
||||
const scssLanguageConfiguration: monaco.languages.LanguageConfiguration = {
|
||||
wordPattern: /(#?-?\d*\.\d\w*%?)|([@#!.:]?[\w-?]+%?)|[@#!.]/g,
|
||||
comments: {
|
||||
blockComment: ['/*', '*/'],
|
||||
lineComment: '//'
|
||||
},
|
||||
brackets: [['{','}'], ['[',']'], ['(',')'], ['<','>']],
|
||||
autoClosingPairs: [
|
||||
{ open: '"', close: '"', notIn: ['string', 'comment'] },
|
||||
{ open: '\'', close: '\'', notIn: ['string', 'comment'] },
|
||||
{ open: '{', close: '}', notIn: ['string', 'comment'] },
|
||||
{ open: '[', close: ']', notIn: ['string', 'comment'] },
|
||||
{ open: '(', close: ')', notIn: ['string', 'comment'] },
|
||||
{ open: '<', close: '>', notIn: ['string', 'comment'] },
|
||||
]
|
||||
};
|
||||
|
||||
setupMode(
|
||||
defaults,
|
||||
scssLanguageConfiguration
|
||||
);
|
||||
}
|
||||
|
||||
function setupMode(defaults:LanguageServiceDefaultsImpl, languageConfiguration: monaco.languages.LanguageConfiguration): void {
|
||||
export function setupMode(defaults:LanguageServiceDefaultsImpl): void {
|
||||
|
||||
let disposables: IDisposable[] = [];
|
||||
|
||||
|
|
@ -111,7 +34,6 @@ function setupMode(defaults:LanguageServiceDefaultsImpl, languageConfiguration:
|
|||
disposables.push(monaco.languages.registerDocumentSymbolProvider(languageId, new languageFeatures.DocumentSymbolAdapter(worker)));
|
||||
disposables.push(monaco.languages.registerRenameProvider(languageId, new languageFeatures.RenameAdapter(worker)));
|
||||
disposables.push(new languageFeatures.DiagnostcsAdapter(languageId, worker));
|
||||
disposables.push(monaco.languages.setLanguageConfiguration(languageId, languageConfiguration));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -88,32 +88,14 @@ function withMode(callback:(module:typeof mode)=>void): void {
|
|||
require<typeof mode>(['vs/language/css/cssMode'], callback);
|
||||
}
|
||||
|
||||
monaco.languages.register({
|
||||
id: 'less',
|
||||
extensions: ['.less'],
|
||||
aliases: ['Less', 'less'],
|
||||
mimetypes: ['text/x-less', 'text/less']
|
||||
});
|
||||
monaco.languages.onLanguage('less', () => {
|
||||
withMode((mode) => mode.setupLESS(lessDefaults));
|
||||
withMode(mode => mode.setupMode(lessDefaults));
|
||||
});
|
||||
|
||||
monaco.languages.register({
|
||||
id: 'scss',
|
||||
extensions: ['.scss'],
|
||||
aliases: ['Sass', 'sass', 'scss'],
|
||||
mimetypes: ['text/x-scss', 'text/scss']
|
||||
});
|
||||
monaco.languages.onLanguage('scss', () => {
|
||||
withMode((mode) => mode.setupSCSS(scssDefaults));
|
||||
withMode(mode => mode.setupMode(scssDefaults));
|
||||
});
|
||||
|
||||
monaco.languages.register({
|
||||
id: 'css',
|
||||
extensions: ['.css'],
|
||||
aliases: ['CSS', 'css'],
|
||||
mimetypes: ['text/css']
|
||||
});
|
||||
monaco.languages.onLanguage('css', () => {
|
||||
withMode((mode) => mode.setupCSS(cssDefaults));
|
||||
withMode(mode => mode.setupMode(cssDefaults));
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue