-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for sourcing a Vim9 script from a buffer #9974
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9974 +/- ##
==========================================
- Coverage 81.91% 81.74% -0.18%
==========================================
Files 167 167
Lines 187269 187229 -40
Branches 42201 42202 +1
==========================================
- Hits 153409 153044 -365
- Misses 21516 21813 +297
- Partials 12344 12372 +28
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Can it source the following:
|
We can keep using sourcing_a_script(), hide the details of how that is decided. I don't think we should try to be clever and detect the kind of script. If someone sources some sequence of buffer lines we can't really know whether they are legacy or Vim9 script. They could even be some lines in a help file. We can require using "vim9cmd source". Unless "vim9script" is the first command in the range of lines. We also need to define what happens when sourcing from the same buffer again. I suppose this would work like "vim9script noclear". That way you could, for example, source a function again after modifying it. |
823a6a1
to
fa01bdb
Compare
Hi Bram,
On Sun, Mar 20, 2022 at 3:43 AM Bram Moolenaar ***@***.***> wrote:
We can keep using sourcing_a_script(), hide the details of how that is
decided.
I have updated the PR to restore this function.
I don't think we should try to be clever and detect the kind of script. If
someone sources some sequence of buffer lines we can't really know whether
they are legacy or Vim9 script. They could even be some lines in a help
file. We can require using "vim9cmd source". Unless "vim9script" is the
first command in the range of lines.
Currently the code relies on the first sourced line to detect the script
type and
doesn't try to detect the type of script.
We also need to define what happens when sourcing from the same buffer
again. I suppose this would work like "vim9script noclear". That way you
could, for example, source a function again after modifying it.
Yes. I have added a test for sourcing a Vim9 script with a function
multiple times.
- Yegappan
|
There is a remark in the help about using the same SID when sourcing multiple times. When sourcing just a few lines, e.g. from a help buffer, "vim9cmd source" should work. |
a70a87d
to
17d2229
Compare
Hi,
On Sun, Mar 20, 2022 at 1:19 AM Maxim Kim ***@***.***> wrote:
Can it source the following:
vim9script
def Hello()
var myList = ['multi',
'lined',
'list'
]
echo myList[0]
enddef
nnoremap <F5> <ScriptCmd>Hello()<CR>
:4,7source
:11source -- would proper script context be used here?
?
To source a Vim9 script from a buffer, it must start with "vim9script"
as the first line.
For a legacy script, you can source any range of lines.
- Yegappan
|
I have this operator to run both vimscript and vim9script ranges:
So |
Problem: Sourcing buffer lines is too complicated. Solution: Simplify the code. Make it possible to source Vim9 script lines. (Yegappan Lakshmanan, closes vim/vim#9974) vim/vim@85b43c6 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Problem: Sourcing buffer lines is too complicated. Solution: Simplify the code. Make it possible to source Vim9 script lines. (Yegappan Lakshmanan, closes vim/vim#9974) vim/vim@85b43c6 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Problem: Sourcing buffer lines is too complicated. Solution: Simplify the code. Make it possible to source Vim9 script lines. (Yegappan Lakshmanan, closes vim/vim#9974) vim/vim@85b43c6 vim-patch:9.1.0372: Calling CLEAR_FIELD() on the same struct twice Problem: Calling CLEAR_FIELD() on the same struct twice. Solution: Remove the second CLEAR_FIELD(). Move the assignment of cookie.sourceing_lnum (zeertzjq). closes: vim/vim#14627 vim/vim@f68517c Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
No description provided.