Created
January 22, 2015 19:29
-
-
Save hugoware/7927d22b576cb1a4903a to your computer and use it in GitHub Desktop.
Theme via File Path in Sublime Text 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# checks settings and changes the theme depending on the file location | |
# default_folder_theme: string of the theme to use normally | |
# folder_themes: object with key/value of find/theme | |
# ex: { | |
# "trunk": "Packages/User/trunk.tmTheme", | |
# "alt/folder": "Packages/User/darkUi.tmTheme" | |
# } | |
import sublime | |
import sublime_plugin | |
class WindowColorSchemeCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
themeSet = 0 | |
settings = self.view.settings().get("folder_themes") | |
defaultTo = self.view.settings().get("default_folder_theme") | |
# check each defined folder name | |
for ( attr, value ) in settings.items(): | |
# if it's a match, replace the theme | |
if themeSet == 0 and attr != '' and attr in self.view.file_name(): | |
themeSet = 1 | |
self.view.settings().set("color_scheme", value ) | |
# theme wasn't changed - use the default | |
if themeSet == 0: | |
self.view.settings().set("color_scheme", defaultTo ) | |
class WindowColorSchemeEventListener(sublime_plugin.EventListener): | |
def on_load_async(self, view): | |
view.run_command("window_color_scheme") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment