aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-08-01 10:13:45 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-08-02 11:56:51 +0800
commitf7fde0173af95925e7324b7d3c09776173dab8a7 (patch)
treec7a54472837afe4baf13e66855265cc8a003805a /runtime
parent48e4589eaded3213956aa9ddbcc0aa6971a974e5 (diff)
downloadrneovim-f7fde0173af95925e7324b7d3c09776173dab8a7.tar.gz
rneovim-f7fde0173af95925e7324b7d3c09776173dab8a7.tar.bz2
rneovim-f7fde0173af95925e7324b7d3c09776173dab8a7.zip
vim-patch:9.0.0632: calling a function from an "expr" option has overhead
Problem: Calling a function from an "expr" option has too much overhead. Solution: Add call_simple_func() and use it for 'foldexpr' https://github.com/vim/vim/commit/87b4e5c5db9d1cfd6f2e79656e1a6cff3c69d15f Cherry-pick a call_func() change from patch 8.2.1343. Add expr-option-function docs to options.txt. Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/fold.txt6
-rw-r--r--runtime/doc/options.txt8
2 files changed, 12 insertions, 2 deletions
diff --git a/runtime/doc/fold.txt b/runtime/doc/fold.txt
index 8f7393f5e3..b844e0ed85 100644
--- a/runtime/doc/fold.txt
+++ b/runtime/doc/fold.txt
@@ -69,8 +69,6 @@ method. The value of the 'foldexpr' option is evaluated to get the foldlevel
of a line. Examples:
This will create a fold for all consecutive lines that start with a tab: >
:set foldexpr=getline(v:lnum)[0]==\"\\t\"
-This will call a function to compute the fold level: >
- :set foldexpr=MyFoldLevel(v:lnum)
This will make a fold out of paragraphs separated by blank lines: >
:set foldexpr=getline(v:lnum)=~'^\\s*$'&&getline(v:lnum+1)=~'\\S'?'<1':1
This does the same: >
@@ -79,6 +77,10 @@ This does the same: >
Note that backslashes must be used to escape characters that ":set" handles
differently (space, backslash, double quote, etc., see |option-backslash|).
+The most efficient is to call a function without arguments: >
+ :set foldexpr=MyFoldLevel()
+The function must use v:lnum. See |expr-option-function|.
+
These are the conditions with which the expression is evaluated:
- The current buffer and window are set for the line.
- The variable "v:lnum" is set to the line number.
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 875767283a..a48d020a34 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -400,6 +400,14 @@ Set using a variable with lambda expression: >
let L = {a, b, c -> MyTagFunc(a, b , c)}
let &tagfunc = L
+Calling a function in an expr option *expr-option-function*
+
+The value of a few options, such as 'foldexpr', is an expression 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 define a function and set the option to call it without
+arguments.
+
Setting the filetype