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

@@ -15,23 +15,9 @@ import { mergeLines } from './mergeLines';
import { toggleComment } from './toggleComment';
import { fetchEditPoint } from './editPoint';
import { fetchSelectItem } from './selectItem';
import { updateExtensionsPath } from './util';
import { updateExtensionsPath, LANGUAGE_MODES, getMappedModes } from './util';
const LANGUAGE_MODES: Object = {
'html': ['!', '.', '}'],
'jade': ['!', '.', '}'],
'slim': ['!', '.', '}'],
'haml': ['!', '.', '}'],
'xml': ['.', '}'],
'xsl': ['.', '}'],
'javascriptreact': ['.'],
'typescriptreact': ['.'],
'css': [':'],
'scss': [':'],
'sass': [':'],
'less': [':'],
'stylus': [':']
};
export function activate(context: vscode.ExtensionContext) {
let completionProvider = new EmmetCompletionItemProvider();
@@ -41,16 +27,12 @@ export function activate(context: vscode.ExtensionContext) {
});
let completionProviderForMappedSyntax = new EmmetCompletionItemProvider(true);
let emmetConfig = vscode.workspace.getConfiguration('emmet');
if (emmetConfig && emmetConfig['syntaxProfiles']) {
let syntaxProfiles = emmetConfig['syntaxProfiles'];
Object.keys(syntaxProfiles).forEach(syntax => {
if (typeof syntaxProfiles[syntax] === 'string' && LANGUAGE_MODES[syntaxProfiles[syntax]]) {
const provider = vscode.languages.registerCompletionItemProvider(syntax, completionProviderForMappedSyntax, ...LANGUAGE_MODES[syntaxProfiles[syntax]]);
context.subscriptions.push(provider);
}
});
}
let mappedModes = getMappedModes();
Object.keys(mappedModes).forEach(syntax => {
const provider = vscode.languages.registerCompletionItemProvider(syntax, completionProviderForMappedSyntax, ...LANGUAGE_MODES[mappedModes[syntax]]);
context.subscriptions.push(provider);
});
context.subscriptions.push(vscode.commands.registerCommand('emmet.wrapWithAbbreviation', () => {
wrapWithAbbreviation();