comparison runtime/autoload/rubycomplete.vim @ 1668:0b796e045c42 v7.2b.000

updated for version 7.2b-000
author vimboss
date Sun, 13 Jul 2008 17:41:49 +0000
parents b9740fb41986
children 7bc41231fbc7
comparison
equal deleted inserted replaced
1667:131dbd3d2a4b 1668:0b796e045c42
299 dprint "load_buffer_module(%s) END" % name 299 dprint "load_buffer_module(%s) END" % name
300 end 300 end
301 301
302 def get_buffer_entity(name, vimfun) 302 def get_buffer_entity(name, vimfun)
303 loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading") 303 loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading")
304 return nil if loading_allowed != '1' 304 return nil if loading_allowed.to_i.zero?
305 return nil if /(\"|\')+/.match( name ) 305 return nil if /(\"|\')+/.match( name )
306 buf = VIM::Buffer.current 306 buf = VIM::Buffer.current
307 nums = eval( VIM::evaluate( vimfun % name ) ) 307 nums = eval( VIM::evaluate( vimfun % name ) )
308 return nil if nums == nil 308 return nil if nums == nil
309 return nil if nums.min == nums.max && nums.min == 0 309 return nil if nums.min == nums.max && nums.min == 0
366 366
367 def get_buffer_entity_list( type ) 367 def get_buffer_entity_list( type )
368 # this will be a little expensive. 368 # this will be a little expensive.
369 loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading") 369 loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading")
370 allow_aggressive_load = VIM::evaluate("exists('g:rubycomplete_classes_in_global') && g:rubycomplete_classes_in_global") 370 allow_aggressive_load = VIM::evaluate("exists('g:rubycomplete_classes_in_global') && g:rubycomplete_classes_in_global")
371 return [] if allow_aggressive_load != '1' || loading_allowed != '1' 371 return [] if allow_aggressive_load.to_i.zero? || loading_allowed.to_i.zero?
372 372
373 buf = VIM::Buffer.current 373 buf = VIM::Buffer.current
374 eob = buf.length 374 eob = buf.length
375 ret = [] 375 ret = []
376 rg = 1..eob 376 rg = 1..eob
399 end 399 end
400 400
401 401
402 def load_rails 402 def load_rails
403 allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") 403 allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails")
404 return if allow_rails != '1' 404 return if allow_rails.to_i.zero?
405 405
406 buf_path = VIM::evaluate('expand("%:p")') 406 buf_path = VIM::evaluate('expand("%:p")')
407 file_name = VIM::evaluate('expand("%:t")') 407 file_name = VIM::evaluate('expand("%:t")')
408 vim_dir = VIM::evaluate('getcwd()') 408 vim_dir = VIM::evaluate('getcwd()')
409 file_dir = buf_path.gsub( file_name, '' ) 409 file_dir = buf_path.gsub( file_name, '' )
459 end 459 end
460 460
461 def get_rails_helpers 461 def get_rails_helpers
462 allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") 462 allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails")
463 rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded') 463 rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded')
464 return [] if allow_rails != '1' || rails_loaded != '1' 464 return [] if allow_rails.to_i.zero? || rails_loaded.to_i.zero?
465 465
466 buf_path = VIM::evaluate('expand("%:p")') 466 buf_path = VIM::evaluate('expand("%:p")')
467 buf_path.gsub!( /\\/, "/" ) 467 buf_path.gsub!( /\\/, "/" )
468 path_elm = buf_path.split( "/" ) 468 path_elm = buf_path.split( "/" )
469 dprint "buf_path: %s" % buf_path 469 dprint "buf_path: %s" % buf_path
509 end 509 end
510 510
511 def add_rails_columns( cls ) 511 def add_rails_columns( cls )
512 allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") 512 allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails")
513 rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded') 513 rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded')
514 return [] if allow_rails != '1' || rails_loaded != '1' 514 return [] if allow_rails.to_i.zero? || rails_loaded.to_i.zero?
515 515
516 begin 516 begin
517 eval( "#{cls}.establish_connection" ) 517 eval( "#{cls}.establish_connection" )
518 return [] unless eval( "#{cls}.ancestors.include?(ActiveRecord::Base).to_s" ) 518 return [] unless eval( "#{cls}.ancestors.include?(ActiveRecord::Base).to_s" )
519 col = eval( "#{cls}.column_names" ) 519 col = eval( "#{cls}.column_names" )
532 end 532 end
533 533
534 def get_rails_view_methods 534 def get_rails_view_methods
535 allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") 535 allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails")
536 rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded') 536 rails_loaded = VIM::evaluate('s:rubycomplete_rails_loaded')
537 return [] if allow_rails != '1' || rails_loaded != '1' 537 return [] if allow_rails.to_i.zero? || rails_loaded.to_i.zero?
538 538
539 buf_path = VIM::evaluate('expand("%:p")') 539 buf_path = VIM::evaluate('expand("%:p")')
540 buf_path.gsub!( /\\/, "/" ) 540 buf_path.gsub!( /\\/, "/" )
541 pelm = buf_path.split( "/" ) 541 pelm = buf_path.split( "/" )
542 idx = pelm.index( "views" ) 542 idx = pelm.index( "views" )
578 b.get_completions base 578 b.get_completions base
579 end 579 end
580 580
581 def get_completions(base) 581 def get_completions(base)
582 loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading") 582 loading_allowed = VIM::evaluate("exists('g:rubycomplete_buffer_loading') && g:rubycomplete_buffer_loading")
583 if loading_allowed == '1' 583 if loading_allowed.to_i == 1
584 load_requires 584 load_requires
585 load_rails 585 load_rails
586 end 586 end
587 587
588 input = VIM::Buffer.current.line 588 input = VIM::Buffer.current.line