diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-01 12:17:00 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-01 12:17:00 +0000 |
commit | b79ee0c299d786627784f7304ba84b80e78ece26 (patch) | |
tree | 8c7d0b09c3592f3bb221fabf4d0ff5ae86abf216 | |
parent | 654b729c4c9951f2a46c161d1e9fefdc223fc94e (diff) | |
download | vim-git-b79ee0c299d786627784f7304ba84b80e78ece26.tar.gz |
patch 8.2.3965: Vim9: no easy way to check if Vim9 script is supportedv8.2.3965
Problem: Vim9: no easy way to check if Vim9 script is supported.
Solution: Add has('vim9script').
-rw-r--r-- | runtime/doc/vim9.txt | 7 | ||||
-rw-r--r-- | src/evalfunc.c | 1 | ||||
-rw-r--r-- | src/testdir/test_vim9_script.vim | 17 | ||||
-rw-r--r-- | src/version.c | 2 |
4 files changed, 22 insertions, 5 deletions
diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt index 1dde731ff..e79e06e5b 100644 --- a/runtime/doc/vim9.txt +++ b/runtime/doc/vim9.txt @@ -391,8 +391,8 @@ later. Example: > endif enddef -If you would do it like this you get an error at compile time that -"PluginFunc" does not exist, even when "g:loaded_plugin" does not exist: > +If you do it like this, you get an error at compile time that "PluginFunc" +does not exist, even when "g:loaded_plugin" does not exist: > def CallPluginFunc() if exists('g:loaded_plugin') PluginFunc() # Error - function not found @@ -1411,9 +1411,6 @@ This can only work in two ways: 2. The "if" statement evaluates to true, the commands up to `endif` are executed and `finish` bails out before reaching `vim9script`. -TODO: The "vim9script" feature does not exist yet, it will only be added once -the Vim9 script syntax has been fully implemented. - Export ~ *:export* *:exp* diff --git a/src/evalfunc.c b/src/evalfunc.c index 9b49d81e8..d61797ae3 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -5929,6 +5929,7 @@ f_has(typval_T *argvars, typval_T *rettv) 0 #endif }, + {"vim9script", 1}, {"vimscript-1", 1}, {"vimscript-2", 1}, {"vimscript-3", 1}, diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim index f79112ea9..8aea26759 100644 --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -7,6 +7,23 @@ source vim9.vim source shared.vim source screendump.vim +def Test_vim9script_feature() + # example from the help, here the feature is always present + var lines =<< trim END + " old style comment + if !has('vim9script') + " legacy commands would go here + finish + endif + vim9script + # Vim9 script commands go here + g:didit = true + END + CheckScriptSuccess(lines) + assert_equal(true, g:didit) + unlet g:didit +enddef + def Test_range_only() new setline(1, ['blah', 'Blah']) diff --git a/src/version.c b/src/version.c index db91b29a7..649954870 100644 --- a/src/version.c +++ b/src/version.c @@ -750,6 +750,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 3965, +/**/ 3964, /**/ 3963, |