Home Download Buy Blog Forum Support

Project-specific activation of plugins and snippets

Project-specific activation of plugins and snippets

Postby Mode7James on Wed Jun 06, 2012 5:04 pm

I want the ability to add plugins to my project manifest. The same goes for code snippets & tags, it would be great if Sublime recognized these files within the project or a select folder or even in the project's includes manifest.

For instance some projects I use jQuery, which there's a great plugin and snippets for, however other projects I may use another conflicting library, where the jQuery syntax conflicts. I know I can switch the syntax based on my file but it would be much easier to just have a list of included snippets and plugins that gets loaded based on the project's config file. This would also allow me to write a plugin that can make a list of all dependent files in a library and create a quick list of tags for project-specific code completion, with support for project-specific included libraries.
Mode7James
 
Posts: 5
Joined: Mon Jun 04, 2012 10:41 am

Re: Project-specific activation of plugins and snippets

Postby Mode7James on Wed Jun 13, 2012 5:50 pm

Nobody has any thoughts on this feature request? I have many external libraries that I'd like to include in my project for code completion, but this is dependent again on the specific project. I would like to write a "external libraries" plugin that allows you to "include" external packages and snippets, but it only applies to that project.
Mode7James
 
Posts: 5
Joined: Mon Jun 04, 2012 10:41 am

Re: Project-specific activation of plugins and snippets

Postby agibsonsw on Thu Jun 14, 2012 12:18 am

Code from Package Control may give some pointers, where it offers the ability to disable or enable certain Packages:

Code: Select all
class DisablePackageCommand(sublime_plugin.WindowCommand):
    def run(self):
        manager = PackageManager()
        packages = manager.list_all_packages()
        self.settings = sublime.load_settings('Global.sublime-settings')
        disabled_packages = self.settings.get('ignored_packages')
        if not disabled_packages:
            disabled_packages = []
        self.package_list = list(set(packages) - set(disabled_packages))
        self.package_list.sort()
        if not self.package_list:
            sublime.error_message(('%s: There are no enabled packages' +
                'to disable.') % __name__)
            return
        self.window.show_quick_panel(self.package_list, self.on_done)

    def on_done(self, picked):
        if picked == -1:
            return
        package = self.package_list[picked]
        ignored_packages = self.settings.get('ignored_packages')
        if not ignored_packages:
            ignored_packages = []
        ignored_packages.append(package)
        self.settings.set('ignored_packages', ignored_packages)
        sublime.save_settings('Global.sublime-settings')
        sublime.status_message(('Package %s successfully added to list of ' +
            'disabled packages - restarting Sublime Text may be required') %
            package)

You could perhaps cause your Packages to be enabled/disabled from a TextCommand. Alternatively, this could be checked using the on_load event; although, this would cause your code to run every time you open a file.

[I apologise if I've misunderstood your question.]

PS I had an ulterior motive in posting my reply, as I wanted to see my name "in lights" :)
"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: Project-specific activation of plugins and snippets

Postby Mode7James on Fri Jul 06, 2012 10:51 pm

agibsonsw wrote:Code from Package Control may give some pointers, where it offers the ability to disable or enable certain Packages:

Code: Select all
class DisablePackageCommand(sublime_plugin.WindowCommand):
    def run(self):
        manager = PackageManager()
        packages = manager.list_all_packages()
        self.settings = sublime.load_settings('Global.sublime-settings')
        disabled_packages = self.settings.get('ignored_packages')
        if not disabled_packages:
            disabled_packages = []
        self.package_list = list(set(packages) - set(disabled_packages))
        self.package_list.sort()
        if not self.package_list:
            sublime.error_message(('%s: There are no enabled packages' +
                'to disable.') % __name__)
            return
        self.window.show_quick_panel(self.package_list, self.on_done)

    def on_done(self, picked):
        if picked == -1:
            return
        package = self.package_list[picked]
        ignored_packages = self.settings.get('ignored_packages')
        if not ignored_packages:
            ignored_packages = []
        ignored_packages.append(package)
        self.settings.set('ignored_packages', ignored_packages)
        sublime.save_settings('Global.sublime-settings')
        sublime.status_message(('Package %s successfully added to list of ' +
            'disabled packages - restarting Sublime Text may be required') %
            package)

You could perhaps cause your Packages to be enabled/disabled from a TextCommand. Alternatively, this could be checked using the on_load event; although, this would cause your code to run every time you open a file.

[I apologise if I've misunderstood your question.]

PS I had an ulterior motive in posting my reply, as I wanted to see my name "in lights" :)


Yeah, I think we'll need to live with something manual for the time being. It would be nice to be able to use Sublime as a foundation for a fully-functional IDE, that can be used with external libraries.
Mode7James
 
Posts: 5
Joined: Mon Jun 04, 2012 10:41 am


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: No registered users and 8 guests