diff --git a/Zig.py b/Zig.py index 512cdfe..35c764d 100644 --- a/Zig.py +++ b/Zig.py @@ -365,33 +365,12 @@ def on_phantom_navigate(self, url): self.hide_phantoms() -class ZigFmt(sublime_plugin.TextCommand): - def run(self, edit, file: str = "$file"): - view = self.view - zig_exec = get_setting(view, 'zig.executable', 'zig') - file = sublime.expand_variables(file, self.view.window().extract_variables()) - subprocess.run([zig_exec, "fmt", file], check=True, encoding="utf-8") - print(zig_exec, "fmt", file) - - class Zig(sublime_plugin.EventListener): def on_load_async(self, view): w = view.window() if w is not None: w.run_command('zig_build', {'update_phantoms_only': True}) - def on_post_save(self, view): - # Formatting happens synchronously to avoid conflict between user inputs and format changes. - sel = view.sel()[0] - region = view.word(sel) - scope = view.scope_name(region.b) - if scope.find('source.zig') != -1: - should_fmt = get_setting(view, 'zig.fmt.on_save', True) - if (should_fmt): - mode = get_setting(view, 'zig.fmt.mode', 'file').lower() - file = '$file' if mode == 'file' else '$folder' - view.run_command('zig_fmt', {"file": file }) - def on_post_save_async(self, view): sel = view.sel()[0] region = view.word(sel)