summaryrefslogtreecommitdiff
path: root/runtime/doc/vim9.txt
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/doc/vim9.txt')
-rw-r--r--runtime/doc/vim9.txt15
1 files changed, 12 insertions, 3 deletions
diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt
index 7af10024a..ce5e5078f 100644
--- a/runtime/doc/vim9.txt
+++ b/runtime/doc/vim9.txt
@@ -1,4 +1,4 @@
-*vim9.txt* For Vim version 8.2. Last change: 2022 Mar 28
+*vim9.txt* For Vim version 8.2. Last change: 2022 Mar 30
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -185,7 +185,7 @@ For now you will need to pass the dictionary explicitly: >
echo d[arg]
enddef
var ad = {item: 'value', func: DictFunc}
- ad.func(d, 'item')
+ ad.func(ad, 'item')
You can call a legacy dict function though: >
func Legacy() dict
@@ -1745,7 +1745,8 @@ actually needed. Using the autoload mechanism is recommended:
The "autoload" argument to `:import` means that the script is not loaded
until one of the items is actually used. The script will be found under
the "autoload" directory in 'runtimepath' instead of the "import"
- directory.
+ directory. Alternatively a relative or absolute name can be used, see
+ below.
2. In the autoload script put the bulk of the code. >
vim9script
@@ -1765,6 +1766,14 @@ actually needed. Using the autoload mechanism is recommended:
You can split up the functionality and import other scripts from the
autoload script as you like. This way you can share code between plugins.
+Searching for the autoload script in all entries in 'runtimepath' can be a bit
+slow. If the plugin knows where the script is located, quite often a relative
+path can be used. This avoids the search and should be quite a bit faster.
+Another advantage is that the script name does not need to be unique. An
+absolute path is also possible. Examples: >
+ import autoload '../lib/implement.vim'
+ import autoload MyScriptsDir .. '/lib/implement.vim'
+
For defining a mapping that uses the imported autoload script the special key
|<ScriptCmd>| is useful. It allows for a command in a mapping to use the
script context of where the mapping was defined.