From 5e63c6bd4df841dca16bd1f9f6ca45c6a8b32ddd Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Mon, 22 Aug 2016 17:11:32 -0700 Subject: [PATCH] Support *.pug extension for Jade Templates **Bug** The Jade was renamed Pug, and they no longer support `*.jade` files natively. NTVS only supports `*.jade` files **Fix** As first part of Jade -> Pug update, add support to use jade editor for both `*.jade` and `*.pug` files. --- .../Nodejs/Jade/JadeContentTypeDefinition.cs | 9 +++++++ .../Product/Nodejs/Jade/JadeLanguageInfo.cs | 2 +- Nodejs/Product/Nodejs/NodejsPackage.cs | 2 ++ .../Project/ImportWizard/ImportSettings.cs | 24 ++++++++++++++++++- 4 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Nodejs/Product/Nodejs/Jade/JadeContentTypeDefinition.cs b/Nodejs/Product/Nodejs/Jade/JadeContentTypeDefinition.cs index f231b088b..8d90175e0 100644 --- a/Nodejs/Product/Nodejs/Jade/JadeContentTypeDefinition.cs +++ b/Nodejs/Product/Nodejs/Jade/JadeContentTypeDefinition.cs @@ -25,6 +25,7 @@ class JadeContentTypeDefinition { public const string JadeLanguageName = "Jade"; public const string JadeContentType = "jade"; public const string JadeFileExtension = ".jade"; + public const string PugFileExtension = ".pug"; /// /// Exports the Jade content type @@ -41,5 +42,13 @@ class JadeContentTypeDefinition { [ContentType(JadeContentType)] [FileExtension(JadeFileExtension)] public FileExtensionToContentTypeDefinition IJadeFileExtension { get; set; } + + /// + /// Exports the Pug file extension + /// + [Export(typeof(FileExtensionToContentTypeDefinition))] + [ContentType(JadeContentType)] + [FileExtension(PugFileExtension)] + public FileExtensionToContentTypeDefinition IPugFileExtension { get; set; } } } diff --git a/Nodejs/Product/Nodejs/Jade/JadeLanguageInfo.cs b/Nodejs/Product/Nodejs/Jade/JadeLanguageInfo.cs index 7fb8f9fd7..1a1bad458 100644 --- a/Nodejs/Product/Nodejs/Jade/JadeLanguageInfo.cs +++ b/Nodejs/Product/Nodejs/Jade/JadeLanguageInfo.cs @@ -30,7 +30,7 @@ public int GetColorizer(IVsTextLines pBuffer, out IVsColorizer ppColorizer) { } public int GetFileExtensions(out string pbstrExtensions) { - pbstrExtensions = JadeContentTypeDefinition.JadeFileExtension; + pbstrExtensions = string.Join(";", new[] { JadeContentTypeDefinition.JadeFileExtension, JadeContentTypeDefinition.PugFileExtension }); return VSConstants.S_OK; } diff --git a/Nodejs/Product/Nodejs/NodejsPackage.cs b/Nodejs/Product/Nodejs/NodejsPackage.cs index 55a9518dc..8882c2c2b 100644 --- a/Nodejs/Product/Nodejs/NodejsPackage.cs +++ b/Nodejs/Product/Nodejs/NodejsPackage.cs @@ -86,8 +86,10 @@ namespace Microsoft.NodejsTools { [ProvideTextEditorAutomation(NodejsConstants.Nodejs, 106, 102, ProfileMigrationType.PassThrough)] [ProvideLanguageService(typeof(JadeLanguageInfo), JadeContentTypeDefinition.JadeLanguageName, 3041, RequestStockColors = true, ShowSmartIndent = false, ShowCompletion = false, DefaultToInsertSpaces = true, HideAdvancedMembersByDefault = false, EnableAdvancedMembersOption = false, ShowDropDownOptions = false)] [ProvideEditorExtension2(typeof(JadeEditorFactory), JadeContentTypeDefinition.JadeFileExtension, 50, __VSPHYSICALVIEWATTRIBUTES.PVA_SupportsPreview, "*:1", ProjectGuid = VSConstants.CLSID.MiscellaneousFilesProject_string, NameResourceID = 3041, EditorNameResourceId = 3045)] + [ProvideEditorExtension2(typeof(JadeEditorFactory), JadeContentTypeDefinition.PugFileExtension, 50, __VSPHYSICALVIEWATTRIBUTES.PVA_SupportsPreview, "*:1", ProjectGuid = VSConstants.CLSID.MiscellaneousFilesProject_string, NameResourceID = 3041, EditorNameResourceId = 3045)] [ProvideEditorLogicalView(typeof(JadeEditorFactory), VSConstants.LOGVIEWID.TextView_string)] [ProvideLanguageExtension(typeof(JadeEditorFactory), JadeContentTypeDefinition.JadeFileExtension)] + [ProvideLanguageExtension(typeof(JadeEditorFactory), JadeContentTypeDefinition.PugFileExtension)] [ProvideTextEditorAutomation(JadeContentTypeDefinition.JadeLanguageName, 3041, 3045, ProfileMigrationType.PassThrough)] [ProvideLanguageEditorOptionPage(typeof(NodejsFormattingSpacingOptionsPage), NodejsConstants.Nodejs, "Formatting", "Spacing", "3042")] [ProvideLanguageEditorOptionPage(typeof(NodejsFormattingBracesOptionsPage), NodejsConstants.Nodejs, "Formatting", "Braces", "3043")] diff --git a/Nodejs/Product/Nodejs/Project/ImportWizard/ImportSettings.cs b/Nodejs/Product/Nodejs/Project/ImportWizard/ImportSettings.cs index 71bed5b81..6088d54ff 100644 --- a/Nodejs/Product/Nodejs/Project/ImportWizard/ImportSettings.cs +++ b/Nodejs/Product/Nodejs/Project/ImportWizard/ImportSettings.cs @@ -30,12 +30,34 @@ namespace Microsoft.NodejsTools.Project.ImportWizard { internal class ImportSettings : DependencyObject { + public static readonly string DefaultLanguageExtensionsFilter = string.Join(";", + new[] { + ".txt", + ".htm", + ".html", + ".css", + ".png", + ".jpg", + ".gif", + ".bmp", + ".ico", + ".svg", + ".json", + ".md", + ".ejs", + ".styl", + ".xml", + ".ts", + Jade.JadeContentTypeDefinition.JadeFileExtension, + Jade.JadeContentTypeDefinition.PugFileExtension + }.Select(x => "*" + x)); + private bool _isAutoGeneratedProjectPath; public ImportSettings() { TopLevelJavaScriptFiles = new BulkObservableCollection(); - Filters = "*.txt;*.htm;*.html;*.css;*.png;*.jpg;*.gif;*.bmp;*.ico;*.svg;*.json;*.md;*.ejs;*.styl;*.jade;*.xml;*.ts"; + Filters = DefaultLanguageExtensionsFilter; } public string ProjectPath {