Permalink
Browse files

add labeled arguments and some UI polish

git-svn-id: http://svn.textmate.org/trunk/Bundles/OCaml Experimental Completions.tmbundle@6532 dfb7d73b-c2ec-0310-8fea-fb051d288c6d
  • Loading branch information...
1 parent 7e0be06 commit 4ecb8206a370f0f5cad405e9c36347bc2223a0c2 David Powers committed Feb 5, 2007
@@ -60,22 +60,37 @@ def convert_to_snippet str
if last == '-' and depth == 0
args << token.join.chomp('-').strip
token = []
+ else
+ token << c
end
else
token << c
end
last = c
end
- args << token.join.chomp('-').strip
- args = args.map_i { |i, a| "\$\{#{i+1}:#{e_sn(a.strip)}\}" }
+ i = 1
+ args = args.map do |a|
+ a.strip!
+ i += 1
+ if a =~ /^\S+:/
+ if a =~ /^\?/
+ i += 1
+ "\$\{#{i - 1}:~#{a[/^\S+:/]}\$\{#{i}:#{e_sn(a[/:(.*)$/, 1])}\}}"
+ else
+ "~#{a[/^\S+:/]}\$\{#{i}:#{e_sn(a[/:(.*)$/, 1])}\}"
+ end
+ else
+ "\$\{#{i}:#{e_sn(a)}\}"
+ end
+ end
snippet = "#{funname} #{args.join(' ')}"
e_sn($line[0...$linepos]) + snippet + e_sn($line[$linepos..-1])
end
modulename = extract_module_from_line
-possible_completions = OCamlCompletion::cmigrep('.', :values, [modulename]).split(/\n/)
+possible_completions = OCamlCompletion::cmigrep('.', :values, [modulename]).split(/\n/).select { |l| l !~ /^(from file|external)/ }.sort.uniq
possible_completions = possible_completions.map do |c|
chash = Hash.new
chash['completion'] = c
@@ -93,7 +108,9 @@ choice = PropertyList.load(cio.read)
if !choice['returnButton'] || choice['returnButton'] != 'Cancel'
selection = choice['result']['returnArgument'].to_i
snippettxt = plist['possibleCompletions'][selection]['completion']
- puts convert_to_snippet(snippettxt)
+ print convert_to_snippet(snippettxt)
+else
+ print e_sn($line)
end
</string>
<key>fallbackInput</key>
Binary file not shown.

0 comments on commit 4ecb820

Please sign in to comment.