From 66c302caa4b3e9f384b74f85c0d4180f87ebe847 Mon Sep 17 00:00:00 2001 From: Nikolajus Date: Mon, 18 Jul 2016 10:38:10 +0200 Subject: [PATCH] #71 ~ way to turn off validation on save --- Pretty JSON.sublime-settings | 3 ++- PrettyJsonListeners.py | 5 +++-- README.md | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Pretty JSON.sublime-settings b/Pretty JSON.sublime-settings index e688f53..5b8e124 100644 --- a/Pretty JSON.sublime-settings +++ b/Pretty JSON.sublime-settings @@ -7,5 +7,6 @@ "value_separator": ": ", "keep_arrays_single_line": false, "max_arrays_line_length": 120, - "pretty_on_save": false + "pretty_on_save": false, + "validate_on_save": true } \ No newline at end of file diff --git a/PrettyJsonListeners.py b/PrettyJsonListeners.py index e78364f..0526f1f 100644 --- a/PrettyJsonListeners.py +++ b/PrettyJsonListeners.py @@ -12,8 +12,9 @@ s = sublime.load_settings("Pretty JSON.sublime-settings") class PrettyJsonLintListener(sublime_plugin.EventListener, PrettyJsonBaseCommand): def on_post_save(self, view): - # will work only in json syntax - if "JSON" in view.settings().get('syntax'): + # will work only in json syntax and once validate_on_save setting is true + validate = s.get("validate_on_save", True) + if validate and "JSON" in view.settings().get('syntax'): self.view = view self.view.erase_regions('json_errors') diff --git a/README.md b/README.md index 2ecba6d..c981e95 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,9 @@ http://stedolan.github.io/jq/ **pretty_on_save** - false `do we need to automatically Pretty JSON on save` +**validate_on_save** - true +`do we need validate JSON files on each save` + ## Using tabs for indentation You can change configuration key **indent** to string value "\t" or any other string