Skip to content

Commit

Permalink
Update a few runtime files.
Browse files Browse the repository at this point in the history
  • Loading branch information
brammool committed Dec 9, 2019
1 parent 661ed8b commit 2ed639a
Show file tree
Hide file tree
Showing 8 changed files with 504 additions and 413 deletions.
59 changes: 44 additions & 15 deletions runtime/autoload/rubycomplete.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
" Maintainer: Mark Guzman <segfault@hasno.info>
" URL: https://github.com/vim-ruby/vim-ruby
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
" Last Change: 2019 Jan 06
" Last Change: 2019 Feb 25
" ----------------------------------------------------------------------------
"
" Ruby IRB/Complete author: Keiju ISHITSUKA(keiju@ishitsuka.com)
Expand Down Expand Up @@ -53,6 +53,23 @@ if !exists("g:rubycomplete_include_objectspace")
endif
" }}} configuration failsafe initialization

" {{{ regex patterns

" Regex that defines the start-match for the 'end' keyword.
let s:end_start_regex =
\ '\C\%(^\s*\|[=,*/%+\-|;{]\|<<\|>>\|:\s\)\s*\zs' .
\ '\<\%(module\|class\|if\|for\|while\|until\|case\|unless\|begin' .
\ '\|\%(\K\k*[!?]\?\s\+\)\=def\):\@!\>' .
\ '\|\%(^\|[^.:@$]\)\@<=\<do:\@!\>'

" Regex that defines the middle-match for the 'end' keyword.
let s:end_middle_regex = '\<\%(ensure\|else\|\%(\%(^\|;\)\s*\)\@<=\<rescue:\@!\>\|when\|elsif\):\@!\>'

" Regex that defines the end-match for the 'end' keyword.
let s:end_end_regex = '\%(^\|[^.:@$]\)\@<=\<end:\@!\>'

" }}} regex patterns

" {{{ vim-side support functions
let s:rubycomplete_debug = 0

Expand Down Expand Up @@ -103,7 +120,7 @@ function! s:GetBufferRubyEntity( name, type, ... )
endif

let curpos = getpos(".")
let [enum,ecol] = searchpairpos( crex, '', '\(end\|}\)', 'W' )
let [enum,ecol] = searchpairpos( s:end_start_regex, s:end_middle_regex, s:end_end_regex, 'W' )
call cursor(lastpos[1], lastpos[2])

if lnum > enum
Expand All @@ -128,19 +145,28 @@ function! s:IsPosInClassDef(pos)
return ret
endfunction

function! s:IsInComment(pos)
let stack = synstack(a:pos[0], a:pos[1])
if !empty(stack)
return synIDattr(stack[0], 'name') =~ 'ruby\%(.*Comment\|Documentation\)'
else
return 0
endif
endfunction

function! s:GetRubyVarType(v)
let stopline = 1
let vtp = ''
let pos = getpos('.')
let curpos = getpos('.')
let sstr = '^\s*#\s*@var\s*'.escape(a:v, '*').'\>\s\+[^ \t]\+\s*$'
let [lnum,lcol] = searchpos(sstr,'nb',stopline)
if lnum != 0 && lcol != 0
call setpos('.',pos)
call setpos('.',curpos)
let str = getline(lnum)
let vtp = substitute(str,sstr,'\1','')
return vtp
endif
call setpos('.',pos)
call setpos('.',curpos)
let ctors = '\(now\|new\|open\|get_instance'
if exists('g:rubycomplete_rails') && g:rubycomplete_rails == 1 && s:rubycomplete_rails_loaded == 1
let ctors = ctors.'\|find\|create'
Expand All @@ -150,9 +176,13 @@ function! s:GetRubyVarType(v)

let fstr = '=\s*\([^ \t]\+.' . ctors .'\>\|[\[{"''/]\|%[xwQqr][(\[{@]\|[A-Za-z0-9@:\-()\.]\+...\?\|lambda\|&\)'
let sstr = ''.escape(a:v, '*').'\>\s*[+\-*/]*'.fstr
let [lnum,lcol] = searchpos(sstr,'nb',stopline)
if lnum != 0 && lcol != 0
let str = matchstr(getline(lnum),fstr,lcol)
let pos = searchpos(sstr,'bW')
while pos != [0,0] && s:IsInComment(pos)
let pos = searchpos(sstr,'bW')
endwhile
if pos != [0,0]
let [lnum, col] = pos
let str = matchstr(getline(lnum),fstr,col)
let str = substitute(str,'^=\s*','','')

call setpos('.',pos)
Expand All @@ -174,7 +204,7 @@ function! s:GetRubyVarType(v)
end
return ''
endif
call setpos('.',pos)
call setpos('.',curpos)
return ''
endfunction

Expand Down Expand Up @@ -671,11 +701,10 @@ class VimRubyCompletion
methods.delete_if { |c| c.match( /'/ ) }
end

when /^::([A-Z][^:\.\(]*)$/ # Absolute Constant or class methods
when /^::([A-Z][^:\.\(]*)?$/ # Absolute Constant or class methods
dprint "const or cls"
receiver = $1
methods = Object.constants
methods.grep(/^#{receiver}/).collect{|e| "::" + e}
methods = Object.constants.collect{ |c| c.to_s }.grep(/^#{receiver}/)

when /^(((::)?[A-Z][^:.\(]*)+?)::?([^:.]*)$/ # Constant or class methods
receiver = $1
Expand All @@ -684,13 +713,13 @@ class VimRubyCompletion
load_buffer_class( receiver )
load_buffer_module( receiver )
begin
classes = eval("#{receiver}.constants")
#methods = eval("#{receiver}.methods")
constants = eval("#{receiver}.constants").collect{ |c| c.to_s }.grep(/^#{message}/)
methods = eval("#{receiver}.methods").collect{ |m| m.to_s }.grep(/^#{message}/)
rescue Exception
dprint "exception: %s" % $!
constants = []
methods = []
end
methods.grep(/^#{message}/).collect{|e| receiver + "::" + e}

when /^(:[^:.]+)\.([^.]*)$/ # Symbol
dprint "symbol"
Expand Down
3 changes: 1 addition & 2 deletions runtime/doc/pi_logipat.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ Copyright: (c) 2004-2015 by Charles E. Campbell *logiPat-copyright*
is performed and echoed onto the display.

:LogiPatFlags {search flags} *LogiPat-flags*
:LogiPatFlags {search flags}
LogiPat uses the |search()| command. The flags
passed to that call to search() may be specified
by the :LogiPatFlags command.
Expand Down Expand Up @@ -105,7 +104,7 @@ Copyright: (c) 2004-2015 by Charles E. Campbell *logiPat-copyright*


==============================================================================
3. LogiPat History *logiPat-history*
5. LogiPat History *logiPat-history*

v4 Jun 22, 2015 * LogiPat has been picked up by Bram M for standard
plugin distribution; hence the name change
Expand Down
4 changes: 2 additions & 2 deletions runtime/doc/pi_netrw.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*pi_netrw.txt* For Vim version 8.1. Last change: 2019 Nov 30
*pi_netrw.txt* For Vim version 8.1. Last change: 2019 Dec 09

------------------------------------------------
NETRW REFERENCE MANUAL by Charles E. Campbell
Expand Down Expand Up @@ -1184,7 +1184,7 @@ One may easily "bookmark" the currently browsed directory by using >
*.netrwbook*
Bookmarks are retained in between sessions of vim in a file called .netrwbook
as a |List|, which is typically stored in the first directory on the user's
|'runtimepath'|; entries are kept in sorted order.
runtimepath'; entries are kept in sorted order.

If there are marked files and/or directories, mb will add them to the bookmark
list.
Expand Down
4 changes: 3 additions & 1 deletion runtime/doc/todo.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*todo.txt* For Vim version 8.1. Last change: 2019 Dec 07
*todo.txt* For Vim version 8.1. Last change: 2019 Dec 08


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -118,6 +118,8 @@ E290, E292, E362, E366, E450, E451, E452,
E453, E454, E460, E489, E491, E565, E578, E610, E611, E653,
E654, E856, E857, E860, E861, E863, E889, E900

Patch to move duplicated code to a function. (Yegappan Lakshmanan, #5330)

Running test_gui and test_gui_init with Motif sometimes kills the window
manager. Problem with Motif? Now test_gui crashes in submenu_change().
Athena is OK.
Expand Down
20 changes: 10 additions & 10 deletions runtime/doc/version8.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*version8.txt* For Vim version 8.1. Last change: 2019 Dec 08
*version8.txt* For Vim version 8.1. Last change: 2019 Dec 09


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -25831,14 +25831,14 @@ window. This also works for normal windows.
Text properties *new-text-properties*
---------------

Text properties give a plugin author flexibility what to highlight. This can
be used with an external asynchronous parser to do syntax highlighting. Or
to highlight text in a popup window. The text properties stick with the text
when characters are deleted or inserted, which makes them also useful as text
markers. See |text-properties|.
Text properties give a plugin author flexibility about what to highlight.
This can be used with an external asynchronous parser to do syntax
highlighting. Or to highlight text in a popup window. The text properties
stick with the text when characters are deleted or inserted, which makes them
also useful as text markers. See |text-properties|.

The listener functions have been added to report text changes to a server so
that it can dynamically update highligting, mark syntax errors and the like.
that it can dynamically update highlighting, mark syntax errors and the like.
See |listener_add()|.


Expand Down Expand Up @@ -39746,7 +39746,7 @@ Files: src/testdir/test_exit.vim, src/ex_docmd.c

Patch 8.1.2198
Problem: Crash when using :center in autocommand.
Solution: Bail out early for an empty line. (Dominique pelle, closes #5095)
Solution: Bail out early for an empty line. (Dominique Pelle, closes #5095)
Files: src/ex_cmds.c, src/testdir/test_textformat.vim

Patch 8.1.2199
Expand Down Expand Up @@ -40610,7 +40610,7 @@ Solution: Make sure long line does not overflow IObuff. (Dominique Pelle,
Files: src/quickfix.c, src/testdir/test_quickfix.vim

Patch 8.1.2341
Problem: Not so easy to interrupt a script programatically.
Problem: Not so easy to interrupt a script programmatically.
Solution: Add the interrupt() function. (Yasuhiro Matsumoto, closes #2834)
Files: runtime/doc/eval.txt, src/evalfunc.c, src/ex_eval.c,
src/testdir/Make_all.mak, src/testdir/test_interrupt.vim
Expand Down Expand Up @@ -41039,7 +41039,7 @@ Solution: Free the old title. Don't copy expr_line.
Files: src/term.c, src/os_unix.c, src/register.c

Patch 8.1.2407
Problem: proto file and dependenciess outdated.
Problem: proto file and dependencies outdated.
Solution: Update proto files and dependencies.
Files: src/Makefile, src/proto/bufwrite.pro, src/proto/cmdhist.pro,
src/proto/optionstr.pro, src/proto/popupwin.pro,
Expand Down
49 changes: 29 additions & 20 deletions runtime/ftplugin/ruby.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
" URL: https://github.com/vim-ruby/vim-ruby
" Release Coordinator: Doug Kearns <dougkearns@gmail.com>
" Last Change: 2019 Jan 06
" Last Change: 2019 Nov 06

if (exists("b:did_ftplugin"))
finish
Expand All @@ -24,20 +24,20 @@ if exists("loaded_matchit") && !exists("b:match_words")
let b:match_ignorecase = 0

let b:match_words =
\ '\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|def\|begin\)\>=\@!' .
\ '{\|\<\%(if\|unless\|case\|while\|until\|for\|do\|class\|module\|def\|=\@<!begin\)\>=\@!' .
\ ':' .
\ '\<\%(else\|elsif\|ensure\|when\|rescue\|break\|redo\|next\|retry\)\>' .
\ ':' .
\ '\%(^\|[^.\:@$]\)\@<=\<end\:\@!\>' .
\ ',{:},\[:\],(:)'
\ '}\|\%(^\|[^.\:@$=]\)\@<=\<end\:\@!\>' .
\ ',^=begin\>:^=end\>,' .
\ ',\[:\],(:)'

let b:match_skip =
\ "synIDattr(synID(line('.'),col('.'),0),'name') =~ '" .
\ "\\<ruby\\%(String\\|StringDelimiter\\|ASCIICode\\|Escape\\|" .
\ "Regexp\\|RegexpDelimiter\\|" .
\ "Interpolation\\|NoInterpolation\\|Comment\\|Documentation\\|" .
\ "ConditionalModifier\\|RepeatModifier\\|OptionalDo\\|" .
\ "Function\\|BlockArgument\\|KeywordAsMethod\\|ClassVariable\\|" .
\ "\\<ruby\\%(String\\|.\+Delimiter\\|Character\\|.\+Escape\\|" .
\ "Regexp\\|Interpolation\\|Comment\\|Documentation\\|" .
\ "ConditionalModifier\\|RepeatModifier\\|RescueModifier\\|OptionalDo\\|" .
\ "MethodName\\|BlockArgument\\|KeywordAsMethod\\|ClassVariable\\|" .
\ "InstanceVariable\\|GlobalVariable\\|Symbol\\)\\>'"
endif

Expand Down Expand Up @@ -87,7 +87,7 @@ endfunction

function! s:build_path(path) abort
let path = join(map(copy(a:path), 'v:val ==# "." ? "" : v:val'), ',')
if &g:path !~# '\v^\.%(,/%(usr|emx)/include)=,,$'
if &g:path !~# '\v^%(\.,)=%(/%(usr|emx)/include,)=,$'
let path = substitute(&g:path,',,$',',','') . ',' . path
endif
return path
Expand Down Expand Up @@ -152,7 +152,7 @@ endif
function! s:map(mode, flags, map) abort
let from = matchstr(a:map, '\S\+')
if empty(mapcheck(from, a:mode))
exe a:mode.'map' '<buffer>' a:map
exe a:mode.'map' '<buffer>' a:flags a:map
let b:undo_ftplugin .= '|sil! '.a:mode.'unmap <buffer> '.from
endif
endfunction
Expand Down Expand Up @@ -311,13 +311,16 @@ function! s:synid() abort
endfunction

function! s:wrap_i(back,forward) abort
execute 'norm k'.a:forward
execute 'norm! k'
execute 'norm '.a:forward
let line = line('.')
execute 'norm '.a:back
if line('.') == line - 1
return s:wrap_a(a:back,a:forward)
endif
execute 'norm jV'.a:forward.'k'
execute 'norm! jV'
execute 'norm '.a:forward
execute 'norm! k'
endfunction

function! s:wrap_a(back,forward) abort
Expand All @@ -330,11 +333,15 @@ function! s:wrap_a(back,forward) abort
-
endwhile
if exists('after')
execute 'norm V'.a:forward.'j'
execute 'norm! V'
execute 'norm '.a:forward
execute 'norm! j'
elseif line('.') > 1 && getline(line('.')-1) =~# '^\s*$'
execute 'norm kV'.a:forward
execute 'norm! kV'
execute 'norm '.a:forward
else
execute 'norm V'.a:forward
execute 'norm! V'
execute 'norm '.a:forward
endif
endfunction

Expand Down Expand Up @@ -366,7 +373,6 @@ function! RubyCursorFile() abort
endtry
let pre = matchstr(strpart(getline('.'), 0, col('.')-1), '.*\f\@<!')
let post = matchstr(strpart(getline('.'), col('.')), '\f\@!.*')
let ext = getline('.') =~# '^\s*\%(require\%(_relative\)\=\|autoload\)\>' && cfile !~# '\.rb$' ? '.rb' : ''
if s:synid() ==# hlID('rubyConstant')
let cfile = substitute(cfile,'\.\w\+[?!=]\=$','','')
let cfile = substitute(cfile,'^::','','')
Expand All @@ -375,12 +381,15 @@ function! RubyCursorFile() abort
let cfile = substitute(cfile,'\(\l\|\d\)\(\u\)','\1_\2', 'g')
return tolower(cfile) . '.rb'
elseif getline('.') =~# '^\s*require_relative\s*\(["'']\).*\1\s*$'
let cfile = expand('%:p:h') . '/' . matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . ext
let cfile = expand('%:p:h') . '/' . matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1')
let cfile .= cfile !~# '\.rb$' ? '.rb' : ''
elseif getline('.') =~# '^\s*\%(require[( ]\|load[( ]\|autoload[( ]:\w\+,\)\s*\%(::\)\=File\.expand_path(\(["'']\)\.\./.*\1,\s*__FILE__)\s*$'
let target = matchstr(getline('.'),'\(["'']\)\.\.\zs/.\{-\}\ze\1')
let cfile = expand('%:p:h') . target . ext
let cfile = expand('%:p:h') . target
let cfile .= cfile !~# '\.rb$' ? '.rb' : ''
elseif getline('.') =~# '^\s*\%(require \|load \|autoload :\w\+,\)\s*\(["'']\).*\1\s*$'
let cfile = matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1') . ext
let cfile = matchstr(getline('.'),'\(["'']\)\zs.\{-\}\ze\1')
let cfile .= cfile !~# '\.rb$' ? '.rb' : ''
elseif pre.post =~# '\<File.expand_path[( ].*[''"]\{2\}, *__FILE__\>' && cfile =~# '^\.\.'
let cfile = expand('%:p:h') . strpart(cfile, 2)
else
Expand Down
Loading

0 comments on commit 2ed639a

Please sign in to comment.