Skip to content

Commit

Permalink
Support for JavaScript formatting in .vue files
Browse files Browse the repository at this point in the history
  • Loading branch information
madskristensen committed Mar 28, 2017
1 parent 523d08e commit 1726bdb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ download in the
These are the changes to each version that has been released
on the official Visual Studio extension gallery.

## 1.1
- [x] Support for JavaScript formatting in .vue files

## 1.0

- [x] Initial release
7 changes: 1 addition & 6 deletions src/HTML/ContentType/VueContentTypeDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,9 @@ namespace VuePack
{
public class VueContentTypeDefinition
{
public const string VueContentType = "Vue";
public const string VueContentType = "htmlx";
private const string VueFileExtension = ".vue";

[Export(typeof(ContentTypeDefinition))]
[Name(VueContentType)]
[BaseDefinition("htmlx")]
public ContentTypeDefinition IVueContentTypeDefinitionContentType { get; set; }

[Export(typeof(FileExtensionToContentTypeDefinition))]
[ContentType(VueContentType)]
[FileExtension(VueFileExtension)]
Expand Down
11 changes: 6 additions & 5 deletions src/HTML/VueCreationListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.TextManager.Interop;
using Microsoft.VisualStudio.Utilities;
using System;

namespace VuePack
{
Expand All @@ -20,7 +21,7 @@ class VueCreationListener : IVsTextViewCreationListener
public IVsEditorAdaptersFactoryService EditorAdaptersFactoryService { get; set; }

[Import]
public ITextDocumentFactoryService TextDocumentFactoryService { get; set; }
public ITextDocumentFactoryService DocumentService { get; set; }

private ITextDocument _document;

Expand All @@ -30,13 +31,13 @@ public void VsTextViewCreated(IVsTextView textViewAdapter)

// Both "Web Compiler" and "Bundler & Minifier" extensions add this property on their
// generated output files. Generated output should be ignored from linting
bool generated;
if (textView.Properties.TryGetProperty("generated", out generated) && generated)
if (textView.Properties.TryGetProperty("generated", out bool generated) && generated)
return;

if (TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out _document))
if (DocumentService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out _document))
{
_document.FileActionOccurred += DocumentSaved;
if (_document.FilePath.EndsWith(".vue", StringComparison.OrdinalIgnoreCase))
_document.FileActionOccurred += DocumentSaved;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/source.extension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ static class Vsix
public const string Name = "Vue.js Pack 2017";
public const string Description = @"Contains HTML Intellisense and code snippets for the Vue.js JavaScript library";
public const string Language = "en-US";
public const string Version = "1.0";
public const string Version = "1.1";
public const string Author = "Mads Kristensen";
public const string Tags = "vue.js, snippets, javascript";
}
Expand Down
2 changes: 1 addition & 1 deletion src/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="4163aa08-9878-4b1c-a1ee-58ab67f7db5b" Version="1.0" Language="en-US" Publisher="Mads Kristensen" />
<Identity Id="4163aa08-9878-4b1c-a1ee-58ab67f7db5b" Version="1.1" Language="en-US" Publisher="Mads Kristensen" />
<DisplayName>Vue.js Pack 2017</DisplayName>
<Description xml:space="preserve">Contains HTML Intellisense and code snippets for the Vue.js JavaScript library</Description>
<MoreInfo>https://github.com/madskristensen/VuePack2017</MoreInfo>
Expand Down

0 comments on commit 1726bdb

Please sign in to comment.