aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-08-02 13:15:16 +0800
committerGitHub <noreply@github.com>2024-08-02 13:15:16 +0800
commit76dea5feaa1ab3f2e987ac3ff35238f8e29f2242 (patch)
tree075b4793350d5bef55da000f89d75d90ecfc7c7e /runtime
parent48e4589eaded3213956aa9ddbcc0aa6971a974e5 (diff)
parent99bb0a10d3400ee8b9b2773d51a957dacbf52b33 (diff)
downloadrneovim-76dea5feaa1ab3f2e987ac3ff35238f8e29f2242.tar.gz
rneovim-76dea5feaa1ab3f2e987ac3ff35238f8e29f2242.tar.bz2
rneovim-76dea5feaa1ab3f2e987ac3ff35238f8e29f2242.zip
Merge pull request #29951 from zeertzjq/vim-9.0.0632
vim-patch:9.0.{0632,0634,0635},9.1.0649
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/diff.txt6
-rw-r--r--runtime/doc/fold.txt6
-rw-r--r--runtime/doc/options.txt39
-rw-r--r--runtime/lua/vim/_meta/options.lua24
4 files changed, 63 insertions, 12 deletions
diff --git a/runtime/doc/diff.txt b/runtime/doc/diff.txt
index 2f174a404e..c9de54342e 100644
--- a/runtime/doc/diff.txt
+++ b/runtime/doc/diff.txt
@@ -369,6 +369,9 @@ Additionally, 'diffexpr' should take care of "icase" and "iwhite" in the
'diffopt' option. 'diffexpr' cannot change the value of 'lines' and
'columns'.
+The advantage of using a function call without arguments is that it is faster,
+see |expr-option-function|.
+
Example (this does almost the same as 'diffexpr' being empty): >
set diffexpr=MyDiff()
@@ -434,6 +437,9 @@ will have the same effect. These variables are set to the file names used:
v:fname_diff patch file
v:fname_out resulting patched file
+The advantage of using a function call without arguments is that it is faster,
+see |expr-option-function|.
+
Example (this does the same as 'patchexpr' being empty): >
set patchexpr=MyPatch()
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..bc2a8ae263 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -400,6 +400,21 @@ 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. A |v:lua-call| can also be used. Example: >vim
+ lua << EOF
+ function _G.MyFoldFunc()
+ -- ... compute fold level for line v:lnum
+ return level
+ end
+ EOF
+ set foldexpr=v:lua.MyFoldFunc()
+
Setting the filetype
@@ -1307,6 +1322,9 @@ A jump table for the options with a short description can be found at |Q_op|.
v:fname_out name of the output file
Note that v:fname_in and v:fname_out will never be the same.
+ The advantage of using a function call without arguments is that it is
+ faster, see |expr-option-function|.
+
If the 'charconvert' expression starts with s: or |<SID>|, then it is
replaced with the script ID (|local-function|). Example: >vim
set charconvert=s:MyConvert()
@@ -2773,6 +2791,9 @@ A jump table for the options with a short description can be found at |Q_op|.
< This will invoke the mylang#Format() function in the
autoload/mylang.vim file in 'runtimepath'. |autoload|
+ The advantage of using a function call without arguments is that it is
+ faster, see |expr-option-function|.
+
The expression is also evaluated when 'textwidth' is set and adding
text beyond that limit. This happens under the same conditions as
when internal formatting is used. Make sure the cursor is kept in the
@@ -3408,11 +3429,14 @@ A jump table for the options with a short description can be found at |Q_op|.
If the expression starts with s: or |<SID>|, then it is replaced with
the script ID (|local-function|). Example: >vim
- setlocal includeexpr=s:MyIncludeExpr(v:fname)
- setlocal includeexpr=<SID>SomeIncludeExpr(v:fname)
+ setlocal includeexpr=s:MyIncludeExpr()
+ setlocal includeexpr=<SID>SomeIncludeExpr()
< Otherwise, the expression is evaluated in the context of the script
where the option was set, thus script-local items are available.
+ It is more efficient if the value is just a function call without
+ arguments, see |expr-option-function|.
+
The expression will be evaluated in the |sandbox| when set from a
modeline, see |sandbox-option|.
This option cannot be set in a modeline when 'modelineexpr' is off.
@@ -3475,6 +3499,9 @@ A jump table for the options with a short description can be found at |Q_op|.
< Otherwise, the expression is evaluated in the context of the script
where the option was set, thus script-local items are available.
+ The advantage of using a function call without arguments is that it is
+ faster, see |expr-option-function|.
+
The expression must return the number of spaces worth of indent. It
can return "-1" to keep the current indent (this means 'autoindent' is
used for the indent).
@@ -5915,9 +5942,11 @@ A jump table for the options with a short description can be found at |Q_op|.
The file is used for all languages.
expr:{expr} Evaluate expression {expr}. Use a function to avoid
- trouble with spaces. |v:val| holds the badly spelled
- word. The expression must evaluate to a List of
- Lists, each with a suggestion and a score.
+ trouble with spaces. Best is to call a function
+ without arguments, see |expr-option-function|.
+ |v:val| holds the badly spelled word. The expression
+ must evaluate to a List of Lists, each with a
+ suggestion and a score.
Example:
[['the', 33], ['that', 44]] ~
Set 'verbose' and use |z=| to see the scores that the
diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua
index ebb6ee2329..10c888548c 100644
--- a/runtime/lua/vim/_meta/options.lua
+++ b/runtime/lua/vim/_meta/options.lua
@@ -786,6 +786,9 @@ vim.bo.channel = vim.o.channel
--- v:fname_out name of the output file
--- Note that v:fname_in and v:fname_out will never be the same.
---
+--- The advantage of using a function call without arguments is that it is
+--- faster, see `expr-option-function`.
+---
--- If the 'charconvert' expression starts with s: or `<SID>`, then it is
--- replaced with the script ID (`local-function`). Example:
---
@@ -2521,6 +2524,9 @@ vim.wo.fdt = vim.wo.foldtext
--- This will invoke the mylang#Format() function in the
--- autoload/mylang.vim file in 'runtimepath'. `autoload`
---
+--- The advantage of using a function call without arguments is that it is
+--- faster, see `expr-option-function`.
+---
--- The expression is also evaluated when 'textwidth' is set and adding
--- text beyond that limit. This happens under the same conditions as
--- when internal formatting is used. Make sure the cursor is kept in the
@@ -3286,12 +3292,15 @@ vim.go.inc = vim.go.include
--- the script ID (`local-function`). Example:
---
--- ```vim
---- setlocal includeexpr=s:MyIncludeExpr(v:fname)
---- setlocal includeexpr=<SID>SomeIncludeExpr(v:fname)
+--- setlocal includeexpr=s:MyIncludeExpr()
+--- setlocal includeexpr=<SID>SomeIncludeExpr()
--- ```
--- Otherwise, the expression is evaluated in the context of the script
--- where the option was set, thus script-local items are available.
---
+--- It is more efficient if the value is just a function call without
+--- arguments, see `expr-option-function`.
+---
--- The expression will be evaluated in the `sandbox` when set from a
--- modeline, see `sandbox-option`.
--- This option cannot be set in a modeline when 'modelineexpr' is off.
@@ -3366,6 +3375,9 @@ vim.go.is = vim.go.incsearch
--- Otherwise, the expression is evaluated in the context of the script
--- where the option was set, thus script-local items are available.
---
+--- The advantage of using a function call without arguments is that it is
+--- faster, see `expr-option-function`.
+---
--- The expression must return the number of spaces worth of indent. It
--- can return "-1" to keep the current indent (this means 'autoindent' is
--- used for the indent).
@@ -6314,9 +6326,11 @@ vim.bo.spo = vim.bo.spelloptions
--- The file is used for all languages.
---
--- expr:{expr} Evaluate expression {expr}. Use a function to avoid
---- trouble with spaces. `v:val` holds the badly spelled
---- word. The expression must evaluate to a List of
---- Lists, each with a suggestion and a score.
+--- trouble with spaces. Best is to call a function
+--- without arguments, see `expr-option-function|.
+--- |v:val` holds the badly spelled word. The expression
+--- must evaluate to a List of Lists, each with a
+--- suggestion and a score.
--- Example:
--- [['the', 33], ['that', 44]] ~
--- Set 'verbose' and use `z=` to see the scores that the