Mercurial > vim
comparison runtime/autoload/rubycomplete.vim @ 15512:f0f06837a699
Update runtime files.
commit https://github.com/vim/vim/commit/d09091d4955c5f41de69928f2db85611ed54ed23
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 17 16:07:22 2019 +0100
Update runtime files.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 17 Jan 2019 16:15:08 +0100 |
parents | 57b2b8268d3a |
children | 70ce979e76bc |
comparison
equal
deleted
inserted
replaced
15511:f41122780189 | 15512:f0f06837a699 |
---|---|
1 " Vim completion script | 1 " Vim completion script |
2 " Language: Ruby | 2 " Language: Ruby |
3 " Maintainer: Mark Guzman <segfault@hasno.info> | 3 " Maintainer: Mark Guzman <segfault@hasno.info> |
4 " URL: https://github.com/vim-ruby/vim-ruby | 4 " URL: https://github.com/vim-ruby/vim-ruby |
5 " Release Coordinator: Doug Kearns <dougkearns@gmail.com> | 5 " Release Coordinator: Doug Kearns <dougkearns@gmail.com> |
6 " Maintainer Version: 0.8.1 | 6 " Last Change: 2019 Jan 06 |
7 " ---------------------------------------------------------------------------- | 7 " ---------------------------------------------------------------------------- |
8 " | 8 " |
9 " Ruby IRB/Complete author: Keiju ISHITSUKA(keiju@ishitsuka.com) | 9 " Ruby IRB/Complete author: Keiju ISHITSUKA(keiju@ishitsuka.com) |
10 " ---------------------------------------------------------------------------- | 10 " ---------------------------------------------------------------------------- |
11 | 11 |
101 call cursor(lastpos[1], lastpos[2]) | 101 call cursor(lastpos[1], lastpos[2]) |
102 return [0,0] | 102 return [0,0] |
103 endif | 103 endif |
104 | 104 |
105 let curpos = getpos(".") | 105 let curpos = getpos(".") |
106 let [enum,ecol] = searchpairpos( crex, '', '\(end\|}\)', 'wr' ) | 106 let [enum,ecol] = searchpairpos( crex, '', '\(end\|}\)', 'W' ) |
107 call cursor(lastpos[1], lastpos[2]) | 107 call cursor(lastpos[1], lastpos[2]) |
108 | 108 |
109 if lnum > enum | 109 if lnum > enum |
110 return [0,0] | 110 return [0,0] |
111 endif | 111 endif |
251 "[]", "[]=", "^", ] | 251 "[]", "[]=", "^", ] |
252 # }}} constants | 252 # }}} constants |
253 | 253 |
254 # {{{ buffer analysis magic | 254 # {{{ buffer analysis magic |
255 def load_requires | 255 def load_requires |
256 | |
257 custom_paths = VIM::evaluate("get(g:, 'rubycomplete_load_paths', [])") | |
258 | |
259 if !custom_paths.empty? | |
260 $LOAD_PATH.concat(custom_paths).uniq! | |
261 end | |
262 | |
256 buf = VIM::Buffer.current | 263 buf = VIM::Buffer.current |
257 enum = buf.line_number | 264 enum = buf.line_number |
258 nums = Range.new( 1, enum ) | 265 nums = Range.new( 1, enum ) |
259 nums.each do |x| | 266 nums.each do |x| |
267 | |
260 ln = buf[x] | 268 ln = buf[x] |
261 begin | 269 begin |
262 eval( "require %s" % $1 ) if /.*require\s*(.*)$/.match( ln ) | 270 if /.*require_relative\s*(.*)$/.match( ln ) |
263 rescue Exception | 271 eval( "require %s" % File.expand_path($1) ) |
264 #ignore? | 272 elsif /.*require\s*(["'].*?["'])/.match( ln ) |
273 eval( "require %s" % $1 ) | |
274 end | |
275 rescue Exception => e | |
276 dprint e.inspect | |
265 end | 277 end |
266 end | 278 end |
267 end | 279 end |
268 | 280 |
269 def load_gems | 281 def load_gems |
342 | 354 |
343 nums.each do |x| | 355 nums.each do |x| |
344 if x != cur_line | 356 if x != cur_line |
345 next if x == 0 | 357 next if x == 0 |
346 ln = buf[x] | 358 ln = buf[x] |
347 if /^\s*(module|class|def|include)\s+/.match(ln) | 359 is_const = false |
348 clscnt += 1 if $1 == "class" | 360 if /^\s*(module|class|def|include)\s+/.match(ln) || is_const = /^\s*?[A-Z]([A-z]|[1-9])*\s*?[|]{0,2}=\s*?.+\s*?/.match(ln) |
361 clscnt += 1 if /class|module/.match($1) | |
362 # We must make sure to load each constant only once to avoid errors | |
363 if is_const | |
364 ln.gsub!(/\s*?[|]{0,2}=\s*?/, '||=') | |
365 end | |
349 #dprint "\$1$1 | 366 #dprint "\$1$1 |
350 classdef += "%s\n" % ln | 367 classdef += "%s\n" % ln |
351 classdef += "end\n" if /def\s+/.match(ln) | 368 classdef += "end\n" if /def\s+/.match(ln) |
352 dprint ln | 369 dprint ln |
353 end | 370 end |
420 end | 437 end |
421 | 438 |
422 def get_buffer_classes | 439 def get_buffer_classes |
423 return get_buffer_entity_list( "class" ) | 440 return get_buffer_entity_list( "class" ) |
424 end | 441 end |
425 | |
426 | 442 |
427 def load_rails | 443 def load_rails |
428 allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") | 444 allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") |
429 return if allow_rails.to_i.zero? | 445 return if allow_rails.to_i.zero? |
430 | 446 |
527 when "db" | 543 when "db" |
528 ret += ActiveRecord::ConnectionAdapters::SchemaStatements.instance_methods | 544 ret += ActiveRecord::ConnectionAdapters::SchemaStatements.instance_methods |
529 ret += ActiveRecord::ConnectionAdapters::SchemaStatements.methods | 545 ret += ActiveRecord::ConnectionAdapters::SchemaStatements.methods |
530 end | 546 end |
531 | 547 |
532 | |
533 return ret | 548 return ret |
534 end | 549 end |
535 | 550 |
536 def add_rails_columns( cls ) | 551 def add_rails_columns( cls ) |
537 allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") | 552 allow_rails = VIM::evaluate("exists('g:rubycomplete_rails') && g:rubycomplete_rails") |
585 # }}} buffer analysis magic | 600 # }}} buffer analysis magic |
586 | 601 |
587 # {{{ main completion code | 602 # {{{ main completion code |
588 def self.preload_rails | 603 def self.preload_rails |
589 a = VimRubyCompletion.new | 604 a = VimRubyCompletion.new |
590 require 'Thread' | 605 if VIM::evaluate("has('nvim')") == 0 |
591 Thread.new(a) do |b| | 606 require 'thread' |
592 begin | 607 Thread.new(a) do |b| |
593 b.load_rails | 608 begin |
594 rescue | 609 b.load_rails |
610 rescue | |
611 end | |
595 end | 612 end |
596 end | 613 end |
597 a.load_rails | 614 a.load_rails |
598 rescue | 615 rescue |
599 end | 616 end |
610 load_rails | 627 load_rails |
611 end | 628 end |
612 | 629 |
613 want_gems = VIM::evaluate("get(g:, 'rubycomplete_load_gemfile')") | 630 want_gems = VIM::evaluate("get(g:, 'rubycomplete_load_gemfile')") |
614 load_gems unless want_gems.to_i.zero? | 631 load_gems unless want_gems.to_i.zero? |
615 | |
616 | 632 |
617 input = VIM::Buffer.current.line | 633 input = VIM::Buffer.current.line |
618 cpos = VIM::Window.current.cursor[1] - 1 | 634 cpos = VIM::Window.current.cursor[1] - 1 |
619 input = input[0..cpos] | 635 input = input[0..cpos] |
620 input += base | 636 input += base |
664 when /^(((::)?[A-Z][^:.\(]*)+?)::?([^:.]*)$/ # Constant or class methods | 680 when /^(((::)?[A-Z][^:.\(]*)+?)::?([^:.]*)$/ # Constant or class methods |
665 receiver = $1 | 681 receiver = $1 |
666 message = Regexp.quote($4) | 682 message = Regexp.quote($4) |
667 dprint "const or cls 2 [recv: \'%s\', msg: \'%s\']" % [ receiver, message ] | 683 dprint "const or cls 2 [recv: \'%s\', msg: \'%s\']" % [ receiver, message ] |
668 load_buffer_class( receiver ) | 684 load_buffer_class( receiver ) |
685 load_buffer_module( receiver ) | |
669 begin | 686 begin |
670 classes = eval("#{receiver}.constants") | 687 classes = eval("#{receiver}.constants") |
671 #methods = eval("#{receiver}.methods") | 688 #methods = eval("#{receiver}.methods") |
672 rescue Exception | 689 rescue Exception |
673 dprint "exception: %s" % $! | 690 dprint "exception: %s" % $! |
784 | 801 |
785 methods += get_rails_helpers | 802 methods += get_rails_helpers |
786 methods += Kernel.public_methods | 803 methods += Kernel.public_methods |
787 end | 804 end |
788 | 805 |
789 | |
790 include_object = VIM::evaluate("exists('g:rubycomplete_include_object') && g:rubycomplete_include_object") | 806 include_object = VIM::evaluate("exists('g:rubycomplete_include_object') && g:rubycomplete_include_object") |
791 methods = clean_sel( methods, message ) | 807 methods = clean_sel( methods, message ) |
792 methods = (methods-Object.instance_methods) if include_object == "0" | 808 methods = (methods-Object.instance_methods) if include_object == "0" |
793 rbcmeth = (VimRubyCompletion.instance_methods-Object.instance_methods) # lets remove those rubycomplete methods | 809 rbcmeth = (VimRubyCompletion.instance_methods-Object.instance_methods) # lets remove those rubycomplete methods |
794 methods = (methods-rbcmeth) | 810 methods = (methods-rbcmeth) |
827 let s:rubycomplete_rails_loaded = 0 | 843 let s:rubycomplete_rails_loaded = 0 |
828 | 844 |
829 call s:DefRuby() | 845 call s:DefRuby() |
830 "}}} ruby-side code | 846 "}}} ruby-side code |
831 | 847 |
832 | |
833 " vim:tw=78:sw=4:ts=8:et:fdm=marker:ft=vim:norl: | 848 " vim:tw=78:sw=4:ts=8:et:fdm=marker:ft=vim:norl: |