From bcae4af3743dbc8fc51027bbe323ddc9211cd8ca Mon Sep 17 00:00:00 2001 From: Jonas Strittmatter <40792180+smjonas@users.noreply.github.com> Date: Thu, 16 Feb 2023 15:54:25 +0100 Subject: docs: remove mentions of 'balloonexpr' #22049 'balloonexpr' option was removed in Nvim. --- runtime/doc/eval.txt | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 58759a6053..0e77fb182e 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1670,38 +1670,6 @@ v:argv The command line arguments Vim was invoked with. This is a list of strings. The first item is the Vim command. See |v:progpath| for the command with full path. - *v:beval_col* *beval_col-variable* -v:beval_col The number of the column, over which the mouse pointer is. - This is the byte index in the |v:beval_lnum| line. - Only valid while evaluating the 'balloonexpr' option. - - *v:beval_bufnr* *beval_bufnr-variable* -v:beval_bufnr The number of the buffer, over which the mouse pointer is. Only - valid while evaluating the 'balloonexpr' option. - - *v:beval_lnum* *beval_lnum-variable* -v:beval_lnum The number of the line, over which the mouse pointer is. Only - valid while evaluating the 'balloonexpr' option. - - *v:beval_text* *beval_text-variable* -v:beval_text The text under or after the mouse pointer. Usually a word as - it is useful for debugging a C program. 'iskeyword' applies, - but a dot and "->" before the position is included. When on a - ']' the text before it is used, including the matching '[' and - word before it. When on a Visual area within one line the - highlighted text is used. Also see ||. - Only valid while evaluating the 'balloonexpr' option. - - *v:beval_winnr* *beval_winnr-variable* -v:beval_winnr The number of the window, over which the mouse pointer is. Only - valid while evaluating the 'balloonexpr' option. The first - window has number zero (unlike most other places where a - window gets a number). - - *v:beval_winid* *beval_winid-variable* -v:beval_winid The |window-ID| of the window, over which the mouse pointer - is. Otherwise like v:beval_winnr. - *v:char* *char-variable* v:char Argument for evaluating 'formatexpr' and used for the typed character when using in an abbreviation |:map-|. @@ -4244,8 +4212,8 @@ Textlock *textlock* In a few situations it is not allowed to change the text in the buffer, jump to another window and some other things that might confuse or break what Vim is currently doing. This mostly applies to things that happen when Vim is -actually doing something else. For example, evaluating the 'balloonexpr' may -happen any moment the mouse cursor is resting at some position. +actually doing something else. For example, a TextYankPost autocommand cannot +edit the text it is yanking. This is not allowed when the textlock is active: - changing the buffer text -- cgit From b62c0c8d9c22ae7fc9ee200733f8312efa6dbced Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Mon, 20 Feb 2023 08:12:59 +0100 Subject: docs: fix typos (#21961) Co-authored-by: Ben Morgan --- runtime/doc/eval.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 0e77fb182e..3889b8e9a5 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1827,8 +1827,8 @@ v:event Dictionary of event data for the current |autocommand|. Valid |CompleteChanged|. scrollbar Is |v:true| if popup menu have scrollbar, or |v:false| if not. - changed_window Is |v:true| if the the event fired - while changing window (or tab) on |DirChanged|. + changed_window Is |v:true| if the event fired while + changing window (or tab) on |DirChanged|. status Job status or exit code, -1 means "unknown". |TermClose| *v:exception* *exception-variable* -- cgit From f1816f9ee2a8b811fd6ce4e60a843087f855f97d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 20 Feb 2023 15:13:55 +0800 Subject: refactor(main.c): remove unreachable use_builtin_ui conditions (#22338) When use_builtin_ui is true, Nvim will exit before line 385 is reached. --- runtime/doc/eval.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 3889b8e9a5..49d4546f95 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1794,7 +1794,7 @@ v:event Dictionary of event data for the current |autocommand|. Valid abort Whether the event triggered during an aborting condition (e.g. |c_Esc| or |c_CTRL-C| for |CmdlineLeave|). - chan |channel-id| or 0 for "internal". + chan |channel-id| cmdlevel Level of cmdline. cmdtype Type of cmdline, |cmdline-char|. cwd Current working directory. -- cgit From ee26b227e15abc263195d4c746d5dba9f0e6dec4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 21 Feb 2023 23:50:29 +0800 Subject: vim-patch:partial:938ae280c79b (#22356) Update runtime files. https://github.com/vim/vim/commit/938ae280c79b8cdb0fca60336ec4c090ecd8bb5a Partially skip autocmd.txt: needs patch 8.2.5011. Partially skip builtin.txt: needs patch 9.0.0411. Partially skip eval.txt: needs patch 8.2.3783. Cherry-pick :map-meta-keys from patch 9.0.1276. Co-authored-by: Bram Moolenaar --- runtime/doc/eval.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 49d4546f95..af67e2b67d 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1445,7 +1445,7 @@ See below |functions|. ------------------------------------------------------------------------------ lambda expression *expr-lambda* *lambda* -{args -> expr1} lambda expression +{args -> expr1} lambda expression *E451* A lambda expression creates a new unnamed function which returns the result of evaluating |expr1|. Lambda expressions differ from |user-function|s in -- cgit From 344a1ee8e6b7d78120f8393d1babfd285e866334 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 22 Feb 2023 00:07:26 +0800 Subject: docs: fix typos (#22353) --- runtime/doc/eval.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index af67e2b67d..d79b446986 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1817,17 +1817,17 @@ v:event Dictionary of event data for the current |autocommand|. Valid completed_item Current selected complete item on |CompleteChanged|, Is `{}` when no complete item selected. - height Height of popup menu on |CompleteChanged| - width width of popup menu on |CompleteChanged| - row Row count of popup menu on |CompleteChanged|, + height Height of popup menu on |CompleteChanged| + width width of popup menu on |CompleteChanged| + row Row count of popup menu on |CompleteChanged|, relative to screen. - col Col count of popup menu on |CompleteChanged|, + col Col count of popup menu on |CompleteChanged|, relative to screen. - size Total number of completion items on + size Total number of completion items on |CompleteChanged|. - scrollbar Is |v:true| if popup menu have scrollbar, or + scrollbar Is |v:true| if popup menu have scrollbar, or |v:false| if not. - changed_window Is |v:true| if the event fired while + changed_window Is |v:true| if the event fired while changing window (or tab) on |DirChanged|. status Job status or exit code, -1 means "unknown". |TermClose| @@ -2668,8 +2668,8 @@ text... Example with [depth] 0: > let mylist = [1, 2, 3] lockvar 0 mylist - let mylist[0] = 77 " OK - call add(mylist, 4] " OK + let mylist[0] = 77 " OK + call add(mylist, 4] " OK let mylist = [7, 8, 9] " Error! < *E743* For unlimited depth use [!] and omit [depth]. -- cgit From 2882b1543a4f30ee3d7b039a5d51bb994fd6aa1d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 7 Mar 2023 11:04:36 +0800 Subject: vim-patch:8.2.3969: value of MAXCOL not available in Vim script Problem: Value of MAXCOL not available in Vim script. Solution: Add v:maxcol. (Naohiro Ono, closes vim/vim#9451) https://github.com/vim/vim/commit/56200eed62e59ad831f6564dcafe346e6f97ac20 The variable is always 2147483647, but introducing it makes functions easier to document. Co-authored-by: naohiro ono --- runtime/doc/eval.txt | 3 +++ 1 file changed, 3 insertions(+) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index d79b446986..51e26cc28b 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1979,6 +1979,9 @@ v:lnum Line number for the 'foldexpr' |fold-expr|, 'formatexpr', v:lua Prefix for calling Lua functions from expressions. See |v:lua-call| for more information. + *v:maxcol* *maxcol-variable* +v:maxcol Maximum line length. + *v:mouse_win* *mouse_win-variable* v:mouse_win Window number for a mouse click obtained with |getchar()|. First window has number 1, like with |winnr()|. The value is -- cgit From 08d0f99ae122b21e9470d58224edd69d1615ee3d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 7 Mar 2023 11:41:25 +0800 Subject: vim-patch:partial:944697ae196 Update runtime files https://github.com/vim/vim/commit/944697ae19683441981539cd4d2469df89d6ec82 Co-authored-by: Bram Moolenaar --- runtime/doc/eval.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 51e26cc28b..fe15ba6115 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1980,7 +1980,9 @@ v:lua Prefix for calling Lua functions from expressions. See |v:lua-call| for more information. *v:maxcol* *maxcol-variable* -v:maxcol Maximum line length. +v:maxcol Maximum line length. Depending on where it is used it can be + screen columns, characters or bytes. The value currently is + 2147483647 on all systems. *v:mouse_win* *mouse_win-variable* v:mouse_win Window number for a mouse click obtained with |getchar()|. -- cgit From d6e2804ab4f8810293dbcd748bfb938d9e0c3d52 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 14 Apr 2023 11:00:17 +0800 Subject: vim-patch:8.2.1794: no falsy Coalescing operator Problem: No falsy Coalescing operator. Solution: Add the "??" operator. Fix mistake with function argument count. https://github.com/vim/vim/commit/92f26c256e06277ff2ec4ce7adea1eb58c85abe0 Cherry-pick tv2bool() into eval/typval.c. Cherry-pick *??* tag from Vim runtime. Co-authored-by: Bram Moolenaar --- runtime/doc/eval.txt | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index fe15ba6115..9f0a6ceb25 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -93,7 +93,27 @@ non-zero number it means TRUE: > :" executed To test for a non-empty string, use empty(): > :if !empty("foo") -< + +< *falsy* *truthy* +An expression can be used as a condition, ignoring the type and only using +whether the value is "sort of true" or "sort of false". Falsy is: + the number zero + empty string, blob, list or dictionary +Other values are truthy. Examples: + 0 falsy + 1 truthy + -1 truthy + 0.0 falsy + 0.1 truthy + '' falsy + 'x' truthy + [] falsy + [0] truthy + {} falsy + #{x: 1} truthy + 0z falsy + 0z00 truthy + *non-zero-arg* Function arguments often behave slightly different from |TRUE|: If the argument is present and it evaluates to a non-zero Number, |v:true| or a @@ -841,9 +861,12 @@ All expressions within one level are parsed from left to right. ------------------------------------------------------------------------------ -expr1 *expr1* *ternary* *E109* +expr1 *expr1* *ternary* *falsy-operator* *??* *E109* + +The ternary operator: expr2 ? expr1 : expr1 +The falsy operator: expr2 ?? expr1 -expr2 ? expr1 : expr1 +Ternary operator ~ The expression before the '?' is evaluated to a number. If it evaluates to |TRUE|, the result is the value of the expression between the '?' and ':', @@ -866,6 +889,23 @@ To keep this readable, using |line-continuation| is suggested: > You should always put a space before the ':', otherwise it can be mistaken for use in a variable such as "a:1". +Falsy operator ~ + +This is also known as the "null coalescing operator", but that's too +complicated, thus we just call it the falsy operator. + +The expression before the '??' is evaluated. If it evaluates to +|truthy|, this is used as the result. Otherwise the expression after the '??' +is evaluated and used as the result. This is most useful to have a default +value for an expression that may result in zero or empty: > + echo theList ?? 'list is empty' + echo GetName() ?? 'unknown' + +These are similar, but not equal: > + expr2 ?? expr1 + expr2 ? expr2 : expr1 +In the second line "expr2" is evaluated twice. + ------------------------------------------------------------------------------ expr2 and expr3 *expr2* *expr3* -- cgit From e36806666fe3c5792c39f0f9127e6637a6ceb7f2 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 14 Apr 2023 20:35:46 +0800 Subject: vim-patch:8.2.2138: Vim9: "exit_cb" causes Vim to exit (#23087) Problem: Vim9: "exit_cb" causes Vim to exit. Solution: Require white space after a command in Vim9 script. (closes vim/vim#7467) Also fix that Vim9 style heredoc was not always recognized. https://github.com/vim/vim/commit/b5b9480ee936ef4cd0e350c468ef8c5f42fa398b Omit EX_NONWHITE_OK, E1143, E1144: Vim9 script only. Cherry-pick test_vimscript.vim changes from patch 8.2.2141. Cherry-pick E1145 tag from Vim runtime. N/A patches for version.c: vim-patch:8.2.2140: build failure with tiny features Problem: Build failure with tiny features. Solution: Add #ifdef. https://github.com/vim/vim/commit/2a3cd3af455973d678f70303ebdd486f3478bc0d Co-authored-by: Bram Moolenaar --- runtime/doc/eval.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 9f0a6ceb25..351690f4df 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2539,7 +2539,7 @@ This does NOT work: > |List| item. *:let=<<* *:let-heredoc* - *E990* *E991* *E172* *E221* + *E990* *E991* *E172* *E221* *E1145* :let {var-name} =<< [trim] {endmarker} text... text... -- cgit From 3ad8c08acc506555667a070cf83c410ac9334f1e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 14 Apr 2023 19:45:54 +0800 Subject: vim-patch:8.2.4770: cannot easily mix expression and heredoc Problem: Cannot easily mix expression and heredoc. Solution: Support in heredoc. (Yegappan Lakshmanan, closes vim/vim#10138) https://github.com/vim/vim/commit/efbfa867a146fcd93fdec2435597aa4ae7f1325c Co-authored-by: Yegappan Lakshmanan --- runtime/doc/eval.txt | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 351690f4df..c8eea03f5f 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2540,14 +2540,30 @@ This does NOT work: > *:let=<<* *:let-heredoc* *E990* *E991* *E172* *E221* *E1145* -:let {var-name} =<< [trim] {endmarker} +:let {var-name} =<< [trim] [eval] {endmarker} text... text... {endmarker} Set internal variable {var-name} to a |List| containing the lines of text bounded by the string - {endmarker}. The lines of text is used as a - |literal-string|. + {endmarker}. + + If "eval" is not specified, then each line of text is + used as a |literal-string|. If "eval" is specified, + then any Vim expression in the form ``={expr}`` is + evaluated and the result replaces the expression. + Example where $HOME is expanded: > + let lines =<< trim eval END + some text + See the file `=$HOME`/.vimrc + more text + END +< There can be multiple Vim expressions in a single line + but an expression cannot span multiple lines. If any + expression evaluation fails, then the assignment fails. + once the "`=" has been found {expr} and a backtick + must follow. {expr} cannot be empty. + {endmarker} must not contain white space. {endmarker} cannot start with a lower case character. The last line should end only with the {endmarker} @@ -2597,6 +2613,13 @@ text... 1 2 3 4 5 6 7 8 DATA + + let code =<< trim eval CODE + let v = `=10 + 20` + let h = "`=$HOME`" + let s = "`=Str1()` abc `=Str2()`" + let n = `=MyFunc(3, 4)` + CODE < *E121* :let {var-name} .. List the value of variable {var-name}. Multiple -- cgit From bacb5021d4eff33c67eb659fb01125b2abcacd79 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 14 Apr 2023 21:08:00 +0800 Subject: vim-patch:8.2.4883: string interpolation only works in heredoc Problem: String interpolation only works in heredoc. Solution: Support interpolated strings. Use syntax for heredoc consistent with strings, similar to C#. (closes vim/vim#10327) https://github.com/vim/vim/commit/2eaef106e4a7fc9dc74a7e672b5f550ec1f9786e Cherry-pick Test_Debugger_breakadd_expr() from Vim. Co-authored-by: LemonBoy --- runtime/doc/eval.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index c8eea03f5f..518a190d3c 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1406,6 +1406,26 @@ to be doubled. These two commands are equivalent: > if a =~ '\s*' +------------------------------------------------------------------------------ +interpolated-string *interp-string* + +$"string" interpolated string constant *expr-$quote* +$'string' interpolated literal string constant *expr-$'* + +Interpolated strings are an extension of the |string| and |literal-string|, +allowing the inclusion of Vim script expressions (see |expr1|). Any +expression returning a value can be enclosed between curly braces. The value +is converted to a string. All the text and results of the expressions +are concatenated to make a new string. + +To include an opening brace '{' or closing brace '}' in the string content +double it. + +Examples: > + let your_name = input("What's your name? ") + echo $"Hello, {your_name}!" + echo $"The square root of 9 is {sqrt(9)}" + ------------------------------------------------------------------------------ option *expr-option* *E112* *E113* -- cgit From f2a9097d764cf61b9479d7633a9738077f75f43c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 15 Apr 2023 19:02:02 +0800 Subject: vim-patch:partial:d899e5112079 Update runtime files https://github.com/vim/vim/commit/d899e51120798d3fb5420abb1f19dddf3f014d05 Co-authored-by: Bram Moolenaar --- runtime/doc/eval.txt | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 518a190d3c..072d894aff 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2569,20 +2569,20 @@ text... {endmarker}. If "eval" is not specified, then each line of text is - used as a |literal-string|. If "eval" is specified, - then any Vim expression in the form ``={expr}`` is - evaluated and the result replaces the expression. + used as a |literal-string|, except that single quotes + doe not need to be doubled. + If "eval" is specified, then any Vim expression in the + form {expr} is evaluated and the result replaces the + expression, like with |interp-string|. Example where $HOME is expanded: > let lines =<< trim eval END some text - See the file `=$HOME`/.vimrc + See the file {$HOME}/.vimrc more text END < There can be multiple Vim expressions in a single line but an expression cannot span multiple lines. If any expression evaluation fails, then the assignment fails. - once the "`=" has been found {expr} and a backtick - must follow. {expr} cannot be empty. {endmarker} must not contain white space. {endmarker} cannot start with a lower case character. @@ -2635,10 +2635,10 @@ text... DATA let code =<< trim eval CODE - let v = `=10 + 20` - let h = "`=$HOME`" - let s = "`=Str1()` abc `=Str2()`" - let n = `=MyFunc(3, 4)` + let v = {10 + 20} + let h = "{$HOME}" + let s = "{Str1()} abc {Str2()}" + let n = {MyFunc(3, 4)} CODE < *E121* -- cgit From 9f1d33307270e7d013896aea6042b73d091078f5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 15 Apr 2023 19:04:55 +0800 Subject: vim-patch:3f32a5f1601a Update runtime files and translations https://github.com/vim/vim/commit/3f32a5f1601ab2b0eba0caad00d4c26fb86a02a2 Co-authored-by: Bram Moolenaar --- runtime/doc/eval.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 072d894aff..dd9137649d 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1417,14 +1417,22 @@ allowing the inclusion of Vim script expressions (see |expr1|). Any expression returning a value can be enclosed between curly braces. The value is converted to a string. All the text and results of the expressions are concatenated to make a new string. - + *E1278* To include an opening brace '{' or closing brace '}' in the string content -double it. +double it. For double quoted strings using a backslash also works. A single +closing brace '}' will result in an error. Examples: > let your_name = input("What's your name? ") +< What's your name? Peter ~ +> + echo echo $"Hello, {your_name}!" - echo $"The square root of 9 is {sqrt(9)}" +< Hello, Peter! ~ +> + echo $"The square root of {{9}} is {sqrt(9)}" +< The square root of {9} is 3.0 ~ + ------------------------------------------------------------------------------ option *expr-option* *E112* *E113* -- cgit From 57221e0d11d1c24bc2abada7559a1d20c5090b62 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 15 Apr 2023 19:11:29 +0800 Subject: vim-patch:b59ae59a5870 Update runtime files https://github.com/vim/vim/commit/b59ae59a58706e454ef8c78276f021b1f58466e7 Co-authored-by: Bram Moolenaar --- runtime/doc/eval.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index dd9137649d..1ff6e3c360 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1407,7 +1407,7 @@ to be doubled. These two commands are equivalent: > ------------------------------------------------------------------------------ -interpolated-string *interp-string* +interpolated-string *$quote* *interpolated-string* $"string" interpolated string constant *expr-$quote* $'string' interpolated literal string constant *expr-$'* @@ -2578,10 +2578,10 @@ text... If "eval" is not specified, then each line of text is used as a |literal-string|, except that single quotes - doe not need to be doubled. + does not need to be doubled. If "eval" is specified, then any Vim expression in the form {expr} is evaluated and the result replaces the - expression, like with |interp-string|. + expression, like with |interpolated-string|. Example where $HOME is expanded: > let lines =<< trim eval END some text -- cgit From f4d3e279e861dc37dd047c81a0807767a74d251b Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 16 Apr 2023 09:01:33 +0800 Subject: vim-patch:8.2.2977: crash when using a null function reference Problem: Crash when using a null function reference. (Naohiro Ono) Solution: Check for an invalid function name. (closes vim/vim#8367) https://github.com/vim/vim/commit/22db0d549f64aa3d8a6e366b70eb8d7e66933b82 Co-authored-by: Bram Moolenaar --- runtime/doc/eval.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 1ff6e3c360..ccb615602f 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -139,7 +139,7 @@ You will not get an error if you try to change the type of a variable. 1.2 Function references ~ - *Funcref* *E695* *E718* + *Funcref* *E695* *E718* *E1192* A Funcref variable is obtained with the |function()| function, the |funcref()| function or created with the lambda expression |expr-lambda|. It can be used in an expression in the place of a function name, before the parenthesis -- cgit From 68ca16c376bd8786ffc0c7ce7619b9a0ce5657e8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 16 Apr 2023 08:54:07 +0800 Subject: vim-patch:8.2.3783: confusing error for using a variable as a function Problem: Confusing error for using a variable as a function. Solution: If a function is not found but there is a variable, give a more useful error. (issue vim/vim#9310) https://github.com/vim/vim/commit/2ef9156b4284e4a52613c36e3d4667245273a28d Co-authored-by: Bram Moolenaar --- runtime/doc/eval.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index ccb615602f..f80ca5346c 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1236,7 +1236,7 @@ Note that the dot is also used for String concatenation. To avoid confusion always put spaces around the dot for String concatenation. -expr8(expr1, ...) |Funcref| function call +expr8(expr1, ...) |Funcref| function call *E1085* When expr8 is a |Funcref| type variable, invoke the function it refers to. -- cgit From 191e8b40625731a652bade7000911554834afe5f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 26 Apr 2023 09:50:37 +0800 Subject: vim-patch:9.0.1485: no functions for converting from/to UTF-16 index (#23318) Problem: no functions for converting from/to UTF-16 index. Solution: Add UTF-16 flag to existing funtions and add strutf16len() and utf16idx(). (Yegappan Lakshmanan, closes vim/vim#12216) https://github.com/vim/vim/commit/67672ef097dd708244ff042a8364994da2b91e75 Co-authored-by: Yegappan Lakshmanan --- runtime/doc/eval.txt | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index f80ca5346c..0c18fd5b4e 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1433,6 +1433,32 @@ Examples: > echo $"The square root of {{9}} is {sqrt(9)}" < The square root of {9} is 3.0 ~ + *string-offset-encoding* +A string consists of multiple characters. UTF-8 uses one byte for ASCII +characters, two bytes for other latin characters and more bytes for other +characters. + +A string offset can count characters or bytes. Other programs may use +UTF-16 encoding (16-bit words) and an offset of UTF-16 words. Some functions +use byte offsets, usually for UTF-8 encoding. Other functions use character +offsets, in which case the encoding doesn't matter. + +The different offsets for the string "a©😊" are below: + + UTF-8 offsets: + [0]: 61, [1]: C2, [2]: A9, [3]: F0, [4]: 9F, [5]: 98, [6]: 8A + UTF-16 offsets: + [0]: 0061, [1]: 00A9, [2]: D83D, [3]: DE0A + UTF-32 (character) offsets: + [0]: 00000061, [1]: 000000A9, [2]: 0001F60A + +You can use the "g8" and "ga" commands on a character to see the +decimal/hex/octal values. + +The functions |byteidx()|, |utf16idx()| and |charidx()| can be used to convert +between these indices. The functions |strlen()|, |strutf16len()| and +|strcharlen()| return the number of bytes, UTF-16 code units and characters in +a string respectively. ------------------------------------------------------------------------------ option *expr-option* *E112* *E113* -- cgit From dd3d857c390bee1f467eda9ec82c29948672bbff Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 4 May 2023 17:10:58 +0800 Subject: vim-patch:8.2.1461: Vim9: string indexes are counted in bytes Problem: Vim9: string indexes are counted in bytes. Solution: Use character indexes. (closes vim/vim#6574) https://github.com/vim/vim/commit/e3c37d8ebf9dbbf210fde4a5fb28eb1f2a492a34 Co-authored-by: Bram Moolenaar --- runtime/doc/eval.txt | 2 ++ 1 file changed, 2 insertions(+) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 0c18fd5b4e..9ee38e06d6 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1152,6 +1152,8 @@ text column numbers start with one! Example, to get the byte under the cursor: > :let c = getline(".")[col(".") - 1] +Index zero gives the first byte. Careful: text column numbers start with one! + If the length of the String is less than the index, the result is an empty String. A negative index always results in an empty string (reason: backward compatibility). Use [-1:] to get the last byte. -- cgit From b441dafdf53e367c7d43177274bd781c5c73e6e0 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 4 May 2023 16:46:38 +0800 Subject: vim-patch:8.2.2344: using inclusive index for slice is not always desired Problem: Using inclusive index for slice is not always desired. Solution: Add the slice() method, which has an exclusive index. (closes vim/vim#7408) https://github.com/vim/vim/commit/6601b62943a19d4f8818c3638440663d67a17b6a Cherry-pick a line in docs added later. Co-authored-by: Bram Moolenaar --- runtime/doc/eval.txt | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 9ee38e06d6..05fdf2f5bb 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -270,6 +270,9 @@ similar to -1. > :let shortlist = mylist[2:2] " List with one item: [3] :let otherlist = mylist[:] " make a copy of the List +Notice that the last index is inclusive. If you prefer using an exclusive +index use the |slice()| method. + If the first index is beyond the last item of the List or the second item is before the first item, the result is an empty list. There is no error message. @@ -1178,6 +1181,9 @@ In legacy Vim script the indexes are byte indexes. This doesn't recognize multibyte encodings, see |byteidx()| for computing the indexes. If expr8 is a Number it is first converted to a String. +The item at index expr1b is included, it is inclusive. For an exclusive index +use the |slice()| function. + If expr1a is omitted zero is used. If expr1b is omitted the length of the string minus one is used. -- cgit From 057a5bc78d90db50caa85cdb34986fb186f0fd98 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 8 May 2023 13:57:24 +0800 Subject: docs: add some missing changes from Vim runtime updates (#23533) --- runtime/doc/eval.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 05fdf2f5bb..09c44a88af 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4270,10 +4270,10 @@ The input is in the variable "line", the results in the variables "file", getting the scriptnames in a Dictionary ~ *scriptnames-dictionary* -The |:scriptnames| command can be used to get a list of all script files that -have been sourced. There is no equivalent function or variable for this -(because it's rarely needed). In case you need to manipulate the list this -code can be used: > +The `:scriptnames` command can be used to get a list of all script files that +have been sourced. There is also the `getscriptinfo()` function, but the +information returned is not exactly the same. In case you need to manipulate +the output of `scriptnames` this code can be used: > " Get the output of ":scriptnames" in the scriptnames_output variable. let scriptnames_output = '' redir => scriptnames_output -- cgit From 08991b078267e5de0a19a136d00d4f71ad651a32 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 13 May 2023 21:33:22 +0200 Subject: docs: small fixes Co-authored-by: Christian Clason Co-authored-by: Gregory Anders Co-authored-by: HiPhish Co-authored-by: Julio B Co-authored-by: T727 <74924917+T-727@users.noreply.github.com> Co-authored-by: camoz Co-authored-by: champignoom <66909116+champignoom@users.noreply.github.com> --- runtime/doc/eval.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 09c44a88af..aa53244dc8 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -1087,7 +1087,7 @@ That works, since the String "190" is automatically converted to the Number 1 . 90 * 90.0 Should be read as: > 1 . (90 * 90.0) -Since '.' has lower precedence than '*'. This does NOT work, since this +Since '.' has lower precedence than "*". This does NOT work, since this attempts to concatenate a Float and a String. When dividing a Number by zero the result depends on the value: @@ -2210,7 +2210,7 @@ v:register The name of the register in effect for the current normal mode (use this in custom commands that take a register). If none is supplied it is the default register '"', unless 'clipboard' contains "unnamed" or "unnamedplus", then it is - '*' or '+'. + "*" or '+'. Also see |getreg()| and |setreg()| *v:relnum* *relnum-variable* -- cgit From 473a216a21fdc086ef71e0ca7d40c2fdf5346245 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sun, 11 Jun 2023 12:40:22 +0100 Subject: vim-patch:10e8ff9b2607 (#23977) Update runtime files https://github.com/vim/vim/commit/10e8ff9b26078994cae57c2422b145d37aaf714e Also: - fix a missing `<` in builtin.txt. - edit `:function` `{name}` wording to match the change made for the docs above by Justin in #10619. - link to `*vimrc*` rather than `*init.vim*` in repeat.txt change (as `init.lua` may also be used). Co-authored-by: Bram Moolenaar --- runtime/doc/eval.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index aa53244dc8..5cee668b39 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2799,7 +2799,7 @@ text... let mylist = [1, 2, 3] lockvar 0 mylist let mylist[0] = 77 " OK - call add(mylist, 4] " OK + call add(mylist, 4) " OK let mylist = [7, 8, 9] " Error! < *E743* For unlimited depth use [!] and omit [depth]. -- cgit From d931b829e92665fd7371b1bb49d22ce25b50a89a Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 21 Jun 2023 15:40:40 +0200 Subject: fix(docs): vimdoc syntax errors Since https://github.com/neovim/tree-sitter-vimdoc/pull/97 the many cases of *.foo cause parser errors. But even before that, these were erroneously highlighted as (argument), so fixing them is good. --- runtime/doc/eval.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 5cee668b39..c1ea28c839 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -39,7 +39,7 @@ List An ordered sequence of items, see |List| for details. Dictionary An associative, unordered array: Each entry has a key and a value. |Dictionary| - Examples: + Examples: > {"blue": "#0000ff", "red": "#ff0000"} #{blue: "#0000ff", red: "#ff0000"} -- cgit From 036da0d07921e67090d1a62c9a4e382ca09d8584 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Sat, 24 Jun 2023 13:47:10 +0200 Subject: fix(docs): vimdoc syntax errors gen_help_html: truncate parse-error sample text --- runtime/doc/eval.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index c1ea28c839..3cd5ea13f6 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -841,19 +841,19 @@ Expression syntax summary, from least to most significant: |expr9| number number constant "string" string constant, backslash is special - 'string' string constant, ' is doubled + `'string'` string constant, ' is doubled [expr1, ...] |List| - {expr1: expr1, ...} |Dictionary| + `{expr1: expr1, ...}` |Dictionary| #{key: expr1, ...} |Dictionary| &option option value (expr1) nested expression variable internal variable va{ria}ble internal variable with curly braces $VAR environment variable - @r contents of register 'r' + @r contents of register "r" function(expr1, ...) function call func{ti}on(expr1, ...) function call with curly braces - {args -> expr1} lambda expression + `{args -> expr1}` lambda expression "..." indicates that the operations in this level can be concatenated. @@ -1547,7 +1547,7 @@ See below |functions|. ------------------------------------------------------------------------------ lambda expression *expr-lambda* *lambda* -{args -> expr1} lambda expression *E451* +`{args -> expr1}` lambda expression *E451* A lambda expression creates a new unnamed function which returns the result of evaluating |expr1|. Lambda expressions differ from |user-function|s in @@ -1846,7 +1846,7 @@ v:ctype The current locale setting for characters of the runtime v:dying Normally zero. When a deadly signal is caught it's set to one. When multiple signals are caught the number increases. Can be used in an autocommand to check if Vim didn't - terminate normally. {only works on Unix} + terminate normally. Example: > :au VimLeave * if v:dying | echo "\nAAAAaaaarrrggghhhh!!!\n" | endif < Note: if another deadly signal is caught when v:dying is one, @@ -2493,7 +2493,7 @@ This does NOT work: > *:let/=* *:let%=* *:let.=* *:let..=* *E734* :let {var} += {expr1} Like ":let {var} = {var} + {expr1}". :let {var} -= {expr1} Like ":let {var} = {var} - {expr1}". -:let {var} *= {expr1} Like ":let {var} = {var} * {expr1}". +`:let {var} *= {expr1}` Like ":let {var} = {var} * {expr1}". :let {var} /= {expr1} Like ":let {var} = {var} / {expr1}". :let {var} %= {expr1} Like ":let {var} = {var} % {expr1}". :let {var} .= {expr1} Like ":let {var} = {var} . {expr1}". -- cgit From 29fe883aa9166bdbcae3f935523c75a8aa56fe45 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 4 Oct 2023 06:31:25 -0700 Subject: feat: ignore swapfile for running Nvim processes #25336 Problem: The swapfile "E325: ATTENTION" dialog is displayed when editing a file already open in another (running) Nvim. Usually this behavior is annoying and irrelevant: - "Recover" and the other options ("Open readonly", "Quit", "Abort") are almost never wanted. - swapfiles are less relevant for "multi-Nvim" since 'autoread' is enabled by default. - Even less relevant if user enables 'autowrite'. Solution: Define a default SwapExists handler which does the following: 1. If the swapfile is owned by a running Nvim process, automatically chooses "(E)dit anyway" (caveat: this creates a new, extra swapfile, which is mostly harmless and ignored except by `:recover` or `nvim -r`. 2. Shows a 1-line "ignoring swapfile..." message. 3. Users can disable the default SwapExists handler via `autocmd! nvim_swapfile`. --- runtime/doc/eval.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 3cd5ea13f6..c41237b862 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2276,12 +2276,13 @@ v:stderr |channel-id| corresponding to stderr. The value is always 2; :call chansend(v:stderr, "error: toaster empty\n") < *v:swapname* *swapname-variable* -v:swapname Only valid when executing |SwapExists| autocommands: Name of - the swap file found. Read-only. +v:swapname Name of the swapfile found. + Only valid during |SwapExists| event. + Read-only. *v:swapchoice* *swapchoice-variable* v:swapchoice |SwapExists| autocommands can set this to the selected choice - for handling an existing swap file: + for handling an existing swapfile: 'o' Open read-only 'e' Edit anyway 'r' Recover -- cgit From 0774d0cfe1d5efb4bdd34cc8cf3799af5c947d2e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 6 Nov 2023 19:03:08 +0800 Subject: vim-patch:da4e433dc3be (#25912) runtime(doc): document vim-script library function https://github.com/vim/vim/commit/da4e433dc3bee7fa521df3c7235d49a6732134ef Co-authored-by: Christian Brabandt --- runtime/doc/eval.txt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index c41237b862..4cb29205a5 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -4353,6 +4353,33 @@ This is not allowed when the textlock is active: - closing a window or quitting Vim - etc. +============================================================================== +Vim script library *vim-script-library* + +Vim comes bundled with a Vim script library, that can be used by runtime, +script authors. Currently, it only includes very few functions, but it may +grow over time. + + *dist#vim* +The functions make use of the autoloaded prefix "dist#vim". + +The following functions are available: + +dist#vim#IsSafeExecutable(filetype, executable) ~ + +This function takes a filetype and an executable and checks whether it is safe +to execute the given executable. For security reasons users may not want to +have Vim execute random executables or may have forbidden to do so for +specific filetypes by setting the "_exec" variable (|plugin_exec|). + +It returns |TRUE| or |FALSE| to indicate whether the plugin should run the given +exectuable. It takes the following arguments: + + argument type ~ + + filetype string + executable string + ============================================================================== Command-line expressions highlighting *expr-highlight* -- cgit From 56627ca2423e9d6084f87f5bc4639f06d10ecf91 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Mon, 6 Nov 2023 12:42:40 -0600 Subject: feat(tui): use TermResponse event for OSC responses (#25868) When the terminal emulator sends an OSC sequence to Nvim (as a response to another OSC sequence that was first sent by Nvim), populate the OSC sequence in the v:termresponse variable and fire the TermResponse event. The escape sequence is also included in the "data" field of the autocommand callback when the autocommand is defined in Lua. This makes use of the already documented but unimplemented TermResponse event. This event exists in Vim but is only fired when Vim receives a primary device attributes response. Fixes: https://github.com/neovim/neovim/issues/25856 --- runtime/doc/eval.txt | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 4cb29205a5..2223829548 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2318,18 +2318,10 @@ v:t_string Value of |String| type. Read-only. See: |type()| v:t_blob Value of |Blob| type. Read-only. See: |type()| *v:termresponse* *termresponse-variable* -v:termresponse The escape sequence returned by the terminal for the DA - (request primary device attributes) control sequence. It is - set when Vim receives an escape sequence that starts with ESC - [ or CSI and ends in a 'c', with only digits, ';' and '.' in - between. - When this option is set, the TermResponse autocommand event is - fired, so that you can react to the response from the - terminal. - The response from a new xterm is: "[ Pp ; Pv ; Pc c". Pp - is the terminal type: 0 for vt100 and 1 for vt220. Pv is the - patch level (since this was introduced in patch 95, it's - always 95 or bigger). Pc is always zero. +v:termresponse The value of the most recent OSC escape sequence received by + Nvim from the terminal. This can be read in a |TermResponse| + event handler after querying the terminal using another escape + sequence. *v:testing* *testing-variable* v:testing Must be set before using `test_garbagecollect_now()`. -- cgit From b4b7ca2d548a1cc1a2cd8c48e5c93478811bd275 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Thu, 16 Nov 2023 11:12:42 -0600 Subject: feat(tui): support DCS responses in TermResponse event (#26061) --- runtime/doc/eval.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'runtime/doc/eval.txt') diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 2223829548..a73932be00 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -2318,10 +2318,10 @@ v:t_string Value of |String| type. Read-only. See: |type()| v:t_blob Value of |Blob| type. Read-only. See: |type()| *v:termresponse* *termresponse-variable* -v:termresponse The value of the most recent OSC escape sequence received by - Nvim from the terminal. This can be read in a |TermResponse| - event handler after querying the terminal using another escape - sequence. +v:termresponse The value of the most recent OSC or DCS escape sequence + received by Nvim from the terminal. This can be read in a + |TermResponse| event handler after querying the terminal using + another escape sequence. *v:testing* *testing-variable* v:testing Must be set before using `test_garbagecollect_now()`. -- cgit