diff --git a/resources/textmate/local_definition.tmCommand b/resources/textmate/local_definition.tmCommand new file mode 100644 index 0000000..8b95ccd --- /dev/null +++ b/resources/textmate/local_definition.tmCommand @@ -0,0 +1,80 @@ + + + + + beforeRunningCommand + nop + command + #!/usr/bin/env php +<?php + +if (getenv('TM_SELECTED_TEXT')) { + $word = getenv('TM_SELECTED_TEXT'); +} else { + $word = getenv('TM_CURRENT_WORD'); +} + +$file = getenv('TM_FILEPATH'); + +if (!is_dir($file)) { + $file = dirname($file); +} +$file = escapeshellarg($file); + +$ref = null; +$err = 0; +$root = exec("(cd {$file} && /usr/bin/env git rev-parse --show-cdup)", $ref, $err); +if ($err) { + echo "File is not in a git working copy.\n"; + exit($err); +} + +$word = preg_quote($word, $delim = NULL); +$patterns = array( + "((abstract|final) +)*class +{$word}( |$)", + "interface +{$word}( |$)", + "function +&?{$word}( |\(|$)", + " *const +{$word}( |=|$)", + "@provides {$word}( |$)", +); +foreach ($patterns as $k => $pattern) { + $patterns[$k] = '-e '.escapeshellarg($pattern); +} +$patterns = implode(' --or ', $patterns); + +$err = 0; +$cmd = "(cd {$root} && /usr/bin/env git grep --no-index -n -z -I -E {$patterns} | head -n1)"; +$output = exec($cmd, $ref, $err); +$output = trim($output); +if (!$output) { + $untracked = exec("(cd {$root} && /usr/bin/env git ls-files --others --exclude-standard)"); + if ($untracked) { + echo "No results found, but you have untracked files which 'git grep' does not search.\n"; + } else { + echo "No results found.\n"; + } + exit(0); +} + +list($local, $line) = explode("\0", $output); + +$target = $root.'/'.$local; +exec('/usr/bin/env mate '.escapeshellarg($target).' -l '.escapeshellarg($line)); + + + fallbackInput + word + input + selection + keyEquivalent + @ + name + Open Definition (PHP, Local Git) + output + showAsTooltip + scope + source.php + uuid + 0D267B50-2E9C-4B48-9D0C-0FB8E9807552 + + diff --git a/resources/textmate/php_property.tmSnippet b/resources/textmate/php_property.tmSnippet new file mode 100644 index 0000000..da2a180 --- /dev/null +++ b/resources/textmate/php_property.tmSnippet @@ -0,0 +1,25 @@ + + + + + content + ${2:public} function set${1/./\u$0/}(\$${1/[A-Z]+/_\L$0\E/g}) { + \$this->${1:property} = \$${1/[A-Z]+/_\L$0\E/g}; + return \$this; +} + +${2:public} function get${1/./\u$0/}() { + return \$this->$1; +} + +$0 + name + PHP Property + scope + source.php + tabTrigger + prop + uuid + 7C1971CD-6BC0-433B-8604-9F008B6CC29D + + diff --git a/resources/textmate/trailing_whitespace.tmMacro b/resources/textmate/trailing_whitespace.tmMacro new file mode 100644 index 0000000..27c1921 --- /dev/null +++ b/resources/textmate/trailing_whitespace.tmMacro @@ -0,0 +1,43 @@ + + + + + commands + + + argument + + beforeRunningCommand + nop + command + perl -pe 's/[\t ]+$//g' + input + document + output + replaceDocument + + command + executeCommandWithOptions: + + + argument + + beforeRunningCommand + saveActiveFile + input + none + output + discard + + command + executeCommandWithOptions: + + + keyEquivalent + @s + name + Remove Trailing Space and Save + uuid + F61A9B5A-A31E-45C0-8A08-968A50664CC3 + +