Merge pull request #120 from dzhibas/features/3

Features: as_json
This commit is contained in:
Terminal 2020-05-19 18:44:50 -04:00 committed by GitHub
commit 26541438af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 19 deletions

View File

@ -5,10 +5,6 @@
], ],
"command": "pretty_json" "command": "pretty_json"
}, },
{
"keys": ["ctrl+alt+shift+j"],
"command": "jq_query_pretty_json"
},
{ {
"keys": ["ctrl+r"], "keys": ["ctrl+r"],
"command": "pretty_json_goto_symbol", "command": "pretty_json_goto_symbol",

View File

@ -5,10 +5,6 @@
], ],
"command": "pretty_json" "command": "pretty_json"
}, },
{
"keys": ["super+ctrl+shift+j"],
"command": "jq_query_pretty_json"
},
{ {
"keys": ["super+r"], "keys": ["super+r"],
"command": "pretty_json_goto_symbol", "command": "pretty_json_goto_symbol",

View File

@ -11,10 +11,6 @@
], ],
"command": "un_pretty_json" "command": "un_pretty_json"
}, },
{
"keys": ["ctrl+alt+shift+j"],
"command": "jq_query_pretty_json"
},
{ {
"keys": ["ctrl+r"], "keys": ["ctrl+r"],
"command": "pretty_json_goto_symbol", "command": "pretty_json_goto_symbol",

View File

@ -7,7 +7,7 @@
"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, "pretty_on_save": true,
"validate_on_save": true, "validate_on_save": true,
"brace_newline": true, "brace_newline": true,
"bracket_newline": true, "bracket_newline": true,
@ -19,9 +19,9 @@
"jq_binary": "jq", "jq_binary": "jq",
"jq_errors": false, "jq_errors": false,
"as_json":[ "as_json":[
"JSON", "Packages/JSON/JSON.sublime-syntax",
"Sublime Text Commands", "Packages/PackageDev/Package/Sublime Text Commands/Sublime Text Commands.sublime-syntax",
"Sublime Text Settingss", "Packages/PackageDev/Package/Sublime Text Settings/Sublime Text Settings.sublime-syntax",
"Sublime Text Menu" "Packages/PackageDev/Package/Sublime Text Menu/Sublime Text Menu.sublime-syntax"
] ]
} }

View File

@ -131,7 +131,7 @@ class PrettyJsonBaseCommand:
return '\n'.join(lines) return '\n'.join(lines)
def show_exception(self, region: sublime.Region = None, msg=str()): def show_exception(self, region: sublime.Region = None, msg=str()):
sublime.status_message(f'[Error]: {msg}') sublime.message_dialog(f'[Error]: {msg}')
if region is None: if region is None:
sublime.message_dialog(f'[Error]: {msg}') sublime.message_dialog(f'[Error]: {msg}')
return return

View File

@ -15,6 +15,7 @@ class PrettyJsonLintListener(sublime_plugin.EventListener, PrettyJsonBaseCommand
if any( if any(
syntax in view.settings().get("syntax") for syntax in as_json syntax in view.settings().get("syntax") for syntax in as_json
): ):
self.view = view
self.clear_phantoms() self.clear_phantoms()
json_content = view.substr(sublime.Region(0, view.size())) json_content = view.substr(sublime.Region(0, view.size()))
try: try:
@ -32,4 +33,4 @@ class PrettyJsonAutoPrettyOnSaveListener(sublime_plugin.EventListener):
if any( if any(
syntax in view.settings().get('syntax') for syntax in as_json syntax in view.settings().get('syntax') for syntax in as_json
): ):
sublime.active_window().run_command('pretty_json') sublime.active_window().active_view().run_command('pretty_json')