Commits

croach  committed 31aacfb

Initial commit

  • Participants

Comments (0)

Files changed (4)

File Commands/Reformat Document : Selection.tmCommand

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>beforeRunningCommand</key>
+	<string>nop</string>
+	<key>command</key>
+	<string>#!/usr/bin/env python                                                           
+
+import os
+import sys
+import json
+
+support_lib = os.path.join(os.environ['TM_BUNDLE_SUPPORT'], 'lib')
+sys.path.append(support_lib)
+from exit_codes import *
+
+try:
+	data = json.load(sys.stdin)
+	print json.dumps(data, indent=4)
+except Exception, e:
+	exit_show_tool_tip("Error: Invalid JSON")
+</string>
+	<key>input</key>
+	<string>selection</string>
+	<key>keyEquivalent</key>
+	<string>^H</string>
+	<key>name</key>
+	<string>Reformat Document / Selection</string>
+	<key>output</key>
+	<string>replaceSelectedText</string>
+	<key>scope</key>
+	<string>source.json</string>
+	<key>uuid</key>
+	<string>151D298C-9502-464F-982E-BDB7D57B5941</string>
+</dict>
+</plist>

File Support/lib/exit_codes.py

+import sys
+
+def exit_discard():
+	sys.exit(200)
+
+def exit_replace_text(out=None):
+	if out:
+		print out
+	sys.exit(201)
+	
+def exit_replace_document(out=None):
+	if out:
+		print out
+	sys.exit(202)
+
+def exit_insert_text(out=None):
+	if out:
+		print out
+	sys.exit(203)
+
+def exit_insert_snippet(out=None):
+	if out:
+		print out
+	sys.exit(204)
+
+def exit_show_html(out=None):
+	if out:
+		print out
+	sys.exit(205)
+
+def exit_show_tool_tip(out=None):
+	if out:
+		print out
+	sys.exit(206)
+
+def exit_create_new_document(out=None):
+	if out:
+		print out
+	sys.exit(207)

File Syntaxes/JSON.tmLanguage

+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>fileTypes</key>
+	<array>
+		<string>json</string>
+	</array>
+	<key>foldingStartMarker</key>
+	<string>(?x:       # turn on extended mode
+                          ^        # a line beginning with
+                          \s*      # some optional space
+                          [{\[]    # the start of an object or array
+                          (?!      # but not followed by
+                            .*     # whatever
+                            [}\]]  # and the close of an object or array
+                            ,?     # an optional comma
+                            \s*    # some optional space
+                            $      # at the end of the line
+                          )
+                          |        # ...or...
+                          [{\[]    # the start of an object or array
+                          \s*      # some optional space
+                          $        # at the end of the line
+                        )</string>
+	<key>foldingStopMarker</key>
+	<string>(?x:     # turn on extended mode
+                         ^      # a line beginning with
+                         \s*    # some optional space
+                         [}\]]  # and the close of an object or array
+                       )</string>
+	<key>keyEquivalent</key>
+	<string>^~J</string>
+	<key>name</key>
+	<string>JSON</string>
+	<key>patterns</key>
+	<array>
+		<dict>
+			<key>include</key>
+			<string>#value</string>
+		</dict>
+	</array>
+	<key>repository</key>
+	<dict>
+		<key>array</key>
+		<dict>
+			<key>begin</key>
+			<string>\[</string>
+			<key>beginCaptures</key>
+			<dict>
+				<key>0</key>
+				<dict>
+					<key>name</key>
+					<string>punctuation.definition.array.begin.json</string>
+				</dict>
+			</dict>
+			<key>end</key>
+			<string>\]</string>
+			<key>endCaptures</key>
+			<dict>
+				<key>0</key>
+				<dict>
+					<key>name</key>
+					<string>punctuation.definition.array.end.json</string>
+				</dict>
+			</dict>
+			<key>name</key>
+			<string>meta.structure.array.json</string>
+			<key>patterns</key>
+			<array>
+				<dict>
+					<key>include</key>
+					<string>#value</string>
+				</dict>
+				<dict>
+					<key>match</key>
+					<string>,</string>
+					<key>name</key>
+					<string>punctuation.separator.array.json</string>
+				</dict>
+				<dict>
+					<key>match</key>
+					<string>[^\s\]]</string>
+					<key>name</key>
+					<string>invalid.illegal.expected-array-separator.json</string>
+				</dict>
+			</array>
+		</dict>
+		<key>constant</key>
+		<dict>
+			<key>match</key>
+			<string>\b(?:true|false|null)\b</string>
+			<key>name</key>
+			<string>constant.language.json</string>
+		</dict>
+		<key>number</key>
+		<dict>
+			<key>comment</key>
+			<string>handles integer and decimal numbers</string>
+			<key>match</key>
+			<string>(?x:         # turn on extended mode
+			             -?         # an optional minus
+			             (?:
+			               0        # a zero
+			               |        # ...or...
+			               [1-9]    # a 1-9 character
+			               \d*      # followed by zero or more digits
+			             )
+			             (?:
+			               (?:
+			                 \.     # a period
+			                 \d+    # followed by one or more digits
+			               )?
+			               (?:
+			                 [eE]   # an e character
+			                 [+-]?  # followed by an option +/-
+			                 \d+    # followed by one or more digits
+			               )?       # make exponent optional
+			             )?         # make decimal portion optional
+			           )</string>
+			<key>name</key>
+			<string>constant.numeric.json</string>
+		</dict>
+		<key>object</key>
+		<dict>
+			<key>begin</key>
+			<string>\{</string>
+			<key>beginCaptures</key>
+			<dict>
+				<key>0</key>
+				<dict>
+					<key>name</key>
+					<string>punctuation.definition.dictionary.begin.json</string>
+				</dict>
+			</dict>
+			<key>comment</key>
+			<string>a JSON object</string>
+			<key>end</key>
+			<string>\}</string>
+			<key>endCaptures</key>
+			<dict>
+				<key>0</key>
+				<dict>
+					<key>name</key>
+					<string>punctuation.definition.dictionary.end.json</string>
+				</dict>
+			</dict>
+			<key>name</key>
+			<string>meta.structure.dictionary.json</string>
+			<key>patterns</key>
+			<array>
+				<dict>
+					<key>comment</key>
+					<string>the JSON object key</string>
+					<key>include</key>
+					<string>#string</string>
+				</dict>
+				<dict>
+					<key>begin</key>
+					<string>:</string>
+					<key>beginCaptures</key>
+					<dict>
+						<key>0</key>
+						<dict>
+							<key>name</key>
+							<string>punctuation.separator.dictionary.key-value.json</string>
+						</dict>
+					</dict>
+					<key>end</key>
+					<string>(,)|(?=\})</string>
+					<key>endCaptures</key>
+					<dict>
+						<key>1</key>
+						<dict>
+							<key>name</key>
+							<string>punctuation.separator.dictionary.pair.json</string>
+						</dict>
+					</dict>
+					<key>name</key>
+					<string>meta.structure.dictionary.value.json</string>
+					<key>patterns</key>
+					<array>
+						<dict>
+							<key>comment</key>
+							<string>the JSON object value</string>
+							<key>include</key>
+							<string>#value</string>
+						</dict>
+						<dict>
+							<key>match</key>
+							<string>[^\s,]</string>
+							<key>name</key>
+							<string>invalid.illegal.expected-dictionary-separator.json</string>
+						</dict>
+					</array>
+				</dict>
+				<dict>
+					<key>match</key>
+					<string>[^\s\}]</string>
+					<key>name</key>
+					<string>invalid.illegal.expected-dictionary-separator.json</string>
+				</dict>
+			</array>
+		</dict>
+		<key>string</key>
+		<dict>
+			<key>begin</key>
+			<string>"</string>
+			<key>beginCaptures</key>
+			<dict>
+				<key>0</key>
+				<dict>
+					<key>name</key>
+					<string>punctuation.definition.string.begin.json</string>
+				</dict>
+			</dict>
+			<key>end</key>
+			<string>"</string>
+			<key>endCaptures</key>
+			<dict>
+				<key>0</key>
+				<dict>
+					<key>name</key>
+					<string>punctuation.definition.string.end.json</string>
+				</dict>
+			</dict>
+			<key>name</key>
+			<string>string.quoted.double.json</string>
+			<key>patterns</key>
+			<array>
+				<dict>
+					<key>match</key>
+					<string>(?x:                # turn on extended mode
+                     \\                # a literal backslash
+                     (?:               # ...followed by...
+                       ["\\/bfnrt]     # one of these characters
+                       |               # ...or...
+                       u               # a u
+                       [0-9a-fA-F]{4}  # and four hex digits
+                     )
+                   )</string>
+					<key>name</key>
+					<string>constant.character.escape.json</string>
+				</dict>
+				<dict>
+					<key>match</key>
+					<string>\\.</string>
+					<key>name</key>
+					<string>invalid.illegal.unrecognized-string-escape.json</string>
+				</dict>
+			</array>
+		</dict>
+		<key>value</key>
+		<dict>
+			<key>comment</key>
+			<string>the 'value' diagram at http://json.org</string>
+			<key>patterns</key>
+			<array>
+				<dict>
+					<key>include</key>
+					<string>#constant</string>
+				</dict>
+				<dict>
+					<key>include</key>
+					<string>#number</string>
+				</dict>
+				<dict>
+					<key>include</key>
+					<string>#string</string>
+				</dict>
+				<dict>
+					<key>include</key>
+					<string>#array</string>
+				</dict>
+				<dict>
+					<key>include</key>
+					<string>#object</string>
+				</dict>
+			</array>
+		</dict>
+	</dict>
+	<key>scopeName</key>
+	<string>source.json</string>
+	<key>uuid</key>
+	<string>0C3868E4-F96B-4E55-B204-1DCB5A20748B</string>
+</dict>
+</plist>
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>contactEmailRot13</key>
+	<string>wnzrf@tenlcebqhpgvbaf.arg</string>
+	<key>contactName</key>
+	<string>James Edward Gray II</string>
+	<key>deleted</key>
+	<array>
+		<string>4B74F2DE-E051-4E8D-9124-EBD90A2CDD2B</string>
+	</array>
+	<key>description</key>
+	<string>Syntax highlight for &lt;a href="http://json.org/"&gt;JavaScript Object Notation&lt;/a&gt; files, often used as a lightweight serialization format.</string>
+	<key>name</key>
+	<string>JSON</string>
+	<key>ordering</key>
+	<array>
+		<string>0C3868E4-F96B-4E55-B204-1DCB5A20748B</string>
+		<string>151D298C-9502-464F-982E-BDB7D57B5941</string>
+	</array>
+	<key>uuid</key>
+	<string>8BB0DBAF-E65C-4E14-A6A7-467D4AA535E0</string>
+</dict>
+</plist>