Sublime Forum

Project-specific activation of plugins and snippets

#1

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.

0 Likes

#2

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.

0 Likes

#3

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

[code]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)[/code]

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.

PS I had an ulterior motive in posting my reply, as I wanted to see my name “in lights” :smile:*

0 Likes

#4

[quote=“agibsonsw”]Code from Package Control may give some pointers, where it offers the ability to disable or enable certain Packages:

[code]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)[/code]

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.

PS I had an ulterior motive in posting my reply, as I wanted to see my name “in lights” :smile:*

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.[/quote]

0 Likes