Python sublime.load_settings() Examples
The following are 30
code examples of sublime.load_settings().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
sublime
, or try the search function
.
Example #1
Source File: dired.py From dired with MIT License | 6 votes |
def run(self, edit): settings = sublime.load_settings('dired.sublime-settings') for key_name in ['reuse_view', 'bookmarks']: settings.set(key_name, settings.get(key_name)) bm = bookmarks() def on_done(select) : if not select == -1 : bm.pop(select) sublime.status_message('Remove selected bookmark.') settings.set('bookmarks', bm) sublime.save_settings('dired.sublime-settings') self.view.window().show_quick_panel(bm, on_done)
Example #2
Source File: util.py From SalesforceXyTools with Apache License 2.0 | 6 votes |
def sf_oauth2(sf_basic_config): sublconsole = SublConsole(sf_basic_config) settings = sf_basic_config.get_setting() from SalesforceXyTools.libs import auth project_setting = settings # project_setting = settings["default_project_value"] is_sandbox = project_setting["is_sandbox"] if refresh_token(sf_basic_config): return server_info = sublime.load_settings("sfdc.server.sublime-settings") client_id = server_info.get("client_id") client_secret = server_info.get("client_secret") redirect_uri = server_info.get("redirect_uri") oauth = auth.SalesforceOAuth2(client_id, client_secret, redirect_uri, is_sandbox) authorize_url = oauth.authorize_url() sublconsole.debug('authorize_url-->') sublconsole.debug(authorize_url) start_server() open_in_default_browser(sf_basic_config, authorize_url)
Example #3
Source File: gutter_color.py From GutterColor with MIT License | 6 votes |
def fix_scheme_in_settings(settings_file,current_scheme, new_scheme, regenerate=False): """Change the color scheme in the given Settings to a background-corrected one""" from os.path import join, normpath, isfile settings = load_settings(settings_file) settings_scheme = settings.get("color_scheme") if current_scheme == settings_scheme: new_scheme_path = join(packages_path(), normpath(new_scheme[len("Packages/"):])) if isfile(new_scheme_path) and not regenerate: settings.set("color_scheme", new_scheme) else: generate_scheme_fix(current_scheme, new_scheme_path) settings.set("color_scheme", new_scheme) save_settings(settings_file) return True return False
Example #4
Source File: listener.py From network_tech with Apache License 2.0 | 6 votes |
def run(self, edit): settings = sublime.load_settings(SETTINGS_FILE_NAME) network_info_on_hover = settings.get(NETWORK_INFO_ON_HOVER_SETTING_NAME, True) print(network_info_on_hover) settings.set(NETWORK_INFO_ON_HOVER_SETTING_NAME, not network_info_on_hover) sublime.save_settings(SETTINGS_FILE_NAME) setting_status = 'ON' if not network_info_on_hover else 'OFF' set_status = 'Network Info Popup: {}'.format(setting_status) def clear_status(): current_status = self.view.get_status(STATUS_KEY) if set_status == current_status: self.view.erase_status(STATUS_KEY) self.view.set_status(STATUS_KEY, set_status) sublime.set_timeout_async(clear_status, 4000)
Example #5
Source File: hound.py From SublimeHound with MIT License | 6 votes |
def run(self, edit): self.settings = sublime.load_settings(SETTINGS) self.hound_url = self.settings.get("hound_url").rstrip("/") self.github_base_url = self.settings.get("github_base_url") self.exclude_repos = set(self.settings.get("exclude_repos", [])) self.custom_headers = self.settings.get("custom_headers", {}) self.debug = self.settings.get("debug", False) if self.debug: logger.setLevel(logging.DEBUG) http.client.HTTPConnection.debuglevel = 1 else: http.client.HTTPConnection.debuglevel = 0 if self.hound_url == "" or self.github_base_url == "": self.settings.set("hound_url", self.hound_url) self.settings.set("github_base_url", self.github_base_url) sublime.save_settings(self.SETTINGS) # save them so we have something to edit sublime.error_message("Please set your hound_url and github_base_url.") self.open_settings() return
Example #6
Source File: jumping.py From SublimeFileBrowser with MIT License | 6 votes |
def run(self, edit): pt = self.view.sel()[0].a row, col = self.view.rowcol(pt) points = [[n, t] for n, t in jump_points()] current_project = [points[row - 3][1]] settings = load_settings('dired.sublime-settings') smart_jump = settings.get('dired_smart_jump', False) if smart_jump and len(self.view.window().views()) == 1: show(self.view.window(), current_project[0]) else: self.view.run_command("dired_open_in_new_window", {"project_folder": current_project}) def close_view(view): if ST3: view.close() else: view.window().run_command("close_file") sublime.set_timeout(close_view(self.view), 100)
Example #7
Source File: StataImproved.py From StataImproved with MIT License | 6 votes |
def run(self, edit): selectedcode = "" sels = self.view.sel() for sel in sels: selectedcode = selectedcode + self.view.substr(sel) if len(selectedcode) == 0: selectedcode = self.view.substr(self.view.line(sel)) selectedcode = selectedcode + "\n" dofile_path =tempfile.gettempdir()+'selectedlines_piupiu.do' with codecs.open(dofile_path, 'w', encoding='utf-8') as out: out.write(selectedcode) version, stata_app_id = get_stata_version() cmd = """osascript<< END tell application id "{0}" DoCommandAsync "run {1}" with addToReview end tell END""".format(stata_app_id,dofile_path) progswitch=sublime.load_settings('StataImproved.sublime-settings').get("prog") print(cmd) print("stata_app_id") print(stata_app_id) os.system(cmd)
Example #8
Source File: sfdx.py From SalesforceXyTools with Apache License 2.0 | 6 votes |
def run(self): self.sf_basic_config = SfBasicConfig() self.settings = self.sf_basic_config.get_setting() self.sublconsole = SublConsole(self.sf_basic_config) self.window = sublime.active_window() self.osutil = util.OsUtil(self.sf_basic_config) s = sublime.load_settings(SFDX_SETTINGS) tasks = s.get("tasks") self.env = s.get("custom_env") self.env.update(DxEnv().get_env()) self.env.update(CommandEnv(self.window, self.sf_basic_config.get_project_dir()).get_env()) self.sel_keys = [task["label"] for task in tasks] self.sel_vals = [task for task in tasks] self.window.show_quick_panel(self.sel_keys, self.panel_done, sublime.MONOSPACE_FONT)
Example #9
Source File: jumping.py From SublimeFileBrowser with MIT License | 6 votes |
def on_pick_point(self, index): if index == -1: return name, target = self.jump_points[index] if isdir(target): settings = load_settings('dired.sublime-settings') smart_jump = settings.get('dired_smart_jump', False) auto = self.new_window == 'auto' if self.new_window is True or ((not smart_jump) and auto) or (smart_jump and auto and len(self.view.window().views()) > 0): self.view.run_command("dired_open_in_new_window", {"project_folder": [target]}) else: show(self.view.window(), target, view_id=self.view.id()) status_message(u"Jumping to point '{0}' complete".format(unicodify(name))) else: # workaround ST3 bug https://github.com/SublimeText/Issues/issues/39 self.view.window().run_command('hide_overlay') msg = u"Can't jump to '{0} → {1}'.\n\nRemove that jump point?".format(name, target) if ok_cancel_dialog(msg): points = load_jump_points() del points[name] save_jump_points(points) status_message(u"Jump point '{0}' was removed".format(name)) self.view.run_command('dired_refresh')
Example #10
Source File: Glue.py From glue with MIT License | 6 votes |
def __init__(self, *args, **kwargs): self.settings = sublime.load_settings('Glue.sublime-settings') self.stdout = "" self.stderr = "" self.exitcode = 1 self.userpath = self.settings.get('glue_userpath') self.shellpath = self.settings.get('glue_shellpath') self.original_env_path = os.environ['PATH'] self.ps1 = self.settings.get('glue_ps1') self.start_dirpath = "" self.current_dirpath = self.settings.get('glue_working_directory') self.current_filepath = "" self.attr_lock = threading.Lock() # thread lock for attribute reads/writes sublime_plugin.TextCommand.__init__(self, *args, **kwargs) #------------------------------------------------------------------------------ # [ run method ] - plugin start method #------------------------------------------------------------------------------
Example #11
Source File: dired.py From dired with MIT License | 6 votes |
def run(self, edit, dirs): settings = sublime.load_settings('dired.sublime-settings') for key_name in ['reuse_view', 'bookmarks']: settings.set(key_name, settings.get(key_name)) bm = bookmarks() for path in dirs : bm.append(path) settings.set('bookmarks', bm) # This command makes/writes a sublime-settings file at Packages/User/, # and doesn't write into one at Packages/dired/. sublime.save_settings('dired.sublime-settings') sublime.status_message('Bookmarking succeeded.') self.view.erase_regions('marked')
Example #12
Source File: ExpandRegion.py From sublime-expand-region with MIT License | 6 votes |
def _detect_language(view, settings_name): point = view.sel()[0].b settings = sublime.load_settings(settings_name + ".sublime-settings") selectors = settings.get("scope_selectors") def maximal_score(scopes): if not scopes: # validity check return 0 return max(view.score_selector(point, s) for s in scopes) # calculate the maximal score for each language scores = [(k, maximal_score(v)) for k, v in selectors.items()] if not scores: # validity check return # get the language with the best score scored_lang, score = max(scores, key=lambda item: item[1]) language = scored_lang if score else "" return language
Example #13
Source File: standard-format.py From sublime-standard-format with MIT License | 6 votes |
def plugin_loaded(): """ perform some work to set up env correctly. """ global global_path global local_path global settings settings = sublime.load_settings(SETTINGS_FILE) view = sublime.active_window().active_view() if platform != "windows": maybe_path = calculate_user_path() if len(maybe_path) > 0: global_path = maybe_path[0] search_path = generate_search_path(view) local_path = search_path print_status(global_path, search_path)
Example #14
Source File: bbcode.py From SublimeKSP with GNU General Public License v3.0 | 6 votes |
def run(self, *args, **kwargs): view = sublime.active_window().active_view() #settings = sublime.load_settings('KSP.sublime-settings') #scheme_file = settings.get('color_scheme', 'Packages/SublimeKSP/KScript Light.tmTheme') scheme_file = 'Packages/SublimeKSP/KScript Light.tmTheme' plist = readPlistFromBytes(sublime.load_binary_resource(scheme_file)) result = ['[pre]'] start, end = view.sel()[0].a, view.sel()[0].b if start == end: start, end = 0, view.size() for a, b, scopes in get_ranges(view.scope_name(i) for i in range(start, end)): result.append(self.apply_style(scopes, plist, view.substr(sublime.Region(start+a, start+b)))) result.append('[/pre]') sublime.set_clipboard(''.join(result))
Example #15
Source File: ksp_plugin.py From SublimeKSP with GNU General Public License v3.0 | 6 votes |
def run(self, setting, default): sksp_options_dict = { "ksp_compact_output" : "Remove Indents and Empty Lines", "ksp_compact_variables" : "Compact Variables", "ksp_extra_checks" : "Extra Syntax Checks", "ksp_optimize_code" : "Optimize Compiled Code", "ksp_signal_empty_ifcase" : "Raise Error on Empty 'if' or 'case' Statements", "ksp_add_compiled_date" : "Add Compilation Date/Time Comment", "ksp_comment_inline_functions" : "Insert Comments When Expanding Functions", "ksp_play_sound" : "Play Sound When Compilation Finishes" } s = sublime.load_settings("KSP.sublime-settings") s.set(setting, not s.get(setting, False)) sublime.save_settings("KSP.sublime-settings") if s.get(setting, False): option_toggle = "enabled!" else: option_toggle = "disabled!" sublime.status_message('SublimeKSP option %s is %s' % (sksp_options_dict[setting], option_toggle))
Example #16
Source File: jasmine_commands.py From sublime-jasmine with MIT License | 5 votes |
def load_settings(self): settings = sublime.load_settings("Jasmine.sublime-settings") self.ignored_directories = settings.get("ignored_directories", []) self.jasmine_path = settings.get("jasmine_path", "spec") self.spec_file_extension = settings.get("spec_file_extension", ".spec.js")
Example #17
Source File: _generated_2018_02_11_at_20_21_24.py From JavaScript-Completions with MIT License | 5 votes |
def load_api(self): # Caching completions if self.API_Setup: for API_Keyword in self.API_Setup: self.api[API_Keyword] = sublime.load_settings( API_Keyword + '.sublime-settings' ) if self.api[API_Keyword].get("scope") == None : path_to_json = os.path.join(PACKAGE_PATH, "sublime-completions", API_Keyword + '.sublime-settings' ) if os.path.isfile(path_to_json): with open(path_to_json) as json_file: self.api[API_Keyword] = json.load(json_file)
Example #18
Source File: jasmine_commands.py From sublime-jasmine with MIT License | 5 votes |
def run(self, edit, split_view = False): self.load_settings() BaseFile.create_base_spec_folder(self.view, self.jasmine_path) self.split_view = split_view self.defer(lambda: self._run(edit))
Example #19
Source File: _generated_2018_02_11_at_20_21_24.py From JavaScript-Completions with MIT License | 5 votes |
def get(self, key): return sublime.load_settings('JavaScript-Completions.sublime-settings').get(key)
Example #20
Source File: graphvizer.py From Graphvizer with GNU General Public License v2.0 | 5 votes |
def plugin_loaded(): global st_settings st_settings = sublime.load_settings("Graphvizer.sublime-settings") add_st_settings_callback() # The file views and unsaved views opened during Sublime Text startup won't trigger any member # function in CoreListener class. We must scan all views and filter the DOT views. Then # we will render the image for each DOT view and set a suitable saving status for it. _mod = sys.modules[__name__] core_listener = _mod.__plugins__[0] for view in sublime.active_window().views(): if view.settings().get('syntax') != "Packages/Graphviz/DOT.sublime-syntax": continue core_listener.rendering(view) # Initial rendering if view.file_name() is not None: # File exists on disk view.settings().set("persistence", True) # Set a suitable saving status for this DOT view
Example #21
Source File: gutter_color.py From GutterColor with MIT License | 5 votes |
def settings(): """Shortcut to the settings""" return load_settings("GutterColor.sublime-settings")
Example #22
Source File: line.py From GutterColor with MIT License | 5 votes |
def __init__(self, view, region, file_id): self.generate_webcolors() self.view = view self.region = region self.file_id = file_id self.settings = load_settings("GutterColor.sublime-settings") self.text = self.view.substr(self.region)
Example #23
Source File: listener.py From network_tech with Apache License 2.0 | 5 votes |
def on_hover(self, point, hover_zone): settings = sublime.load_settings('Network Tech.sublime-settings') network_info_on_hover = settings.get('network_info_on_hover', True) if not network_info_on_hover: return if not self.view.scope_name(point).startswith(SCOPE_PREFIX): return if hover_zone == sublime.HOVER_TEXT: if self.view.is_popup_visible(): self.view.hide_popup() self.network_info(point=point, location=point) else: self.view.hide_popup()
Example #24
Source File: markdown_table_formatter.py From MarkdownTableFormatter with MIT License | 5 votes |
def on_pre_save(self, view): # restrict to markdown files if view.score_selector(0, "text.html.markdown") == 0: return settings = \ sublime.load_settings("MarkdownTableFormatter.sublime-settings") if not settings.get("autoformat_on_save"): return view.run_command("markdown_table_format", {"format_all": True})
Example #25
Source File: settings.py From sublime-gulp with MIT License | 5 votes |
def __init__(self): self.user_settings = sublime.load_settings(Settings.PACKAGE_SETTINGS) self.sources = [ProjectData(), self.user_settings] active_view = sublime.active_window().active_view() if active_view: self.sources.append(active_view.settings())
Example #26
Source File: tern.py From PhaserSublimePackage with MIT License | 5 votes |
def get_setting(key, default): old_settings = sublime.load_settings("Preferences.sublime-settings") new_settings = sublime.load_settings("Tern.sublime-settings") setting = new_settings.get(key, None) if setting is None: return old_settings.get(key, default) else: return new_settings.get(key, default)
Example #27
Source File: package_reloader.py From AutomaticPackageReloader with MIT License | 5 votes |
def run(self): package_reloader_settings = sublime.load_settings("package_reloader.sublime-settings") reload_on_save = not package_reloader_settings.get("reload_on_save") package_reloader_settings.set("reload_on_save", reload_on_save) onoff = "on" if reload_on_save else "off" sublime.status_message("Package Reloader: Reload on Save is %s." % onoff)
Example #28
Source File: package_reloader.py From AutomaticPackageReloader with MIT License | 5 votes |
def on_post_save(self, view): if view.is_scratch() or view.settings().get('is_widget'): return file_name = view.file_name() if file_name and file_name.endswith(".py") and package_of(file_name): package_reloader_settings = sublime.load_settings("package_reloader.sublime-settings") if package_reloader_settings.get("reload_on_save"): view.window().run_command("package_reloader_reload")
Example #29
Source File: package.py From AutomaticPackageReloader with MIT License | 5 votes |
def has_package(package): zipped_file = os.path.join( sublime.installed_packages_path(), "{}.sublime-package".format(package)) unzipped_folder = os.path.join(sublime.packages_path(), package) if not os.path.exists(zipped_file) and not os.path.exists(unzipped_folder): return False preferences = sublime.load_settings("Preferences.sublime-settings") if package in preferences.get("ignored_packages", []): return False return True
Example #30
Source File: test.py From UnitTesting with MIT License | 5 votes |
def setUp(self): self.view = sublime.active_window().new_file() # make sure we have a window to work with s = sublime.load_settings("Preferences.sublime-settings") s.set("close_windows_when_empty", False)