Skip to content

Commit

Permalink
fix #36
Browse files Browse the repository at this point in the history
  • Loading branch information
emekoi committed Apr 18, 2020
1 parent 99c8b18 commit e8f68cd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Build Systems/Zig.sublime-build
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
{
"cmd": ["zig", "fmt", "$file"],
"selector": "source.zig",
"name": "Format File"
"name": "Format File",
"quiet": true,
},
{
"cmd": ["zig", "build", "test"],
Expand All @@ -36,7 +37,8 @@
{
"cmd": ["zig", "fmt", "$folder"],
"selector": "source.zig",
"name": "Format Project"
"name": "Format Project",
"quiet": true
},
]
}
10 changes: 10 additions & 0 deletions Settings/Zig.sublime-settings
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
{
// path to the zig compiler or just "zig" if it's in your PATH
"zig.executable": "zig",

// automatically build the file/project on save
"zig.build.on_save": false,

// automatically format the file/project on save
"zig.fmt.on_save": true,

// format either file or project. the only valid options are "file" or "project"
"zig.fmt.mode": "file",

// automatically hide the build/fmt output panel
"zig.quiet": true,
}
4 changes: 3 additions & 1 deletion Zig.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ def on_post_save_async(self, view):
if scope.find('source.zig') != -1:
should_fmt = get_setting(view, 'zig.fmt.on_save', True)
should_build = get_setting(view, 'zig.build.on_save', False)
is_quiet = get_setting(view, 'zig.quiet', True)

if (should_fmt):
mode = get_setting(view, 'zig.fmt.mode', 'File').title()
view.window().run_command('build', {'variant': 'Format ' + mode})

if (should_build):
view.window().run_command('build')
if (is_quiet):
view.window().run_command("hide_panel")

0 comments on commit e8f68cd

Please sign in to comment.