Question

How can I make a package-specific setting differ by language? It's easy to make general Sublime Text settings differ by language (e.g., I can use Python.sublime-settings to set the number of spaces to indent specific to Python). But I can't figure out how to change a setting for a particular package (whose settings seem to live in a different scope from the general application settings).

What I'm trying to do in particular is to change the "show_transferred_text" parameter in SublimeREPL. In R I need this to be "false" and in Python I need it to be "true." Is there something I can add to the line "show_transferred_text": true in my Python.sublime-settings to indicate that this is a parameter for SublimeREPL? Setting it like that doesn't change the SublimeREPL parameter, again I assume because package-specific settings are in a different scope.

This provides a start that would allow me to write a plugin to do this, but I wonder if it's already supported more simply in ST. Is there a package scope or something that I can add to a key that might let me set package keys directly?

Était-ce utile?

La solution

Well, I went ahead and wrote a short plugin to do this. In case anyone else needs to do something like this, it's straightforward to modify. It's just an extension of EventListener that gets called each time focus changes. This is my first foray into the ST API, so if anyone sees this and knows ways to make it simpler/cleaner, let me know!

import sublime, sublime_plugin

class PythonREPLHelperCommand(sublime_plugin.EventListener):
  def on_activated(self, view):
    syntax = view.settings().get('syntax')
    if syntax=='Packages/Python/Python.tmLanguage':
      plugin_settings = sublime.load_settings('SublimeREPL.sublime-settings')
      plugin_settings.set("show_transferred_text", True)
    else:
      plugin_settings = sublime.load_settings('SublimeREPL.sublime-settings')
      plugin_settings.set("show_transferred_text", False)

But I'd still love to know if it's possible to do this without a plugin!

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top