#40 pretty_on_save config to enable pretty on save
This commit is contained in:
parent
62bdb1d281
commit
7b7ca7b4c1
|
@ -6,5 +6,6 @@
|
||||||
"line_separator": ",",
|
"line_separator": ",",
|
||||||
"value_separator": ": ",
|
"value_separator": ": ",
|
||||||
"keep_arrays_single_line": false,
|
"keep_arrays_single_line": false,
|
||||||
"max_arrays_line_length": 120
|
"max_arrays_line_length": 120,
|
||||||
|
"pretty_on_save": false
|
||||||
}
|
}
|
|
@ -7,6 +7,8 @@ try:
|
||||||
except ValueError:
|
except ValueError:
|
||||||
from PrettyJson import PrettyJsonBaseCommand
|
from PrettyJson import PrettyJsonBaseCommand
|
||||||
|
|
||||||
|
s = sublime.load_settings("Pretty JSON.sublime-settings")
|
||||||
|
|
||||||
|
|
||||||
class PrettyJsonLintListener(sublime_plugin.EventListener, PrettyJsonBaseCommand):
|
class PrettyJsonLintListener(sublime_plugin.EventListener, PrettyJsonBaseCommand):
|
||||||
def on_post_save(self, view):
|
def on_post_save(self, view):
|
||||||
|
@ -23,3 +25,10 @@ class PrettyJsonLintListener(sublime_plugin.EventListener, PrettyJsonBaseCommand
|
||||||
self.json_loads(json_content)
|
self.json_loads(json_content)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.show_exception()
|
self.show_exception()
|
||||||
|
|
||||||
|
|
||||||
|
class PrettyJsonAutoPrettyOnSaveListener(sublime_plugin.EventListener):
|
||||||
|
def on_pre_save(self, edit):
|
||||||
|
auto_pretty = s.get("pretty_on_save", False)
|
||||||
|
if auto_pretty:
|
||||||
|
sublime.active_window().run_command('pretty_json')
|
||||||
|
|
|
@ -77,6 +77,9 @@ http://stedolan.github.io/jq/
|
||||||
**max_arrays_line_length** - 120
|
**max_arrays_line_length** - 120
|
||||||
`if array for example '["a", "b", 123213, ....]' length will reach max it will be kept multi-line (for beauty)`
|
`if array for example '["a", "b", 123213, ....]' length will reach max it will be kept multi-line (for beauty)`
|
||||||
|
|
||||||
|
**pretty_on_save** - false
|
||||||
|
`do we need to automatically Pretty JSON on save`
|
||||||
|
|
||||||
## Using tabs for indentation
|
## Using tabs for indentation
|
||||||
|
|
||||||
You can change configuration key **indent** to string value "\t" or any other string
|
You can change configuration key **indent** to string value "\t" or any other string
|
||||||
|
|
Loading…
Reference in New Issue