-
-
Save runkmc/9ba3d021ad724f99dae8 to your computer and use it in GitHub Desktop.
Ultisnip snippets for rubymotion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'FileUtils' | |
File.open('motion.snippets', 'w') do |snippets_file| | |
snippets = {} | |
File.read('tags').each_line do |line| | |
next unless line.match /^\w+:/ | |
line =~ /^(([^:]*):([^\s]*))\s.*/ | |
snippet = $1 | |
method = $2 | |
args = $3 | |
args = args.split(":") | |
snippets[snippet] = {:snippet => snippet, :method => method, :args => args} | |
end | |
snippets.keys.sort.each do |key| | |
snippet = key | |
method = snippets[key][:method] | |
args = snippets[key][:args] | |
named_args = "" | |
last_arg = 1 | |
args.each_with_index do |arg, i| | |
named_args += ", #{arg}:${#{i+2}}" | |
last_arg += 1 | |
end | |
snippets_file.write("snippet #{snippet} \"i\" i\n#{method}(${1}#{named_args})${#{last_arg + 1}}\nendsnippet\n") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment