Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make emmet.syntaxProfiles configuration item to support custom language Id #95

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/emmetHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ import { parseSnippets, SnippetsMap, syntaxes } from './configCompat';
export { FileService, FileType, FileStat };

let l10n: { t: (message: string) => string };
let getProfileOfCurrentLanguageId = (profilesConfig: any) => null;
try {
l10n = require('vscode').l10n;
var vscode = require('vscode');
l10n = vscode.l10n;
getProfileOfCurrentLanguageId = (profilesConfig: any) => profilesConfig[vscode.window.activeTextEditor.document.languageId];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this section only run right when the package is loaded?
To override the use of profilesConfig[syntax], you might have to change the getProfile API or provide a new one.

} catch {
// Fallback to the identity function.
l10n = {
Expand Down Expand Up @@ -851,7 +854,7 @@ function getProfile(syntax: string, profilesFromSettings: any): any {
}
const profilesConfig = Object.assign({}, profilesFromFile, profilesFromSettings);

const options = profilesConfig[syntax];
const options = getProfileOfCurrentLanguageId(profilesConfig) || profilesConfig[syntax];
if (!options || typeof options === 'string') {
if (options === 'xhtml') {
return {
Expand Down