/
completion.rb
28 lines (27 loc) · 1.36 KB
/
completion.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# You shouldn't place Bond.complete statements before requiring this file
# unless you're also reproducing this Bond.debrief
Bond.debrief(:default_search=>:underscore) unless Bond.config[:default_search]
Bond.debrief(:default_mission=>:default) unless Bond.config[:default_mission]
Bond.complete(:method=>/system|`/, :action=>:shell_commands)
Bond.complete(:method=>'require', :action=>:method_require, :search=>false)
# irb/completion reproduced without the completion quirks
# Completes classes and constants
Bond.complete(:on=>/(((::)?[A-Z][^:.\(]*)+)::?([^:.]*)$/, :action=>:constants, :search=>false)
# Completes absolute constants
Bond.complete(:on=>/::([A-Z][^:\.\(]*)$/, :search=>false) {|e|
Object.constants.grep(/^#{Regexp.escape(e.matched[1])}/).collect{|f| "::" + f}
}
# Completes symbols
Bond.complete(:on=>/(:[^:\s.]*)$/) {|e|
Symbol.respond_to?(:all_symbols) ? Symbol.all_symbols.map {|f| ":#{f}" } : []
}
# Completes global variables
Bond.complete(:on=>/(\$[^\s.]*)$/, :search=>false) {|e|
global_variables.grep(/^#{Regexp.escape(e.matched[1])}/)
}
# Completes files
Bond.complete(:on=>/[\s(]["']([^'"]*)$/, :search=>false, :action=>:quoted_files, :place=>:last)
# Completes any object's methods
Bond.complete(:object=>"Object", :place=>:last)
# Completes method completion anywhere in the line
Bond.complete(:on=>/([^.\s]+)\.([^.\s]*)$/, :object=>"Object", :place=>:last)