Home Download Buy Blog Forum Support

PlistJsonConverter

PlistJsonConverter

Postby facelessuser on Sun Apr 01, 2012 1:42 pm

I always hear people asking about how to convert a plist (tmLanguage, color scheme, etc), so I created a generic plugin to simply toggle your view between plist to json. It assumes that the files of either type are "UTF8", so keep that in mind. It also just operates on the view buffer, so you can toggle back and forth, and then save the file name as whatever you want.

If you like to work in JSON, that is fine. I even allow you to use C style comments in your JSON (they will be removed on conversion back to plist, and vice versa for HTML/XML comments in your plist XML). I also try to catch trailing JSON commas on conversion (those always get me :) ) to plist as well.

Conversion of PHP tmLanguage as an example
Screen Shot 2012-04-01 at 7.28.36 AM.png
Screen Shot 2012-04-01 at 7.28.36 AM.png (152.52 KiB) Viewed 5609 times


Repository: https://github.com/facelessuser/PlistJsonConverter
facelessuser
 
Posts: 1576
Joined: Tue Apr 05, 2011 7:38 pm

Re: PlistJsonConverter

Postby agibsonsw on Sun Apr 01, 2012 3:00 pm

Excuse my naiveté, but how do I install these files? I'm on build 2181 and I managed to find the Zip download button :)

In particular, where do I place the 'Default.sublime-settings'?
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: PlistJsonConverter

Postby C0D312 on Sun Apr 01, 2012 3:04 pm

Just put it all in a folder in the Packages directory.
C0D312
 
Posts: 1063
Joined: Sun Jul 10, 2011 3:23 am

Re: PlistJsonConverter

Postby facelessuser on Sun Apr 01, 2012 3:21 pm

Make sure that when you copy it to the package folder, the folder is named "PlistJsonConverter". Github will name the folder in the zip something dumb like "facelessuser-PlistJsonConverter-123456" etc.
facelessuser
 
Posts: 1576
Joined: Tue Apr 05, 2011 7:38 pm

Re: PlistJsonConverter

Postby agibsonsw on Sun Apr 01, 2012 3:27 pm

C0D312 wrote:Just put it all in a folder in the Packages directory.


Hi. Thank you. I managed to install it ;). I placed the settings and 'Default.sublime-commands' in my existing files, as i wasn't keen to have two files with the same name.

My 'Python.tmLanguage' dropped from 3 to 2000 lines! (Still many more than the JS version though.)

It displays a load of redundant \n\t\t - this is good as it's best to delete them.

I would prefer that it create a new tab though :)
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: PlistJsonConverter

Postby facelessuser on Sun Apr 01, 2012 6:11 pm

agibsonsw wrote:Hi. Thank you. I managed to install it ;). I placed the settings and 'Default.sublime-commands' in my existing files, as i wasn't keen to have two files with the same name.


That is just how plugins add commands to the command palette. You can override them in your Packages/User folder, but I would leave it in the plugin folder. As soon as I add this to Package Control. It is always going to be updated there.

agibsonsw wrote:I would prefer that it create a new tab though :)

Yeah, I can add an option for opening it in a new buffer. That is no biggie.
facelessuser
 
Posts: 1576
Joined: Tue Apr 05, 2011 7:38 pm

Re: PlistJsonConverter

Postby quodlibet on Sun Apr 01, 2012 6:43 pm

I too was unsatisfied with AAAPackageDev and, following your ScopeHunter, this plugin couldn't have come at a better time. Thanks for putting together such wonderful tools.

That said, the workflow is not ideal, although it may simpler for folks who aren't (as I am) learning regular expressions at the same time.

(The fastest process I found for what I was doing earlier was editing the JSON file, copying & pasting the contents into the .tmLanguage file, converting via the palette, saving, and then flipping back to my test document to see the horrors I had wrought.)

Would it be possible to use sublime's build system with this plugin?
quodlibet
 
Posts: 561
Joined: Sat Jun 18, 2011 5:53 pm

Re: PlistJsonConverter

Postby facelessuser on Sun Apr 01, 2012 7:15 pm

quodlibet wrote:I too was unsatisfied with AAAPackageDev and, following your ScopeHunter, this plugin couldn't have come at a better time. Thanks for putting together such wonderful tools.

That said, the workflow is not ideal, although it may simpler for folks who aren't (as I am) learning regular expressions at the same time.

(The fastest process I found for what I was doing earlier was editing the JSON file, copying & pasting the contents into the .tmLanguage file, converting via the palette, saving, and then flipping back to my test document to see the horrors I had wrought.)

Would it be possible to use sublime's build system with this plugin?


Is it that you just want it to convert, create, and save the plist or json file, opposed to just converting? I just need to understand the specifics before I can do any implementation.
facelessuser
 
Posts: 1576
Joined: Tue Apr 05, 2011 7:38 pm

Re: PlistJsonConverter

Postby quodlibet on Sun Apr 01, 2012 7:29 pm

facelessuser wrote:Is it that you just want it to convert, create, and save the plist or json file, opposed to just converting? I just need to understand the specifics before I can do any implementation.


I'm not sure :?

I find it simpler (thus far) to write syntax files in JSON rather than plist. So I *think* what I am looking for is to convert "XXX.tmLanguage.JSON" to "XXX.tmLanguage" with the minimum of fuss.

There may be an external tool I can use for this that I am not aware of. I've had trouble with AAAPackageDev, but it may be better to work with guilermooo to resolve the issues there. On the other hand, if it seems a worthwhile addition to what you are trying to build, what I'm looking is for Ctrl+B to convert.

I hope some of the above makes sense :)
quodlibet
 
Posts: 561
Joined: Sat Jun 18, 2011 5:53 pm

Re: PlistJsonConverter

Postby facelessuser on Sun Apr 01, 2012 7:54 pm

This is why I am asking. If it is just you want to convert XXX.tmLanguage.JSON to XXX.tmLanguage; I don't think a build system is really needed, I can easily add it the plugin, and you can bind it to whatever key combo you want or just access it from the command palette.

Either a command or build system can be implemented though. I don't mind adding more in depth features, or even build systems. I currently don't plan on using AAAPackageDev, so having some standalone plugins to do commonly desired things is what I am aiming for; that way you can pick and choose what you want, and each one can be even more specialized in what they do, because that is all they will do. This plugin is a bit more flexible because it can do any plist you like: tmTheme, tmLanguages, tmPreference, etc.

I personally like the toggle, because I can just toggle it to json, make changes, and toggle back and save. But if you want to keep the json like a source code file, and the tmLanguage like the compiled code, that can be done by a simple command (no build system required). If you want to search an entire project, then maybe a build system would be helpful, but I still don't think it would be necessary. Build systems are better for feeding an external executable that does some compile stuff with project variables.

I will play around with some ideas, and see what I can cook up, maybe even a build system :).
facelessuser
 
Posts: 1576
Joined: Tue Apr 05, 2011 7:38 pm

Next

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 14 guests