Explicit mapping for langs whose parent are emmet supported #28545

This commit is contained in:
Ramya Achutha Rao
2017-06-20 18:47:31 -07:00
parent 4b2fcb84e5
commit a49a42680a
3 changed files with 46 additions and 36 deletions

View File

@@ -13,6 +13,27 @@ import * as fs from 'fs';
let variablesFromFile = {};
let profilesFromFile = {};
let emmetExtensionsPath = '';
export const LANGUAGE_MODES: Object = {
'html': ['!', '.', '}'],
'jade': ['!', '.', '}'],
'slim': ['!', '.', '}'],
'haml': ['!', '.', '}'],
'xml': ['.', '}'],
'xsl': ['.', '}'],
'javascriptreact': ['.'],
'typescriptreact': ['.'],
'css': [':'],
'scss': [':'],
'sass': [':'],
'less': [':'],
'stylus': [':']
};
// Explicitly map languages to their parent language to get emmet support
export const MAPPED_MODES: Object = {
'handlebars': 'html'
};
export function validate(allowStylesheet: boolean = true): boolean {
let editor = vscode.window.activeTextEditor;
if (!editor) {
@@ -96,6 +117,18 @@ export function getVariables(): any {
return Object.assign({}, variablesFromFile, variablesFromSettings);
}
export function getMappedModes(): any {
let finalMappedModes = {};
let syntaxProfileConfig = vscode.workspace.getConfiguration('emmet')['syntaxProfiles'];
let syntaxProfiles = Object.assign({}, MAPPED_MODES, syntaxProfileConfig ? syntaxProfileConfig : {});
Object.keys(syntaxProfiles).forEach(syntax => {
if (typeof syntaxProfiles[syntax] === 'string' && LANGUAGE_MODES[syntaxProfiles[syntax]]) {
finalMappedModes[syntax] = syntaxProfiles[syntax];
}
});
return finalMappedModes;
}
export function updateExtensionsPath() {
let currentEmmetExtensionsPath = vscode.workspace.getConfiguration('emmet')['extensionsPath'];
if (emmetExtensionsPath !== currentEmmetExtensionsPath) {