[vim/vim] Include Vim9 script support (#5530)

115 views
Skip to first unread message

Bram Moolenaar

unread,
Jan 25, 2020, 11:44:52 AM1/25/20
to vim/vim, Subscribed

Still experimental, but ready to include in the base code.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/5530

Commit Summary

  • Rewrite README.md.
  • Extend and improve the READMe file.
  • Add first version of Vim script support.
  • Merge remote-tracking branch 'upstream/master'
  • Merge remote-tracking branch 'upstream/master'
  • Add more builtin function return types.
  • Adjust vim plugins for vim9 syntax
  • Add more return types to builtin functions.
  • Add more return types to builtin functions.
  • Merge remote-tracking branch 'upstream/master'
  • Add more return types to builtin functions.
  • Add the remaining return types to builtin functions.
  • Merge remote-tracking branch 'upstream/master'
  • Initial exception handling. Cleanups.
  • Merge remote-tracking branch 'upstream/master'
  • Remove support for } to end any block.
  • Do not use 'ignorecase' for comperators.
  • Implement compiling and executing :throw
  • Make "true" and "false" work.
  • Merge remote-tracking branch 'upstream/master'
  • Support more types for computation instructions.
  • Merge remote-tracking branch 'upstream/master'
  • Add tentative plans for export and import.
  • Add more tests for computations, fix bug.
  • Support more types for operators.
  • Merge remote-tracking branch 'upstream/master'
  • Stricter type checking for comperators.
  • More specific comperator execution and tests.
  • Add :export, :import and :namespace
  • Merge remote-tracking branch 'upstream/master'
  • Implement some of :namespace
  • Rename the namespace command to vim9script.
  • First stab at implementing :export
  • Merge remote-tracking branch 'upstream/master'
  • First stab at :import.
  • Make import work with a function.
  • Make :import with absolute path and 'runtimepath' work
  • Merge remote-tracking branch 'upstream/master'
  • Make setting an option work.
  • Make heredoc and script-local vars work.
  • Make import from 'runtimepath' work.
  • Rename the "vim9" directory to "import", update docs.
  • Make more script-local items work.
  • Merge remote-tracking branch 'upstream/master'
  • Use one allocation for a fixed size list.
  • Make varagrs work.
  • Reset 'cpo' in Vim9 script.
  • Merge remote-tracking branch 'upstream/master'
  • Make reloading a script work.
  • Make it possible to use import inside function.
  • Documentation edits
  • Merge remote-tracking branch 'upstream/master'

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

lgtm-com[bot]

unread,
Jan 25, 2020, 12:00:22 PM1/25/20
to vim/vim, Subscribed

This pull request introduces 1 alert when merging 4c81df1 into 1d9215b - view on LGTM.com

new alerts:

  • 1 for Missing header guard

Bram Moolenaar

unread,
Jan 25, 2020, 1:01:07 PM1/25/20
to vim/vim, Push

@brammool pushed 1 commit.


You are receiving this because you are subscribed to this thread.

View it on GitHub or unsubscribe.

lgtm-com[bot]

unread,
Jan 25, 2020, 1:16:15 PM1/25/20
to vim/vim, Subscribed

This pull request introduces 1 alert when merging c3a10ab into 1d9215b - view on LGTM.com

new alerts:

  • 1 for Missing header guard

Bram Moolenaar

unread,
Jan 25, 2020, 2:54:10 PM1/25/20
to vim/vim, Push

@brammool pushed 1 commit.


You are receiving this because you are subscribed to this thread.

lgtm-com[bot]

unread,
Jan 25, 2020, 3:10:33 PM1/25/20
to vim/vim, Subscribed

This pull request introduces 1 alert when merging c61bd76 into 1d9215b - view on LGTM.com

new alerts:

  • 1 for Missing header guard

Bram Moolenaar

unread,
Jan 25, 2020, 3:19:43 PM1/25/20
to vim/vim, Push

@brammool pushed 1 commit.

  • 0705151 Fix broken build and tests.


You are receiving this because you are subscribed to this thread.

lgtm-com[bot]

unread,
Jan 25, 2020, 3:34:35 PM1/25/20
to vim/vim, Subscribed

This pull request introduces 1 alert when merging 0705151 into 1d9215b - view on LGTM.com

new alerts:

  • 1 for Missing header guard

Bram Moolenaar

unread,
Jan 25, 2020, 3:56:51 PM1/25/20
to vim/vim, Push

@brammool pushed 1 commit.


You are receiving this because you are subscribed to this thread.

lgtm-com[bot]

unread,
Jan 25, 2020, 4:11:07 PM1/25/20
to vim/vim, Subscribed

This pull request introduces 1 alert when merging b02bd8b into 1d9215b - view on LGTM.com

new alerts:

  • 1 for Missing header guard

Bram Moolenaar

unread,
Jan 25, 2020, 4:46:26 PM1/25/20
to vim/vim, Push

@brammool pushed 1 commit.

  • d5f7c6d Fix tests on Mac and FreeBSD.


You are receiving this because you are subscribed to this thread.

lgtm-com[bot]

unread,
Jan 25, 2020, 5:00:57 PM1/25/20
to vim/vim, Subscribed

This pull request introduces 1 alert when merging d5f7c6d into 1d9215b - view on LGTM.com

new alerts:

  • 1 for Missing header guard

mattn

unread,
Jan 26, 2020, 1:02:01 AM1/26/20
to vim/vim, Subscribed

This seems breaking compatibility with if_python3.

function! s:foo()
let py = 'python3'
execute py "<< EOF"
def do_something():
  return 1
EOF
endfunction
Error detected while processing C:\dev\vim9\src\fooo.vim:                                                                                                                                                                                    line    8:                                                                                                                                                                                                                                   E126: Missing :endfunction 

mattn

unread,
Jan 26, 2020, 6:28:51 AM1/26/20
to vim/vim, Subscribed
  let echo = 10
  edit += 20
  echo edit

This show 20 but

  let echo = 10
  unlet edit
  edit += 20

This open new file. I wonder user possibly confuse.

Bram Moolenaar

unread,
Jan 26, 2020, 8:09:49 AM1/26/20
to vim/vim, Push

@brammool pushed 1 commit.

  • 6fe9033 Fix that pointer is invalid after adding script.


You are receiving this because you are subscribed to this thread.

lgtm-com[bot]

unread,
Jan 26, 2020, 8:24:37 AM1/26/20
to vim/vim, Subscribed

This pull request introduces 1 alert when merging 6fe9033 into 1d9215b - view on LGTM.com

new alerts:

  • 1 for Missing header guard

Codecov

unread,
Jan 26, 2020, 8:31:37 AM1/26/20
to vim/vim, Subscribed

Codecov Report

❗️ No coverage uploaded for pull request base (master@f85fe0c). Click here to learn what that means.
The diff coverage is 80.32%.

Impacted file tree graph

@@            Coverage Diff            @@

##             master    #5530   +/-   ##

=========================================

  Coverage          ?   82.75%           

=========================================

  Files             ?      137           

  Lines             ?   151549           

  Branches          ?        0           

=========================================

  Hits              ?   125407           

  Misses            ?    26142           

  Partials          ?        0
Impacted Files Coverage Δ
src/term.c 81.38% <ø> (ø)
src/scriptfile.c 90.79% <ø> (ø)
src/version.c 92.1% <ø> (ø)
src/insexpand.c 88.4% <ø> (ø)
src/ex_docmd.c 84.05% <ø> (ø)
src/evalvars.c 86.09% <0%> (ø)
src/list.c 90.21% <0%> (ø)
src/evalfunc.c 91.65% <100%> (ø)
src/vim9execute.c 61.46% <50%> (ø)
src/vim9script.c 67.56% <71.42%> (ø)
... and 3 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f85fe0c...6fe9033. Read the comment docs.

Bram Moolenaar

unread,
Jan 26, 2020, 8:44:50 AM1/26/20
to vim...@googlegroups.com, mattn

Yasuhiro Matsumoto wrote:

> ```
> let echo = 10
> edit += 20
> echo edit
> ```
> This show 20 but

I get "undefined variable: edit. Did you mean:

let edit = 10
edit += 10
echo edit

Somehow that doesn't work yet.

> ```
> let echo = 10
> unlet edit
> edit += 20
> ```
> This open new file. I wonder user possibly confuse.

That is not valid code. I haven't yet diallowed "unlet", it should fail
here.

--
You can test a person's importance in the organization by asking how much RAM
his computer has. Anybody who knows the answer to that question is not a
decision-maker.
(Scott Adams - The Dilbert principle)

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

Bram Moolenaar

unread,
Jan 26, 2020, 8:45:14 AM1/26/20
to vim/vim, Subscribed

Yasuhiro Matsumoto wrote:

> This seems breaking compatibility with if_python3.
>
> ```vim

> function! s:foo()
> let py = 'python3'
> execute py "<< EOF"
> def do_something():
> return 1
> EOF
> endfunction
> ```
>
> ```
> Error detected while processing C:\dev\vim9\src\fooo.vim: line 8: E126: Missing :endfunction
> ```

It would also have failed when Python would be using "function".
Since this is using "execute" the parser does not see the "<< EOF" that
would normally make it skip over the Python code.
I think this will just not work.

--
The only way the average employee can speak to an executive is by taking a
second job as a golf caddie.

(Scott Adams - The Dilbert principle)

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

mattn

unread,
Jan 26, 2020, 10:33:22 AM1/26/20
to vim/vim, Subscribed

For users of vim-plug. Vim 9 break compatibility of syntax that using in vim-plug.

image

If you want to fix temporarry:

--- plug.vim.orig	2020-01-27 00:32:28 +0000
+++ plug.vim	2020-01-27 00:32:38 +0000
@@ -1428,8 +1428,7 @@
 endfunction
 
 function! s:update_python()
-let py_exe = has('python') ? 'python' : 'python3'
-execute py_exe "<< EOF"
+python3 << EOF
 import datetime
 import functools
 import os

Bram Moolenaar

unread,
Jan 26, 2020, 11:15:36 AM1/26/20
to vim/vim, Subscribed

Yasuhiro Matsumoto wrote:

> For users of vim-plug. Vim 9 break compatibility of syntax that using
> in vim-plug.
>
> ![image](https://user-images.githubusercontent.com/10111/73137521-64e49800-409c-11ea-8716-497a3f09d9bd.png)

>
> If you want to fix temporarry:
>
> ```diff

> --- plug.vim.orig 2020-01-27 00:32:28 +0000
> +++ plug.vim 2020-01-27 00:32:38 +0000
> @@ -1428,8 +1428,7 @@
> endfunction
>
> function! s:update_python()
> -let py_exe = has('python') ? 'python' : 'python3'
> -execute py_exe "<< EOF"
> +python3 << EOF
> import datetime
> import functools
> import os
> ```

Please check that 8.2.0150 fixes this.

--
Engineers will go without food and hygiene for days to solve a problem.
(Other times just because they forgot.)

(Scott Adams - The Dilbert principle)

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

lacygoill

unread,
Jan 26, 2020, 3:31:38 PM1/26/20
to vim/vim, Subscribed

Please check that 8.2.0150 fixes this.

I can confirm it fixes the issue.

mattn

unread,
Jan 26, 2020, 7:14:35 PM1/26/20
to vim/vim, Subscribed

Please check that 8.2.0150 fixes this.

Confirmed the fix. Thank you.

mattn

unread,
Jan 26, 2020, 7:17:25 PM1/26/20
to vim/vim, Subscribed

I'm thiking that Vim9 script require let to avoid shadowing edit as expression not normal command.

Bram Moolenaar

unread,
Jan 27, 2020, 5:51:07 AM1/27/20
to vim/vim, Subscribed

> I'm thiking that Vim9 script require `let` to avoid shadowing `edit`
> as expression not normal command.

"let" is used for a declaration, using it for assignment will be very
confusing.

If your variable is called "edit", then ":e file" still works.

--
No engineer can take a shower without wondering if some sort of Teflon coating
would make showering unnecessary.

(Scott Adams - The Dilbert principle)

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

Bram Moolenaar

unread,
Jan 30, 2020, 10:29:35 AM1/30/20
to vim/vim, Subscribed

Was included

Bram Moolenaar

unread,
Jan 30, 2020, 10:29:40 AM1/30/20
to vim/vim, Subscribed

Closed #5530.

Reply all
Reply to author
Forward
0 new messages