├── Commands ├── Minify Document.tmCommand ├── Reformat Document : Selection.tmCommand └── Validate Syntax.tmCommand ├── Preferences ├── Folding.tmPreferences └── Miscellaneous.tmPreferences ├── README.mdown ├── Syntaxes └── JSON.tmLanguage └── info.plist /Commands/Minify Document.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env ruby20 9 | require 'json' 10 | stdin = STDIN.read 11 | begin 12 | stdin = JSON.parse(stdin).to_json 13 | print stdin 14 | end 15 | 16 | input 17 | selection 18 | inputFormat 19 | text 20 | keyEquivalent 21 | ^M 22 | name 23 | Minify Document / Selection 24 | outputCaret 25 | heuristic 26 | outputFormat 27 | text 28 | outputLocation 29 | replaceInput 30 | scope 31 | source.json 32 | uuid 33 | 66890766-DB96-4772-B2D3-82ACB5DD6823 34 | version 35 | 2 36 | 37 | 38 | -------------------------------------------------------------------------------- /Commands/Reformat Document : Selection.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env ruby20 9 | require 'json' 10 | 11 | stdin = STDIN.read 12 | indent_level = (ENV['TM_SOFT_TABS'] == "NO" ? "\t" : " "*ENV['TM_TAB_SIZE'].to_i ) 13 | 14 | begin 15 | hash = JSON.parse stdin 16 | print JSON.pretty_generate(hash, indent: indent_level) 17 | rescue Exception => e 18 | print stdin 19 | end 20 | 21 | input 22 | selection 23 | inputFormat 24 | text 25 | keyEquivalent 26 | ^H 27 | name 28 | Reformat Document / Selection 29 | outputCaret 30 | heuristic 31 | outputFormat 32 | text 33 | outputLocation 34 | replaceInput 35 | scope 36 | source.json 37 | uuid 38 | 4B74F2DE-E051-4E8D-9124-EBD90A2CDD2B 39 | version 40 | 2 41 | 42 | 43 | -------------------------------------------------------------------------------- /Commands/Validate Syntax.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | nop 7 | command 8 | #!/usr/bin/env ruby18 9 | require ENV['TM_SUPPORT_PATH'] + '/lib/textmate' 10 | 11 | error = `cat | python3 -mjson.tool 2>&1 > /dev/null` 12 | 13 | if error.empty? 14 | puts "Valid JSON, no errors" 15 | else 16 | puts error 17 | TextMate.go_to :line => $1 if error =~ /line (\d+)/ 18 | end 19 | 20 | input 21 | document 22 | inputFormat 23 | text 24 | keyEquivalent 25 | ^V 26 | name 27 | Validate Syntax 28 | outputCaret 29 | afterOutput 30 | outputFormat 31 | text 32 | outputLocation 33 | toolTip 34 | scope 35 | source.json 36 | uuid 37 | CB0DD80E-CD51-49C3-A89C-57E8C3168067 38 | version 39 | 2 40 | 41 | 42 | -------------------------------------------------------------------------------- /Preferences/Folding.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Folding 7 | scope 8 | source.json 9 | settings 10 | 11 | foldingStartMarker 12 | (?x: # turn on extended mode 13 | ^ # a line beginning with 14 | \s* # some optional space 15 | [{\[] # the start of an object or array 16 | (?! # but not followed by 17 | .* # whatever 18 | [}\]] # and the close of an object or array 19 | ,? # an optional comma 20 | \s* # some optional space 21 | $ # at the end of the line 22 | ) 23 | | # ...or... 24 | [{\[] # the start of an object or array 25 | \s* # some optional space 26 | $ # at the end of the line 27 | ) 28 | foldingStopMarker 29 | (?x: # turn on extended mode 30 | ^ # a line beginning with 31 | \s* # some optional space 32 | [}\]] # and the close of an object or array 33 | ) 34 | 35 | uuid 36 | 0CA8F9F2-FF0F-47BF-8D77-1DC5747C7D4C 37 | 38 | 39 | -------------------------------------------------------------------------------- /Preferences/Miscellaneous.tmPreferences: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | name 6 | Miscellaneous 7 | scope 8 | source.json 9 | settings 10 | 11 | decreaseIndentPattern 12 | ^\s*[}\]],?\s*$ 13 | increaseIndentPattern 14 | ^.*(\{[^}]*|\[[^\]]*)$ 15 | smartTypingPairs 16 | 17 | 18 | " 19 | " 20 | 21 | 22 | ( 23 | ) 24 | 25 | 26 | { 27 | } 28 | 29 | 30 | [ 31 | ] 32 | 33 | 34 | shellVariables 35 | 36 | 37 | name 38 | TM_LINE_TERMINATOR 39 | value 40 | , 41 | 42 | 43 | 44 | uuid 45 | 9D83F5F7-ECAD-4EFE-ADAC-2063C7EFED56 46 | 47 | 48 | -------------------------------------------------------------------------------- /README.mdown: -------------------------------------------------------------------------------- 1 | # Installation 2 | 3 | You can install this bundle in TextMate by opening the preferences and going to the bundles tab. After installation it will be automatically updated for you. 4 | 5 | # General 6 | 7 | * [Bundle Styleguide](http://kb.textmate.org/bundle_styleguide) — _before you make changes_ 8 | * [Commit Styleguide](http://kb.textmate.org/commit_styleguide) — _before you send a pull request_ 9 | * [Writing Bug Reports](http://kb.textmate.org/writing_bug_reports) — _before you report an issue_ 10 | 11 | # License 12 | 13 | If not otherwise specified (see below), files in this repository fall under the following license: 14 | 15 | Permission to copy, use, modify, sell and distribute this 16 | software is granted. This software is provided "as is" without 17 | express or implied warranty, and with no claim as to its 18 | suitability for any purpose. 19 | 20 | An exception is made for files in readable text which contain their own license information, or files where an accompanying file exists (in the same directory) with a “-license” suffix added to the base-name name of the original file, and an extension of txt, html, or similar. For example “tidy” is accompanied by “tidy-license.txt”. -------------------------------------------------------------------------------- /Syntaxes/JSON.tmLanguage: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | fileTypes 6 | 7 | json 8 | 9 | keyEquivalent 10 | ^~J 11 | name 12 | JSON 13 | patterns 14 | 15 | 16 | include 17 | #value 18 | 19 | 20 | repository 21 | 22 | array 23 | 24 | begin 25 | \[ 26 | beginCaptures 27 | 28 | 0 29 | 30 | name 31 | punctuation.definition.array.begin.json 32 | 33 | 34 | end 35 | \] 36 | endCaptures 37 | 38 | 0 39 | 40 | name 41 | punctuation.definition.array.end.json 42 | 43 | 44 | name 45 | meta.structure.array.json 46 | patterns 47 | 48 | 49 | include 50 | #value 51 | 52 | 53 | match 54 | , 55 | name 56 | punctuation.separator.array.json 57 | 58 | 59 | match 60 | [^\s\]] 61 | name 62 | invalid.illegal.expected-array-separator.json 63 | 64 | 65 | 66 | constant 67 | 68 | match 69 | \b(?:true|false|null)\b 70 | name 71 | constant.language.json 72 | 73 | number 74 | 75 | comment 76 | handles integer and decimal numbers 77 | match 78 | (?x: # turn on extended mode 79 | -? # an optional minus 80 | (?: 81 | 0 # a zero 82 | | # ...or... 83 | [1-9] # a 1-9 character 84 | \d* # followed by zero or more digits 85 | ) 86 | (?: 87 | (?: 88 | \. # a period 89 | \d+ # followed by one or more digits 90 | )? 91 | (?: 92 | [eE] # an e character 93 | [+-]? # followed by an option +/- 94 | \d+ # followed by one or more digits 95 | )? # make exponent optional 96 | )? # make decimal portion optional 97 | ) 98 | name 99 | constant.numeric.json 100 | 101 | object 102 | 103 | begin 104 | \{ 105 | beginCaptures 106 | 107 | 0 108 | 109 | name 110 | punctuation.definition.dictionary.begin.json 111 | 112 | 113 | comment 114 | a JSON object 115 | end 116 | \} 117 | endCaptures 118 | 119 | 0 120 | 121 | name 122 | punctuation.definition.dictionary.end.json 123 | 124 | 125 | name 126 | meta.structure.dictionary.json 127 | patterns 128 | 129 | 130 | comment 131 | the JSON object key 132 | include 133 | #string 134 | 135 | 136 | begin 137 | : 138 | beginCaptures 139 | 140 | 0 141 | 142 | name 143 | punctuation.separator.dictionary.key-value.json 144 | 145 | 146 | end 147 | (,)|(?=\}) 148 | endCaptures 149 | 150 | 1 151 | 152 | name 153 | punctuation.separator.dictionary.pair.json 154 | 155 | 156 | name 157 | meta.structure.dictionary.value.json 158 | patterns 159 | 160 | 161 | comment 162 | the JSON object value 163 | include 164 | #value 165 | 166 | 167 | match 168 | [^\s,] 169 | name 170 | invalid.illegal.expected-dictionary-separator.json 171 | 172 | 173 | 174 | 175 | match 176 | [^\s\}] 177 | name 178 | invalid.illegal.expected-dictionary-separator.json 179 | 180 | 181 | 182 | string 183 | 184 | begin 185 | " 186 | beginCaptures 187 | 188 | 0 189 | 190 | name 191 | punctuation.definition.string.begin.json 192 | 193 | 194 | end 195 | " 196 | endCaptures 197 | 198 | 0 199 | 200 | name 201 | punctuation.definition.string.end.json 202 | 203 | 204 | name 205 | string.quoted.double.json 206 | patterns 207 | 208 | 209 | match 210 | (?x: # turn on extended mode 211 | \\ # a literal backslash 212 | (?: # ...followed by... 213 | ["\\/bfnrt] # one of these characters 214 | | # ...or... 215 | u # a u 216 | [0-9a-fA-F]{4} # and four hex digits 217 | ) 218 | ) 219 | name 220 | constant.character.escape.json 221 | 222 | 223 | match 224 | \\. 225 | name 226 | invalid.illegal.unrecognized-string-escape.json 227 | 228 | 229 | 230 | value 231 | 232 | comment 233 | the 'value' diagram at http://json.org 234 | patterns 235 | 236 | 237 | include 238 | #constant 239 | 240 | 241 | include 242 | #number 243 | 244 | 245 | include 246 | #string 247 | 248 | 249 | include 250 | #array 251 | 252 | 253 | include 254 | #object 255 | 256 | 257 | 258 | 259 | scopeName 260 | source.json 261 | uuid 262 | 0C3868E4-F96B-4E55-B204-1DCB5A20748B 263 | 264 | 265 | -------------------------------------------------------------------------------- /info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | contactEmailRot13 6 | wnzrf@tenlcebqhpgvbaf.arg 7 | contactName 8 | James Edward Gray II 9 | description 10 | Syntax highlight for <a href="http://json.org/">JavaScript Object Notation</a> files, often used as a lightweight serialization format. 11 | mainMenu 12 | 13 | items 14 | 15 | 4B74F2DE-E051-4E8D-9124-EBD90A2CDD2B 16 | 66890766-DB96-4772-B2D3-82ACB5DD6823 17 | ------------------------------------ 18 | CB0DD80E-CD51-49C3-A89C-57E8C3168067 19 | 20 | 21 | name 22 | JSON 23 | uuid 24 | 8BB0DBAF-E65C-4E14-A6A7-467D4AA535E0 25 | 26 | 27 | --------------------------------------------------------------------------------