Skip to content

Commit

Permalink
Make compatible with TextMate
Browse files Browse the repository at this point in the history
This change will make this language usable as a TextMate Bundle.

I have used my name/email as contact for the Bundle. Feel free to change.

- Add UUID's to tmLanguage and tmPreferences to make them work with TextMate
- Add Build, Run, Fmt and Test tmCommands
- Run Fmt on save
- Symlink Comments.tmPreferences to TextMate location
- Add install instructions
- Add info.plist required by TextMate
  • Loading branch information
Johan Bloemberg authored and emekoi committed Apr 15, 2020
1 parent 28c5a88 commit 0e0b2c7
Show file tree
Hide file tree
Showing 16 changed files with 386 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Commands/Build.YAML-tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
autoScrollOutput: true
beforeRunningCommand: saveModifiedFiles
command: '#!/usr/bin/env ruby18

require ENV["TM_SUPPORT_PATH"] + "/lib/tm/executor"

require ENV["TM_SUPPORT_PATH"] + "/lib/tm/save_current_document"


TextMate.save_if_untitled(''zig'')

TextMate::Executor.make_project_master_current_document


TextMate::Executor.run(ENV["TM_ZIG"] || "zig", "build-exe", ENV["TM_FILEPATH"],
:create_error_pipe => true) '
input: document
inputFormat: text
keyEquivalent: '@b'
name: Build
outputCaret: afterOutput
outputFormat: html
outputLocation: newWindow
requiredCommands:
- command: zig
locations:
- /opt/local/bin/zig
- /usr/local/bin/zig
- /usr/local/zig/bin/zig
variable: TM_ZIG
scope: source.zig
uuid: C9E6A57F-7472-445A-BF41-292C8D5F183C
version: 2
54 changes: 54 additions & 0 deletions Commands/Build.tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?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>autoScrollOutput</key>
<true/>
<key>beforeRunningCommand</key>
<string>saveModifiedFiles</string>
<key>command</key>
<string>#!/usr/bin/env ruby18
require ENV["TM_SUPPORT_PATH"] + "/lib/tm/executor"
require ENV["TM_SUPPORT_PATH"] + "/lib/tm/save_current_document"
TextMate.save_if_untitled('zig')
TextMate::Executor.make_project_master_current_document
TextMate::Executor.run(ENV["TM_ZIG"] || "zig", "build-exe", ENV["TM_FILEPATH"], :create_error_pipe =&gt; true) </string>
<key>input</key>
<string>document</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>@b</string>
<key>name</key>
<string>Build</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>html</string>
<key>outputLocation</key>
<string>newWindow</string>
<key>requiredCommands</key>
<array>
<dict>
<key>command</key>
<string>zig</string>
<key>locations</key>
<array>
<string>/opt/local/bin/zig</string>
<string>/usr/local/bin/zig</string>
<string>/usr/local/zig/bin/zig</string>
</array>
<key>variable</key>
<string>TM_ZIG</string>
</dict>
</array>
<key>scope</key>
<string>source.zig</string>
<key>uuid</key>
<string>C9E6A57F-7472-445A-BF41-292C8D5F183C</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>
25 changes: 25 additions & 0 deletions Commands/Fmt.YAML-tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
beforeRunningCommand: nop
command: "#!/usr/bin/env bash\n\n# shellcheck source=/dev/null\n. \"${TM_SUPPORT_PATH}/lib/bash_init.sh\"\
\n\nset -e \n\nPATH=/opt/local/bin:/usr/local/bin:/usr/local/zig/bin:$PATH\n \
\ \nrequire_cmd zig\n\ntmpfile=$(mktemp \"${TMPDIR:-/tmp/}zig-fmt.XXXXXX\")\n\
cat - > \"$tmpfile\"\n\nif ! error=$(\"${TM_ZIG:-zig}\" fmt \"$tmpfile\" 2>&1);then\n\
\ exit_show_tool_tip \"${error//$tmpfile/$(basename \"$TM_FILEPATH\")}\"\nfi\n\
\ncat \"$tmpfile\"\nrm \"$tmpfile\"\n"
input: document
inputFormat: text
keyEquivalent: ''
name: Fmt
outputCaret: interpolateByLine
outputFormat: text
outputLocation: replaceDocument
requiredCommands:
- command: zig
locations:
- /opt/local/bin/zig
- /usr/local/bin/zig
- /usr/local/zig/bin/zig
variable: TM_ZIG
scope: source.zig
semanticClass: callback.document.will-save
uuid: BC972D6E-23AC-4EAD-AF7D-A33564F09433
version: 2
67 changes: 67 additions & 0 deletions Commands/Fmt.tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?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 bash
# shellcheck source=/dev/null
. "${TM_SUPPORT_PATH}/lib/bash_init.sh"
set -e
PATH=/opt/local/bin:/usr/local/bin:/usr/local/zig/bin:$PATH
require_cmd zig
tmpfile=$(mktemp "${TMPDIR:-/tmp/}zig-fmt.XXXXXX")
cat - &gt; "$tmpfile"
if ! error=$("${TM_ZIG:-zig}" fmt "$tmpfile" 2&gt;&amp;1);then
exit_show_tool_tip "${error//$tmpfile/$(basename "$TM_FILEPATH")}"
fi
cat "$tmpfile"
rm "$tmpfile"
</string>
<key>input</key>
<string>document</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string></string>
<key>name</key>
<string>Fmt</string>
<key>outputCaret</key>
<string>interpolateByLine</string>
<key>outputFormat</key>
<string>text</string>
<key>outputLocation</key>
<string>replaceDocument</string>
<key>requiredCommands</key>
<array>
<dict>
<key>command</key>
<string>zig</string>
<key>locations</key>
<array>
<string>/opt/local/bin/zig</string>
<string>/usr/local/bin/zig</string>
<string>/usr/local/zig/bin/zig</string>
</array>
<key>variable</key>
<string>TM_ZIG</string>
</dict>
</array>
<key>scope</key>
<string>source.zig</string>
<key>semanticClass</key>
<string>callback.document.will-save</string>
<key>uuid</key>
<string>BC972D6E-23AC-4EAD-AF7D-A33564F09433</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>
33 changes: 33 additions & 0 deletions Commands/Run.YAML-tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
autoScrollOutput: true
beforeRunningCommand: saveModifiedFiles
command: '#!/usr/bin/env ruby18

require ENV["TM_SUPPORT_PATH"] + "/lib/tm/executor"

require ENV["TM_SUPPORT_PATH"] + "/lib/tm/save_current_document"


TextMate.save_if_untitled(''zig'')

TextMate::Executor.make_project_master_current_document


TextMate::Executor.run(ENV["TM_ZIG"] || "zig", "run", ENV["TM_FILEPATH"], :create_error_pipe
=> true)'
input: document
inputFormat: text
keyEquivalent: '@r'
name: Run
outputCaret: afterOutput
outputFormat: html
outputLocation: newWindow
requiredCommands:
- command: zig
locations:
- /opt/local/bin/zig
- /usr/local/bin/zig
- /usr/local/zig/bin/zig
variable: TM_ZIG
scope: source.zig
uuid: 0B3C3EB0-9F51-4997-A87D-ECA507D8E31E
version: 2
54 changes: 54 additions & 0 deletions Commands/Run.tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?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>autoScrollOutput</key>
<true/>
<key>beforeRunningCommand</key>
<string>saveModifiedFiles</string>
<key>command</key>
<string>#!/usr/bin/env ruby18
require ENV["TM_SUPPORT_PATH"] + "/lib/tm/executor"
require ENV["TM_SUPPORT_PATH"] + "/lib/tm/save_current_document"
TextMate.save_if_untitled('zig')
TextMate::Executor.make_project_master_current_document
TextMate::Executor.run(ENV["TM_ZIG"] || "zig", "run", ENV["TM_FILEPATH"], :create_error_pipe =&gt; true)</string>
<key>input</key>
<string>document</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>@r</string>
<key>name</key>
<string>Run</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>html</string>
<key>outputLocation</key>
<string>newWindow</string>
<key>requiredCommands</key>
<array>
<dict>
<key>command</key>
<string>zig</string>
<key>locations</key>
<array>
<string>/opt/local/bin/zig</string>
<string>/usr/local/bin/zig</string>
<string>/usr/local/zig/bin/zig</string>
</array>
<key>variable</key>
<string>TM_ZIG</string>
</dict>
</array>
<key>scope</key>
<string>source.zig</string>
<key>uuid</key>
<string>0B3C3EB0-9F51-4997-A87D-ECA507D8E31E</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>
33 changes: 33 additions & 0 deletions Commands/Test.YAML-tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
autoScrollOutput: true
beforeRunningCommand: saveModifiedFiles
command: '#!/usr/bin/env ruby18

require ENV["TM_SUPPORT_PATH"] + "/lib/tm/executor"

require ENV["TM_SUPPORT_PATH"] + "/lib/tm/save_current_document"


TextMate.save_if_untitled(''zig'')

TextMate::Executor.make_project_master_current_document


TextMate::Executor.run(ENV["TM_ZIG"] || "zig", "test", ENV["TM_FILEPATH"], :create_error_pipe
=> true)'
input: document
inputFormat: text
keyEquivalent: '@R'
name: Test
outputCaret: afterOutput
outputFormat: html
outputLocation: newWindow
requiredCommands:
- command: zig
locations:
- /opt/local/bin/zig
- /usr/local/bin/zig
- /usr/local/zig/bin/zig
variable: TM_ZIG
scope: source.zig
uuid: C679259A-BAFB-4895-917B-7663645C9B5F
version: 2
54 changes: 54 additions & 0 deletions Commands/Test.tmCommand
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?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>autoScrollOutput</key>
<true/>
<key>beforeRunningCommand</key>
<string>saveModifiedFiles</string>
<key>command</key>
<string>#!/usr/bin/env ruby18
require ENV["TM_SUPPORT_PATH"] + "/lib/tm/executor"
require ENV["TM_SUPPORT_PATH"] + "/lib/tm/save_current_document"
TextMate.save_if_untitled('zig')
TextMate::Executor.make_project_master_current_document
TextMate::Executor.run(ENV["TM_ZIG"] || "zig", "test", ENV["TM_FILEPATH"], :create_error_pipe =&gt; true)</string>
<key>input</key>
<string>document</string>
<key>inputFormat</key>
<string>text</string>
<key>keyEquivalent</key>
<string>@R</string>
<key>name</key>
<string>Test</string>
<key>outputCaret</key>
<string>afterOutput</string>
<key>outputFormat</key>
<string>html</string>
<key>outputLocation</key>
<string>newWindow</string>
<key>requiredCommands</key>
<array>
<dict>
<key>command</key>
<string>zig</string>
<key>locations</key>
<array>
<string>/opt/local/bin/zig</string>
<string>/usr/local/bin/zig</string>
<string>/usr/local/zig/bin/zig</string>
</array>
<key>variable</key>
<string>TM_ZIG</string>
</dict>
</array>
<key>scope</key>
<string>source.zig</string>
<key>uuid</key>
<string>C679259A-BAFB-4895-917B-7663645C9B5F</string>
<key>version</key>
<integer>2</integer>
</dict>
</plist>
1 change: 1 addition & 0 deletions Preferences/Comments.tmPreferences
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ Or add `Zig.tmLanguage` to the packages directory. On OSX This is usually
But to find the path on your machine go to `Preferences > Browse Packages` from
within Sublime Text.

TextMate Installation
---------------------

This language is also compatible with TextMate's `.tmBundle` format. To install in TextMate clone or download this repository. Then rename the repository directory to `Zig.tmBundle` and double-click it to install it into TextMate.

Local Development
-----------------

Expand Down
1 change: 1 addition & 0 deletions Support/Comments.YAML-tmPreferences
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# [PackageDev] target_format: plist, ext: tmPreferences
name: Zig
uuid: 06C2FF99-3080-441A-9019-460C51E93116
scope: source.zig
settings:
shellVariables:
Expand Down
2 changes: 2 additions & 0 deletions Support/Comments.tmPreferences
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@
</dict>
</array>
</dict>
<key>uuid</key>
<string>BAB3200A-F546-4902-AC4B-A6D545F6AA07</string>
</dict>
</plist>
1 change: 1 addition & 0 deletions Syntaxes/Zig.YAML-tmLanguage
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# [PackageDev] target_format: plist, ext: tmLanguage

name: Zig
uuid: 06C2FF99-3080-441A-9019-460C51E93116
scopeName: source.zig
fileTypes:
- zig
Expand Down
Loading

0 comments on commit 0e0b2c7

Please sign in to comment.