Wednesday, June 2, 2021

Re: Error in Ruby code embedded in vim9script

Yes.

This is in my _vimrc
nnoremap <F6>            :exe '!start '.expand('$vimruntime/gvim.exe').' -c "call readxml\#mainruby()"'<cr>


Under this dir  vimfiles\plugged\readxml\autoload this code is in a script called readxml.vim
vim9script
# MIT License. Copyright (c) 2021 June 02 Niva.

# Ruby code section
def readxml#mainruby()
  call s:rubyCaller() 
enddef

def s:rubyCaller()

#https://ruby-doc.org/core-3.0.0/
#http://www.ohler.com/ox/#label-Object+Dump+Sample-3A

ruby << EOF

# Core
$LOAD_PATH << Vim::evaluate('expand("$vim/extensions/ruby/lib/ruby/3.0.0")')
EOF
enddef


Use Case : then I type <F6>

Thank you Bram.



Le mercredi 2 juin 2021 à 19:23:30 UTC+2, Bram Moolenaar a écrit :

> I got an error using Ruby code embedded in vim9script, seems something has
> changed in vim9script in this case. Like it understand $ as begin of a
> range no ?
>
> Thank you
>
> Error detected while compiling command line..function
> readxml#mainruby[1]..<SNR>131_rubyCaller:
> line 8:
> E1050: Colon required before a range: $LOAD_PATH <<
> Vim::evaluate('expand("$vim/extensions/ruby/lib/ruby/3.0.0")')
>
>
> This is the code
>
> vim9script
> # MIT License. Copyright (c) 2021 June 02 Niva.
>
> # Ruby code section
> def readxml#mainruby()
> call s:rubyCaller()
> enddef
> def s:rubyCaller()
>
>
> ruby << EOF
>
> # Core
> $LOAD_PATH << Vim::evaluate('expand("$vim/extensions/ruby/lib/ruby/3.0.0")')

Your example looks like it's incomplete. Can you give a minimal example
that fails?

--
Citizens are not allowed to attend a movie house or theater nor ride in a
public streetcar within at least four hours after eating garlic.
[real standing law in Indiana, United States of America]

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/a3092d2f-6128-4065-9465-15c53f653dcfn%40googlegroups.com.

No comments: