summaryrefslogtreecommitdiffstats
path: root/runtime/doc/vim9.txt
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-10-01 15:32:46 +0100
committerBram Moolenaar <Bram@vim.org>2022-10-01 15:32:46 +0100
commit87b4e5c5db9d1cfd6f2e79656e1a6cff3c69d15f (patch)
treea437917654ad79edd9764b4f67af33ce01228d6a /runtime/doc/vim9.txt
parent145d1fd91041bd2a22a11eef0357702e420796e2 (diff)
patch 9.0.0632: calling a function from an "expr" option has overheadv9.0.0632
Problem: Calling a function from an "expr" option has too much overhead. Solution: Add call_simple_func() and use it for 'foldexpr'
Diffstat (limited to 'runtime/doc/vim9.txt')
-rw-r--r--runtime/doc/vim9.txt15
1 files changed, 15 insertions, 0 deletions
diff --git a/runtime/doc/vim9.txt b/runtime/doc/vim9.txt
index b73011a092..15e9a702bc 100644
--- a/runtime/doc/vim9.txt
+++ b/runtime/doc/vim9.txt
@@ -1410,6 +1410,21 @@ to a Vim9 function:
'three'
]
+
+Calling a function in an expr option ~
+ *expr-option-function*
+A few options, such as 'foldexpr', are an expresison that is evaluated to get
+a value. The evaluation can have quite a bit of overhead. One way to
+minimize the overhead, and also to keep the option value very simple, is to
+defined a compiled function and set the option to call it without arguments.
+Example: >
+ vim9script
+ def MyFoldFunc(): any
+ ... compute fold level for line v:lnum
+ return level
+ enddef
+ set foldexpr=s:MyFoldFunc()
+
==============================================================================
4. Types *vim9-types*