lattespirit / sublime-wrapper

A Sublime Text 3 Plugin which Wraps Contents With Specific Code
9 stars 0 forks source link

Enhancement: Simplify JSON structure. #7

Open pykong opened 7 years ago

pykong commented 7 years ago

1) Put name, description, and template into a single object. Currently, the template definition is separated from its name and description which makes editing error prone.

2) Also, it would be best to keep the structure into a single string. In contrast, the current version separates them into several blocks. The purpose of this is not clear to me. A very simple plugin like the one posted below is fully able to output a well-formed python if-else, from a single template string.

3) With explicit keys like "syntaxes", "wrappers", "name" the JSON would be easier to maintain and expand.

JSON structure proposal:

[
  {
    "syntaxes": [
      "Packages/Python/Python.sublime-syntax",
      "Packages/Python 3/Python3.tmLanguage",
      "Packages/Python Improved/PythonImproved.tmLanguage",
      "Packages/MagicPython/grammars/MagicPython.tmLanguage"
    ],
    "wrappers": [
      {
        "name": "if / else",
        "description": "Wrap with: if - else block",
        "template": "if {CARET}:\n\t{SELECTION}\nelse:\n\t...\n"
      }
    ]
  }
]

Plugin example:

import sublime
import sublime_plugin

class InsertTestCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.insert(edit, 0, "if ():\n\t...\nelse:\n\t...\n")
lattespirit commented 7 years ago

@bfelder All i know about Python is in this site and i finished this plugin in several days after taking a glance of that tutorial. I do know that a lot of work need to be done to refactor the major code. Maybe one day i have a deeper learning Python and will do this work.

pykong commented 7 years ago

@lattespirit You did very great with writing that plugin. No need to diminish your python skills here! Your answer implies you see the value in my suggestions. Yet, you are reluctant to implement them. So, here is the thing: If I did the rewrite of the plugin, are you willing to run some tests to verify its working correctly and also maintain it as a plugin on PackageControl? Otherwise, I may just create an independent fork, an option I do not favor.

lattespirit commented 7 years ago

@bfelder Your suggestions are great and i appreciate that. Actually i don't have too much time to maintain and do more refactoring for this plugin recently. But i will make this plugin more configurable and powerful in the future. If you want to make this plugin fit your work flow, create an independent repo is also a good choice. Thanks.

pykong commented 7 years ago

@lattespirit You may want to make me a co-maintainer of the package then. If you do not have that much time to contribute yourself this would be the best choice. It also better to end up with two very similar plugins on PackageControl. Such split is always discouraged by guide lines and common sense. I have already become the co-maintainer of MaxPane another plugin by the author of the famous GitGutter and also for FocusFileOnSideBar. Tell me what you think.

lattespirit commented 7 years ago

@bfelder if your idea and work serve more people and that's a great news. I can even remove my package from PackageControl for Sublime user. That's totally fine. :smile:

pykong commented 7 years ago

@lattespirit That is very honorable of you! Very much in the spirit of open source. :+1: By far the easiest way to do so would be to just transfer ownership of the repo to me. In that case, I can keep you as a co-maintainer if you wish to stay in contact with your repo. Here is a link to describe the process: Ownership transfer I vow to make the very best out of the great work you have already provided. Again your choice. You decide

pykong commented 7 years ago

@lattespirit I just finished a complete rewrite of the wrapper. Based on your awesome work, we now have the most powerful text wrapping tool for Sublime at our disposal! The wrapper definitions are now part of the settings file and can be very easily expanded by the user. In addition to choice by the quick panel, it is now also possible to define key bindings for your favorite wrappings. This really brings sublime-wrapper to the next level. Check it out here: WrapThis