33"
44" See https://github.com/vim-jp/vital.vim for vital module.
55
6- let s: VimLParser = vital#vimlparser#import (' VimlParser' ).import ()
6+ call extend ( s: , vital#vimlparser#import (' VimlParser' ).import () )
77
88" To Vim plugin developer who want to depend on vim-vimlparser:
99" Please use vimlparser as vital-module instead of this autoload function.
1010" We do not ensure that future changes are backward compatible.
1111function ! vimlparser#import ()
12- return s: VimLParser
12+ return s:
1313endfunction
1414
1515" @brief Read input as VimScript and return stringified AST.
@@ -31,3 +31,32 @@ function! vimlparser#test(input, ...)
3131 echoerr substitute (v: throwpoint , ' \.\.\zs\d\+' , ' \=s:numtoname(submatch(0))' , ' g' ) . " \n " . v: exception
3232 endtry
3333endfunction
34+
35+ if has (' patch-7.4.1842' )
36+ function ! s: numtoname (num)
37+ for k in keys (s: )
38+ if type (s: [k ]) == type ({})
39+ for name in keys (s: [k ])
40+ if type (s: [k ][name]) == type (function (' tr' )) && get (s: [k ][name], ' name' ) == a: num
41+ return printf (' %s.%s' , k , name)
42+ endif
43+ endfor
44+ endif
45+ endfor
46+ return a: num
47+ endfunction
48+ else
49+ function ! s: numtoname (num)
50+ let sig = printf (" function('%s')" , a: num )
51+ for k in keys (s: )
52+ if type (s: [k ]) == type ({})
53+ for name in keys (s: [k ])
54+ if type (s: [k ][name]) == type (function (' tr' )) && string (s: [k ][name]) == sig
55+ return printf (' %s.%s' , k , name)
56+ endif
57+ endfor
58+ endif
59+ endfor
60+ return a: num
61+ endfunction
62+ endif
0 commit comments