Skip to content

Commit

Permalink
drop fmt support
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenzek committed Mar 18, 2024
1 parent ed168ce commit fc07bc6
Showing 1 changed file with 0 additions and 21 deletions.
21 changes: 0 additions & 21 deletions Zig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit fc07bc6

Please sign in to comment.