def load_regex_from_file(self): regex_path = os.path.dirname(os.path.realpath(__file__)) + '\\' + str( sublime_api.settings_get(self.settings.settings_id, "pretty_code_regex")) rules = {} if self.language == "papyrus": with open(regex_path, "r") as fp: data = json.load(fp) for lang_regex in data['papyrus']: for rule, rep in lang_regex.items(): rules[rule] = rep fp.close() if len(rules) == 0: return None else: return rules # for smart capitalization: # read through entire sublime dictionary looking for words # and also read through the current file for words # when running through each word, go letter by letter until a word is found
def run(self): sublime.load_settings("Papyrus-Theme.sublime-settings") settings = sublime.load_settings("Papyrus.sublime-settings") scripts_directory = os.path.join( str( sublime_api.settings_get(settings.settings_id, "skyrim_directory")), "Data\\Source\\Scripts") view = sublime.active_window().active_view() scriptname = "None" try: scriptname = view.substr( view.line(0)).strip().rstrip().split(' ')[1] except: sublime.error_message("You lack a ScriptName!") return view.settings().set('default_dir', scripts_directory) view.assign_syntax('Packages/Papyrus/Papyrus.sublime-syntax') view.set_name(scriptname + ".psc") path = os.path.join(scripts_directory, scriptname + ".psc") view.run_command('save') print(path)
def run(self): v = self.window.new_file() scripts_directory = os.path.join( str( sublime_api.settings_get( sublime.load_settings( "Papyrus.sublime-settings").settings_id, "skyrim_directory")), "Data\\Source\\Scripts\\") print(scripts_directory) v.settings().set('default_dir', scripts_directory) v.assign_syntax('Packages/Papyrus/Papyrus.sublime-syntax') template = (""" ScriptName $0 """) v.run_command("insert_snippet", {"contents": textwrap.dedent(template).lstrip()})
def get(self, key, default = None): if default != None: return sublime_api.settings_get_default(self.settings_id, key, default) else: return sublime_api.settings_get(self.settings_id, key)
def get(self, key, default=None): if default != None: return sublime_api.settings_get_default(self.settings_id, key, default) else: return sublime_api.settings_get(self.settings_id, key)