summaryrefslogtreecommitdiffstatshomepage
path: root/src/nvim/eval/userfunc.c
AgeCommit message (Collapse)AuthorFiles
2026-04-22feat(:restart): v:starttime, v:exitreason #39282Justin M. Keyes1
Problem: - The `ZR` feature makes it more obvious that we need some sort of flag so that an `ExitPre` / `QuitPre` / `VimLeave` handler can handle restarts differently than a normal exit. For example, it's common that users want `:mksession` on restart, but perhaps not on a normal exit. - Nvim has no way to report its "uptime". Solution: - Introduce `v:starttime` - Introduce `v:exitreason`
2026-04-18feat(vimfn): use Lua for more excmds/vimfnsJustin M. Keyes1
Problem: Too much boilerplate needed to use Lua to impl an excmd or f_xx function. Solution: - Add `nlua_call_vimfn` which takes the args typval, executes Lua, and returns a typval. - refactor(excmd): lua impl for :log, :lsp
2026-04-14build: update clang v21, fix warningsdundargoc1
- `src/nvim/ex_cmds_defs.h`: use "U" instead of "u" per `readability-uppercase-literal-suffix`
2026-03-28vim-patch:9.2.0265: unnecessary restrictions for defining dictionary ↵zeertzjq1
function names (#38524) Problem: unnecessary restrictions for defining dictionary function names Solution: Allow defining dict function with bracket key that is not a valid identifier (thinca) In Vim script, "function obj.func()" and "function obj['func']()" both define a dictionary function. However, the bracket form required the key to match function naming rules (eval_isnamec), so "function obj['foo-bar']()" failed with E475. Assigning and calling already work: "let obj['foo-bar'] = obj.func" and "call obj['foo-bar']()" are valid. Only the definition was incorrectly restricted. Skip the identifier check when the name comes from fd_newkey (i.e. the key was given in bracket notation). Dictionary keys may be any string. Supported by AI closes: vim/vim#19833 https://github.com/vim/vim/commit/f89662722d3c4b97d55f32ca88a895f246405059 Co-authored-by: thinca <thinca@gmail.com>
2026-02-08fix(messages): unwanted newlines with ext_messages #37733luukvbaal1
Problem: Newlines intended to write messages below the cmdline or to mark the start of a new message on message grid are emitted through ext_messages. This results in unnecessary newlines for a UI that has decoupled its message area from the cmdline. msg_col is set directly in some places which is not transmitted to msg_show events. Various missing message kind for list commands. Trailing newlines on various list commands. Solution: Only emit such newlines without ext_messages enabled. Use msg_advance() instead of setting msg_col directly. Assign them the "list_cmd" kind. Ensure no trailing newline is printed.
2025-12-28vim-patch:8.2.0098: exe stack length can be wrong without being detected ↵Jan Edmund Lazo1
(#37136) Problem: Exe stack length can be wrong without being detected. Solution: Add a check when ABORT_ON_INTERNAL_ERROR is defined. https://github.com/vim/vim/commit/e31ee86859528a7ffe00405645547d494e522fa8 vim-patch:8.2.3262: build failure when ABORT_ON_INTERNAL_ERROR is defined Port patch 9.0.1454 for "make formatc". Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-12-22vim-patch:8.2.1756: Vim9: :let will soon be disallowed (#37063)zeertzjq1
Problem: Vim9: :let will soon be disallowed. Solution: Add v:disallow_let temporarily. Fix tests. https://github.com/vim/vim/commit/cfcd011fcd8021da52fba62dabf7a2497f1879b7 The change to use checkforcmd() is already included in the port of patch 9.0.1505. This commit adds the missing :const check. N/A patches: vim-patch:8.2.1397: Vim9: return type of maparg() not adjusted for fourth arg vim-patch:8.2.1623: Vim9: using :call where it is not needed vim-patch:8.2.1766: Vim9: Some tests are still using :let vim-patch:8.2.1788: Vim9: still allows :let for declarations vim-patch:8.2.1882: Vim9: v:disallow_let is no longer needed Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-12-21vim-patch:8.2.0223: some instructions not yet testedJan Edmund Lazo1
Problem: Some instructions not yet tested. Solution: Disassemble more instructions. Move tests to a new file. Compile call to s:function(). https://github.com/vim/vim/commit/5cab73f8cca46d831fb9337b176493da2a55ed5d Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-12-21vim-patch:8.2.4548: script-local function is deleted when used in a funcrefJan Edmund Lazo1
Problem: Script-local function is deleted when used in a funcref. Solution: Do not consider a function starting with "<SNR>" reference counted. (closes vim/vim#9916, closes vim/vim#9820) https://github.com/vim/vim/commit/fb43cfc2c6a003b850343bfd27cb3059c734d7d4 Co-authored-by: Bram Moolenaar <Bram@vim.org> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2025-12-21vim-patch:8.2.1667: local function name cannot shadow a global function nameJan Edmund Lazo1
Problem: Local function name cannot shadow a global function name. Solution: Ignore global functions when checking a script-local or scoped function name. (closes vim/vim#6926) https://github.com/vim/vim/commit/0f769815c82bf93812842e1ad56fcc52c10ff3e5 Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-12-14vim-patch:8.2.4529: Vim9: comparing partial with function failsJan Edmund Lazo1
Problem: Vim9: comparing partial with function fails. Solution: Support this comparison. Avoid a crash. (closes vim/vim#9909) Add more test cases. https://github.com/vim/vim/commit/ed0c62e7b16b62655824df28cdd6bd75aadbb8fc Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-12-14vim-patch:8.2.4528: crash when using null_function for a partialJan Edmund Lazo1
Problem: Crash when using null_function for a partial. Solution: Don't call fname_trans_sid() with NULL. (closes vim/vim#9908) https://github.com/vim/vim/commit/673bcb10ebe87ccf6954dd342d0143eb88cdfbcb Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-12-02fix(eval): fix crash with :breakadd expr when calling user funczeertzjq1
2025-12-01vim-patch:8.0.0287: debug mode: cannot access function arguments (#36772)zeertzjq1
Problem: Cannot access the arguments of the current function in debug mode. (Luc Hermitte) Solution: use get_funccal(). (Lemonboy, closes vim/vim#1432, closes vim/vim#1352) https://github.com/vim/vim/commit/c7d9eacefa319e5ac3b3b2334fda5acb126b8716 This patch was regressed in e50b545676822eefa3ab6b00b4222cc34c5f4633. Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-10-13fix(coverity/532324): free skip_until to prevent leak #36109Ethan Praeter1
2025-10-11fix(coverity/532421) removed logically dead code #36101Ethan Praeter1
2025-10-10vim-patch:8.2.2456: Coverity warning for strcpy() into fixed size arrayJan Edmund Lazo1
Problem: Coverity warning for strcpy() into fixed size array. Solution: Add a type cast to hopefully silence the bogus warning. https://github.com/vim/vim/commit/7b6903f02c9eeb12cd85941ea0d352d84e4dab30 Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-08-14refactor(build): remove INCLUDE_GENERATED_DECLARATIONS guardsbfredl1
These are not needed after #35129 but making uncrustify still play nice with them was a bit tricky. Unfortunately `uncrustify --update-config-with-doc` breaks strings with backslashes. This issue has been reported upstream, and in the meanwhile auto-update on every single run has been disabled.
2025-08-08vim-patch:9.1.1607: :apple command detected as :append (#35237)zeertzjq1
Problem: :apple command detected as :append (dai475694450) Solution: Disallow to define a custom command with lower-case letter, correctly detect :insert/:change/:append ex commands (Hirohito Higashi). fixes: vim/vim#17893 closes: vim/vim#17930 https://github.com/vim/vim/commit/efd83d441ba14eaadf5df4c7c29fddebb2a24780 Co-authored-by: Hirohito Higashi <h.east.727@gmail.com>
2025-04-14vim-patch:9.1.1298: define_function() is too long (#33457)zeertzjq1
Problem: define_function() is too long Solution: refactor and split up into smaller functions (Yegappan Lakshmanan) closes: vim/vim#17105 https://github.com/vim/vim/commit/3956c5b53c671b8b3df50758be0093f5699db0e7 Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2025-03-13vim-patch:9.1.1195: inside try-block: fn body executed with default arg ↵zeertzjq1
undefined (#32866) Problem: inside try-block: fn body executed when default arg is undefined Solution: When inside a try-block do not execute function body after an error in evaluating a default argument expression (Shane Harper). closes: vim/vim#16865 https://github.com/vim/vim/commit/2d18789aa67cc60072ea0cf21811c403fa0b2c7b Co-authored-by: Shane Harper <shane@shaneharper.net>
2025-03-03vim-patch:9.1.1169: using global variable for get_insert()/get_lambda_name() ↵zeertzjq1
(#32713) Problem: using global variable for get_insert()/get_lambda_name() (after v9.1.1151) Solution: let the functions return a string_T object instead (Yee Cheng Chin) In vim/vim#16720, `get_insert()` was modified to store a string length in a global variable to be queried immediately by another `get_insert_len()` function, which is somewhat fragile. Instead, just have the function itself return a `string_T` object instead. Also do the same for `get_lambda_name()` which has similar issues. closes: vim/vim#16775 https://github.com/vim/vim/commit/0b5fe420715786249cd121d845dbd6a81f962d1b Co-authored-by: Yee Cheng Chin <ychin.git@gmail.com>
2025-02-04vim-patch:9.1.1074: Strange error when heredoc marker starts with "trim" ↵zeertzjq1
(#32317) Problem: Strange error when heredoc marker starts with "trim". Solution: Check for whitespace after "trim" or "eval" (zeertzjq) For :python3 etc., a heredoc marker that starts with a lower-case letter is valid, and when it starts with "trim" it works in a script but not in a function, and this PR makes it works in a function. For :let, a heredoc marker that starts with a lower-case letter is not valid, but when it starts with "trim" or "eval" the error can be a bit confusing in a function, and this PR make it less confusing. closes: vim/vim#16574 https://github.com/vim/vim/commit/449c2e5454735fe1cfc8c21b2c6880d6bdf4cd6e
2025-02-03vim-patch:9.0.1391: "clear" macros are not always used (#32312)zeertzjq1
Problem: "clear" macros are not always used. Solution: Use ALLOC_ONE, VIM_CLEAR, CLEAR_POINTER and CLEAR_FIELD in more places. (Yegappan Lakshmanan, closes vim/vim#12104) https://github.com/vim/vim/commit/960dcbd098c761dd623bec9492d5391ff6e8dceb Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2025-02-03vim-patch:8.2.4948: cannot use Perl heredoc in nested :def function (#32311)zeertzjq1
Problem: Cannot use Perl heredoc in nested :def function. (Virginia Senioria) Solution: Only concatenate heredoc lines when not in a nested function. (closes vim/vim#10415) https://github.com/vim/vim/commit/d881d1598467d88808bafd2fa86982ebbca7dcc1 Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-02-03vim-patch:9.1.1071: args missing after failing to redefine a functionzeertzjq1
Problem: Arguments of a function are missing after failing to redefine it (after 8.2.2505), and heap-use-after-free with script-local function (after 9.1.1063). Solution: Don't clear arguments or free uf_name_exp when failing to redefine an existing function (zeertzjq) closes: vim/vim#16567 https://github.com/vim/vim/commit/04d2a3fdc051d6a419dc0ea4de7a9640cefccd31
2025-02-03vim-patch:9.1.1066: heap-use-after-free and stack-use-after-scope with ↵zeertzjq1
:14verbose Problem: heap-use-after-free and stack-use-after-scope with :14verbose when using :return and :try (after 9.1.1063). Solution: Move back the vim_free(tofree) and the scope of numbuf[]. (zeertzjq) closes: vim/vim#16563 https://github.com/vim/vim/commit/2101230f4013860dbafcb0cab3f4e6bc92fb6f35
2025-02-03vim-patch:9.1.1063: too many strlen() calls in userfunc.czeertzjq1
Problem: too many strlen() calls in userfunc.c Solution: refactor userfunc.c and remove calls to strlen(), drop set_ufunc_name() and roll it into alloc_ufunc(), check for out-of-memory condition in trans_function_name_ext() (John Marriott) closes: vim/vim#16537 https://github.com/vim/vim/commit/b32800f7c51c866dc0e87244eb4902540982309d Add missing change to call_user_func() from patch 8.1.1007. Consistently use PRIdSCID instead of PRId64 for script IDs. Co-authored-by: John Marriott <basilisk@internode.on.net>
2025-02-03vim-patch:9.0.1142: crash and/or memory leak when redefining functionzeertzjq1
Problem: Crash and/or memory leak when redefining function after error. Solution: Clear pointer after making a copy. Clear arrays on failure. (closes vim/vim#11774) https://github.com/vim/vim/commit/f057171d8b562c72334fd7c15c89ff787358ce3a Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-02-03vim-patch:8.2.2505: Vim9: crash after defining function with invalid return typezeertzjq1
Problem: Vim9: crash after defining function with invalid return type. Solution: Clear function growarrays. Fix memory leak. https://github.com/vim/vim/commit/31842cd0772b557eb9584a13740430db29de8a51 Cherry-pick free_fp from patch 8.2.3812. Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-02-03vim-patch:8.2.1445: Vim9: function expanded name is cleared when sourcing againzeertzjq1
Problem: Vim9: function expanded name is cleared when sourcing a script again. Solution: Only clear the expanded name when deleting the function. (closes vim/vim#6707) https://github.com/vim/vim/commit/c4ce36d48698669f81ec90f7c9dc9ab8c362e538 Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-02-03vim-patch:8.2.0825: def_function() may return pointer that was freedzeertzjq1
Problem: def_function() may return pointer that was freed. Solution: Set "fp" to NULL after freeing it. https://github.com/vim/vim/commit/a14e6975478adeddcc2161edc1ec611016aa89f3 Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-02-02vim-patch: port some userfunc.c refactorings from Vim (#32292)zeertzjq1
Port one_function_arg() and get_function_body() from Vim. vim-patch:8.2.2865: skipping over function body fails Problem: Skipping over function body fails. Solution: Do not define the function when skipping. https://github.com/vim/vim/commit/d87c21a918d8d611750f22d68fc638bf7a79b1d5 Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-01-16vim-patch:9.1.1013: Vim9: Regression caused by patch v9.1.0646zeertzjq1
Problem: Vim9: Regression caused by patch v9.1.0646 Solution: Translate the function name before invoking it in call() (Yegappan Lakshmanan) fixes: vim/vim#16430 closes: vim/vim#16445 https://github.com/vim/vim/commit/6289f9159102e0855bedc566636b5e7ca6ced72c N/A patch: vim-patch:8.2.4176: Vim9: cannot use imported function with call() Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
2024-09-23refactor(api)!: rename Dictionary => DictJustin M. Keyes1
In the api_info() output: :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val') ... {'return_type': 'ArrayOf(Integer, 2)', 'name': 'nvim_win_get_position', 'method': v:true, 'parameters': [['Window', 'window']], 'since': 1} The `ArrayOf(Integer, 2)` return type didn't break clients when we added it, which is evidence that clients don't use the `return_type` field, thus renaming Dictionary => Dict in api_info() is not (in practice) a breaking change.
2024-08-02fix(eval): handle wrong v:lua in expr option properly (#29953)zeertzjq1
2024-08-02refactor(eval): treat v:lua call as simple functionzeertzjq1
2024-08-02vim-patch:9.1.0649: Wrong comment for "len" argument of call_simple_func()zeertzjq1
Problem: Wrong comment for "len" argument of call_simple_func(). Solution: Remove the "or -1 to use strlen()". Also change its type to size_t to remove one cast. (zeertzjq) closes: vim/vim#15410 https://github.com/vim/vim/commit/c1ed788c1b41db9b5f1ef548dc877f771f535bbe
2024-08-02vim-patch:9.0.0632: calling a function from an "expr" option has overheadzeertzjq1
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>
2024-08-02vim-patch:8.2.4416: Vim9: using a script-local function requires using "s:" ↵zeertzjq1
(#29950) Problem: Vim9: using a script-local function requires using "s:" when setting 'completefunc'. Solution: Do not require "s:" in Vim9 script. (closes vim/vim#9796) https://github.com/vim/vim/commit/1fca5f3e86f08e696058fc7e86dfe41b415a78e6 vim-patch:8.2.4417: using NULL pointer Problem: Using NULL pointer. Solution: Set offset after checking for NULL pointer. https://github.com/vim/vim/commit/e89bfd212b21c227f026e467f882c62cdd6e642d Co-authored-by: Bram Moolenaar <Bram@vim.org>
2024-07-10vim-patch:9.1.0547: No way to get the arity of a Vim function (#29638)zeertzjq1
Problem: No way to get the arity of a Vim function (Austin Ziegler) Solution: Enhance get() Vim script function to return the function argument info using get(func, "arity") (LemonBoy) fixes: vim/vim#15097 closes: vim/vim#15109 https://github.com/vim/vim/commit/48b7d05a4f88c4326bd5d7a73a523f2d953b3e51 Co-authored-by: LemonBoy <thatlemon@gmail.com>
2024-06-11refactor(memory): use builtin strcat() instead of STRCAT()bfredl1
The latter was mostly relevant with the past char_u madness. NOTE: STRCAT also functioned as a counterfeit "NOLINT" for clint apparently. But NOLINT-ing every usecase is just the same as disabling the check entirely.
2024-06-01refactor: move shared messages to errors.h #26214Justin M. Keyes1
2024-04-30docs: various fixes (#28208)dundargoc1
Co-authored-by: Evgeni Chasnovski <evgeni.chasnovski@gmail.com> Co-authored-by: Famiu Haque <famiuhaque@proton.me> Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: Guilherme Soares <guilhermesoares1970@gmail.com> Co-authored-by: Jannik Buhr <jannik.m.buhr@gmail.com> Co-authored-by: thomaswuhoileong <72001875+thomaswuhoileong@users.noreply.github.com> Co-authored-by: tom-anders <13141438+tom-anders@users.noreply.github.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2024-04-20refactor: add xmemcpyz() and use it in place of some xstrlcpy() (#28422)zeertzjq1
Problem: Using xstrlcpy() when the exact length of the string to be copied is known is not ideal because it requires adding 1 to the length and an unnecessary strlen(). Solution: Add xmemcpyz() and use it in place of such xstrlcpy() calls.
2024-04-13vim-patch:9.0.2180: POSIX function name in exarg causes issues (#28308)zeertzjq1
Problem: POSIX function name in exarg struct causes issues on OpenVMS Solution: Rename getline member in exarg struct to ea_getline, remove isinf() workaround for VMS There are compilers that do not treat well POSIX functions - like getline - usage in the structs. Older VMS compilers could digest this... but the newer OpenVMS compilers ( like VSI C x86-64 X7.4-843 (GEM 50XB9) ) cannot deal with these structs. This could be limited to getline() that is defined via getdelim() and might not affect all POSIX functions in general - but avoiding POSIX function names usage in the structs is a "safe side" practice without compromising the functionality or the code readability. The previous OpenVMS X86 port used a workaround limiting the compiler capabilities using __CRTL_VER_OVERRIDE=80400000 In order to make the OpenVMS port future proof, this pull request proposes a possible solution. closes: vim/vim#13704 https://github.com/vim/vim/commit/6fdb6280821a822768df5689a5d727e37d38306c Co-authored-by: Zoltan Arpadffy <zoltan.arpadffy@gmail.com>
2024-04-11vim-patch:9.1.0301: Vim9: heredoc start may be recognized in string (#28266)zeertzjq1
Problem: Vim9: heredoc start may be recognized in string. Solution: Don't skip to closing bracket for invalid list assignment. (zeertzjq) closes: vim/vim#14472 https://github.com/vim/vim/commit/1817ccdb107ceeaf5c48fe193da5146682c15ca6
2024-04-10vim-patch:9.1.0287: Vim9: comment may be treated as heredoc start (#28257)zeertzjq1
Problem: Vim9: comment may be treated as heredoc start. (Ernie Rael) Solution: Use skip_var_list() instead of find_name_end(). (zeertzjq) fixes: vim/vim#14444 closes: vim/vim#14446 https://github.com/vim/vim/commit/9a91d2b72c20f213bbf77f27b7edd01e0e43d5e0
2024-03-16vim-patch:9.1.0182: Can define function with invalid name inside ↵zeertzjq1
'formatexpr' (#27883) Problem: Can define function with invalid name inside 'formatexpr'. Solution: Use goto instead of checking for did_emsg later. (zeertzjq) closes: vim/vim#14209 https://github.com/vim/vim/commit/6a04bf5ee523b2d6d01d7290e356a30de219f465
2024-03-16vim-patch:8.2.3782: Vim9: no error if a function shadows a script variable ↵zeertzjq1
(#27881) Problem: Vim9: no error if a function shadows a script variable. Solution: Check the function doesn't shadow a variable. (closes vim/vim#9310) https://github.com/vim/vim/commit/052ff291d72bc9c176f9562f021d7e8e030e74c0 Omit EVAL_VAR_NO_FUNC: Vim9 script only. Co-authored-by: Bram Moolenaar <Bram@vim.org>