From d85dbeba7d35e1da1188e80b3537a75c67a247de Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Fri, 5 Feb 2016 13:29:42 +0000 Subject: [PATCH 1/2] Added Validate Syntax command --- Commands/Validate Syntax.tmCommand | 45 ++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Commands/Validate Syntax.tmCommand diff --git a/Commands/Validate Syntax.tmCommand b/Commands/Validate Syntax.tmCommand new file mode 100644 index 0000000..915580a --- /dev/null +++ b/Commands/Validate Syntax.tmCommand @@ -0,0 +1,45 @@ + + + + + beforeRunningCommand + nop + command + #!/usr/bin/env ruby18 +require ENV['TM_SUPPORT_PATH'] + '/lib/textmate' +require 'yaml' + +begin + YAML.load(STDIN.read) +rescue ArgumentError => error +end + +if error.nil? + puts "Valid YAML, no errors" +else + puts "ERROR: ",error.message, "\n" + TextMate.go_to :line => $1, :column => ($2.to_i + 1) if error.message =~ /line (\d+).*col (\d+)/ +end + + input + selection + inputFormat + text + keyEquivalent + ^V + name + Validate Syntax + outputCaret + afterOutput + outputFormat + text + outputLocation + toolTip + scope + source.yaml + uuid + 249C3B83-1F1D-4563-A5B7-DC208820BEA1 + version + 2 + + From c05a201f87bf45deafa6c4506962f35d30562c13 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Fri, 5 Feb 2016 14:51:44 +0000 Subject: [PATCH 2/2] Cleaned up the Validate Syntax command --- Commands/Validate Syntax.tmCommand | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Commands/Validate Syntax.tmCommand b/Commands/Validate Syntax.tmCommand index 915580a..5c1cfc5 100644 --- a/Commands/Validate Syntax.tmCommand +++ b/Commands/Validate Syntax.tmCommand @@ -11,13 +11,9 @@ require 'yaml' begin YAML.load(STDIN.read) -rescue ArgumentError => error -end - -if error.nil? puts "Valid YAML, no errors" -else - puts "ERROR: ",error.message, "\n" +rescue ArgumentError => error + puts error.message TextMate.go_to :line => $1, :column => ($2.to_i + 1) if error.message =~ /line (\d+).*col (\d+)/ end