alek-sys / sublimetext_indentxml

Plugin for Sublime Text editor for reindenting XML and JSON files
MIT License
534 stars 136 forks source link

[Feature] Add NuGet support #97

Closed Kristinita closed 7 years ago

Kristinita commented 7 years ago

Add NuGet syntax support for NuGet and Chocolatey Windows package managers.

Thanks.

alek-sys commented 7 years ago

Plugin auto-detects type of the content by checking starting symbol, < indicates that this could be XML so it tries to format it. Just open the file, select nothing, and run 'Indent XML' command.

So thanks for your effort, but I don't think hard-coding all possible extensions for XML-based files is a good idea. Especially for platform-dependent formats, like nuget. Also, I'm not sure about the extension - AFAIK nuget uses .config, not .nuget. So sorry, but I'd prefer not merge it.

You might be interested in auto-mapping file extension to a certain syntax in Sublime - please take a look here

Kristinita commented 7 years ago

@alek-sys

You might be interested in auto-mapping file extension to a certain syntax in Sublime - please take a look here

Thanks, I know about automatic set syntax, see my answers in Russian Stack Overflow and Toster.

Just open the file, select nothing, and run 'Indent XML' command.

In my nuspec files in NuGet syntax I run command auto_indent → I get bad prettify result. And I can not run command indent_xml in my nuspec files without my changes.

All right, maybe you add option for non-default XML and JSON syntax? If users wanted indent their files in their syntax like default XML or JSON, they may add syntax for yourself.

For example,

"additional_xml_indent_syntax_paths": ["Packages\\NuGet\\NuGet.sublime-syntax", "Packages\\Example\\Example.sublime-syntax"].

Thanks.

alek-sys commented 7 years ago

As I mentioned, file extension is not that critical - even if extension is unknown and you try to run 'auto indent' command - plugin will try to do its best to identify file type (not just by extension).

So probably there is something wrong with the file itself, if you can share it - I'll try to take a look.

Kristinita commented 7 years ago

For example, I have nuspec file:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
  <metadata>
    <id>mega</id>
    <version>2.9.10</version>
    <title>MEGAsync</title>
    <authors>MEGA Limited</authors>
    <owners>Sasha_Chernykh</owners>
    <licenseUrl>https://mega.nz/#terms</licenseUrl>
    <projectUrl>https://mega.nz/</projectUrl>
    <iconUrl>https://cdn.rawgit.com/Kristinita/SashaChocolatey/master/icons/MEGA.png</iconUrl>
    <packageSourceUrl>https://github.com/Kristinita/SashaChocolatey/tree/master/packages/MEGA</packageSourceUrl>
    <docsUrl>https://mega.nz/#doc</docsUrl>
    <mailingListUrl>https://mega.nz/#contact</mailingListUrl>
    <bugTrackerUrl>https://github.com/meganz/MEGAsync/issues</bugTrackerUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <summary>MEGA is a cloud storage and file hosting service. 50 GB free.</summary>
    <description>When MEGA launched early 2013, global mass surveillance by rogue governments under the pretext of fighting terrorism was still a wild conjecture and its proponents were often touted as conspiracy theorists. Edward Snowden's revelations 137 days later fundamentally changed public attitudes and it became excruciatingly clear that security by policy ("we have access to your data, but we promise to keep it confidential and not misuse it") had not been good enough. Anything short of security by design ("we cannot gain access to your data without you being able to find out"), for which strong end-to-end encryption is an essential prerequisite, now seems grossly insufficient.</description>
    <releaseNotes>
    + Support to download/import folder links  
    + Automatic HTTP/HTTPS proxy detection on OS X  
    + Better compatibility with antivirus software  
    + HDPI support for Linux distros having QT >= 5.6  
    + Other bug fixes and minor improvements  </releaseNotes>
    <copyright>Copyright © 2016 year Mega Limited</copyright>
    <tags>mega file-hosting cloud-storage admin</tags>
        <dependencies>
      <dependency id="autohotkey.portable" />
</dependencies>
  </metadata>
    <files>
          <file src="tools\**" target="tools" />
    </files>
</package>

Unprettified lines:

        <dependencies>
      <dependency id="autohotkey.portable" />
</dependencies>

If NuSpec syntax enable for me and I select Auto Indent, these lines not prettify for me. But if XML syntax enable for me and I select Indent XML, these lines successfully prettify for me.

Demonstration:

Demonstration

Thanks.

Kristinita commented 7 years ago

@alek-sys , actually.

Thanks.