summaryrefslogtreecommitdiffstatshomepage
path: root/src/nvim/lua
AgeCommit message (Collapse)AuthorFiles
2026-04-23fix(lua): don't strip debuginfo in precompile module #39191phanium1
Problem: debug.getinfo on bytecode module/func don't give you detail source info. Solution: - Use `loadstring`+`string.dump` to replace LUAC_PRG(`luac`/`luajit -b`) - `string.dump(…,false)` to generate non-strip version bytecode - `loadstring(…,fname)` to specify the full source name BEFORE: $ nvim --clean +'=debug.getinfo(vim.fn.maparg("]<Space>", "n", 0, 1).callback, "Sl")' --headless +q { currentline = -1, lastlinedefined = 456, linedefined = 452, short_src = "?", source = "=?", what = "Lua" } AFTER: $ nvim --clean +'=debug.getinfo(vim.fn.maparg("]<Space>", "n", 0, 1).callback, "Sl")' --headless +q { currentline = -1, lastlinedefined = 456, linedefined = 452, short_src = "/home/xx/b/neovim/runtime/lua/vim/_core/defaults.lua", source = "@/home/xx/b/neovim/runtime/lua/vim/_core/defaults.lua", what = "Lua" }
2026-04-22feat(eval): treat Lua string as "blob" in writefile() #39098Barrett Ruth1
Problem: vim.fn.writefile() treats Lua strings as Vimscript strings instead of a "binary clean" string. Solution: Treat Lua-originated strings as blob data.
2026-04-22fix(:restart): avoid ERR/WRN logging on Windows with --listen (#39287)zeertzjq1
Problem: :restart leads to ERR/WRN logging on Windows with --listen. Solution: Add a log_level flag to vim._with() and use it to suppress logging from serverstart()/serverstop() during restart.
2026-04-20fix(excmd): nlua_call_excmd require() failure is a "lua_error"Justin M. Keyes1
Although `nlua_call_excmd` is semantically for implementing Ex-commands, the `require()` should never fail, so that's a "Lua error". But if the call itself fails (the later `semsg` call), that's an "Ex cmd" error.
2026-04-20refactor(excmd): migrate ex_terminal to LuaJustin M. Keyes1
2026-04-20refactor(excmd): migrate ex_checkhealth to LuaJustin M. Keyes1
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-17perf(vim.fn): call Lua-implemented vim.fn.xx() directly #39166Justin M. Keyes1
Problem: - Builtin "Vimscript" functions (f_xx) are mostly implemented in C. Partly that's because there is some boilerplate required to call out to Lua. - Calls to `vim.fn.foo()` always marshall over the Lua <=> Vimscript ("typval") bridge, even if `fn.foo()` is implemented entirely in Lua: ``` Lua => typval => Object => Lua => Object => typval => Lua. ``` Solution: Functions declared in eval.lua with `func_lua` are implemented in entirely in Lua (`_core/vimfn.lua`). - `gen_eval.lua` wires `func_lua` entries to `lua_wrapper`, which handles the typval conversion for Vimscript callers (slow path). - `nlua_call()` detects `func_lua` functions and calls the Lua implementation directly. This eliminates all conversion overhead for Lua callers (fast path). - Validate at build-time that `func`, `func_float`, and `func_lua` are mutually exclusive. - Migrate `hostname()` as a toy example, to show the idea.
2026-04-16fix(treesitter): restore highlighting on 32 bit systems #39091Barrett Ruth1
Problem: Treesitter highlighting regressed on 32-bit builds because ranges that should cover the whole buffer were corrupted when passed into Lua. Solution: Round-trip those range values through Lua and validate them so treesitter sees the same ranges on 32 and 64-bit builds.
2026-04-02refactor(treesitter): add nts_parser_parse_bufLewis Russell2
This PR creates a C function `nts_parser_parse_buf()` which is like `ts_parser_parse_string()` but instead can be passed an nvim buffer number to parse.
2026-03-28docs: news #38464Justin M. Keyes1
2026-03-18fix(messages): disallow user-defined integer message-id #38359Justin M. Keyes1
Problem: `nvim_echo(…, {id=…})` accepts user-defined id as a string or integer. Generated ids are always higher than last highest msg-id used. Thus plugins may accidentally advance the integer id "address space", which, at minimum, could lead to confusion when troubleshooting, or in the worst case, could overflow or "exhaust" the id address space. There's no use-case for it, and it could be the mildly confusing, so we should just disallow it. Solution: Disallow *integer* user-defined message-id. Only allow *string* user-defined message-id.
2026-03-11docs: api, messages, lsp, trustJustin M. Keyes1
gen_vimdoc.lua: In prepare for the upcoming release, comment-out the "Experimental" warning for prerelease features.
2026-03-06fix(cmdline): cmdline_block events for :lua debug.debug() #38171luukvbaal1
Problem: :lua debug.debug() is missing cmdline_block events. Solution: Emit cmdline_block_show/append/hide events for :lua debug.debug().
2026-03-05fix(build): glibc 2.43 happenedbfredl1
using the GNU compiler we just get a bunch of const warnings we can fix. clang, however, gets really upset that the standard library suddenly starts using a lot of c11 features, despite us being in -std=gnu99 mode. Basically, _GNU_SOURCE which we set is taken as a _carte blanche_ by the glibc headers to do whatever they please, and thus we must inform clang that everything is still OK.
2026-02-13fix: wait() checks condition twice on each interval (#37837)zeertzjq1
Problem: wait() checks condition twice on each interval. Solution: Don't schedule the due callback. Also fix memory leak when Nvim exits while waiting. No test that the condition isn't checked twice, as testing for that can be flaky when there are libuv events from other sources.
2026-02-01fix(lua): close vim.defer_fn() timer if vim.schedule() failed (#37647)zeertzjq1
Problem: Using vim.defer_fn() just before Nvim exit leaks luv handles. Solution: Make vim.schedule() return an error message if scheduling failed. Make vim.defer_fn() close timer if vim.schedule() failed.
2026-01-27fix(ui): textlock still causes issues for UI callbacks #37513luukvbaal1
Problem: There are still ways to run into textlock errors with vim.ui_attach callbacks trying to display a UI event. Solution: Disregard textlock again during vim.ui_attach() callbacks (also when scheduled). Partially revert 3277dc3b; avoiding to flush while textlock is set is still helpful.
2026-01-21fix(lua): correct line number reporting for options set in coroutines (#37463)Tommy Guo2
2025-12-30build: ship "_core/*" as bytecode (built-into Nvim binary)Justin M. Keyes1
Problem: We want to encourage implementing core features in Lua instead of C, but it's clumsy because: - Core Lua code (built into `nvim` so it is available even if VIMRUNTIME is missing/invalid) requires manually updating CMakeLists.txt, or stuffing it into `_editor.lua`. - Core Lua modules are not organized similar to C modules, `_editor.lua` is getting too big. Solution: - Introduce `_core/` where core Lua code can live. All Lua modules added there will automatically be included as bytecode in the `nvim` binary. - Move these core modules into `_core/*`: ``` _defaults.lua _editor.lua _options.lua _system.lua shared.lua ``` TODO: - Move `_extui/ => _core/ui2/`
2025-12-21fix(api,lua): handle converting NULL funcref/partial (#37060)zeertzjq1
This fixes the Coverity warnings.
2025-12-20vim-patch:8.2.3766: converting a funcref to a string leaves out "g:"zeertzjq1
Problem: Converting a funcref to a string leaves out "g:", causing the meaning of the name depending on the context. Solution: Prepend "g:" for a global function. https://github.com/vim/vim/commit/c4ec338fb80ebfb5d631f0718fdd1a1c04d9ed82 Co-authored-by: Bram Moolenaar <Bram@vim.org> Co-authored-by: Jan Edmund Lazo <jan.lazo@mail.utoronto.ca>
2025-12-15Revert "refactor(treesitter): use scratch buffer for string parser" #36964Riley Bruins1
This reverts commit 2a7cb32959b4c616bd2c76ae1933f8e068e391ad.
2025-12-10fix(lua): relax `vim.wait()` timeout validation #36900skewb1k1
Problem: After bc0635a9fc9c15a2423d4eb35f627d127d00fa46 `vim.wait()` rejects floats and NaN values. Solution: Restore the prior behavior, while still supporting `math.huge`. Update tests to cover float case.
2025-12-09fix(lua): vim.wait(math.huge) fails #36885skewb1k1
Problem: `nlua_wait()` uses `luaL_checkinteger()` which doesn't support `math.huge` since it's double type. On PUC Lua this fails with 'number has no integer representation' error and on LuaJIT this overflows int. Solution: Use `luaL_checknumber()` and handle `math.huge`.
2025-10-21feat(vimscript): log function name in "fast" message #32616Matthieu Coudron1
2025-10-05vim-patch:8.1.1957: more code can be moved to evalvars.cJan Edmund Lazo1
Problem: More code can be moved to evalvars.c. Solution: Move code to where it fits better. (Yegappan Lakshmanan, closes vim/vim#4883) https://github.com/vim/vim/commit/da6c03342117fb7f4a8110bd9e8627b612a05a64 Co-authored-by: Bram Moolenaar <Bram@vim.org>
2025-10-02refactor(treesitter): use scratch buffer for string parser #35988Riley Bruins1
This commit changes `languagetree.lua` so that it creates a scratch buffer under the hood when dealing with string parsers. This will make it much easier to just use extmarks whenever we need to track injection trees in `languagetree.lua`. This also allows us to remove the `treesitter.c` code for parsing a string directly. Note that the string parser's scratch buffer has `set noeol nofixeol` so that the parsed source exactly matches the passed in string.
2025-10-01fix(treesitter): don't add final newline if not present #35970Riley Bruins1
**Problem(?):** Buffers that (for whatever reason) aren't meant to have a final newline are still parsed with a final newline in `treesitter.c`. **Solution:** Don't add the newline to the last buffer line if it shouldn't be there. (This more closely matches the approach of `read_buffer_into()`.) This allows us to, say, use a scratch buffer with `noeol` and `nofixeol` behind the scenes in `get_string_parser()`. ...which would allow us to track injection trees with extmarks in that case. ...which would allow us to not drop previous trees after reparsing a different range with `get_parser():parse()`. ...which would prevent flickering when editing a buffer that has 2+ windows to it in view at a time. ...which would allow us to keep our sanity!!! (one step at a time...)
2025-09-23fix(lua): coverity "unreachable" warning #35874Justin M. Keyes1
Problem: CID 584865: Control flow issues (UNREACHABLE) /src/nvim/lua/executor.c: 550 in nlua_wait() >>> CID 584865: Control flow issues (UNREACHABLE) >>> This code cannot be reached: "abort();". 550 abort(); 551 } Solution: The abort() was intended to encourage explicit handling of all cases, to avoid fallthrough to a possible `return x` added at the end. However, this is unlikely so just drop it.
2025-09-16docs: small fixes (#35791)zeertzjq1
Close #34938 Close #35030 Close #35233 Close #35259 Close #35290 Close #35433 Close #35541 Close #35766 Close #35792 Co-authored-by: huylg <45591413+huylg@users.noreply.github.com> Co-authored-by: Jason Del Ponte <961963+jasdel@users.noreply.github.com> Co-authored-by: sooriya <74165167+thuvasooriya@users.noreply.github.com> Co-authored-by: Andrew Braxton <andrewcbraxton@gmail.com> Co-authored-by: Enric Calabuig <enric.calabuig@gmail.com> Co-authored-by: Augusto César Dias <augusto.c.dias@gmail.com> Co-authored-by: David Sierra DiazGranados <davidsierradz@gmail.com> Co-authored-by: Stepan Nikitin <90522882+vectravox@users.noreply.github.com> Co-authored-by: Emilien Breton <bricktech2000@gmail.com>
2025-09-10refactor(lua): fix coverity warning from #35536 (#35703)zeertzjq1
2025-09-09perf(highlight): allow decoration providers to skip ranges without databfredl2
Continuing the work of #31400 That PR allowed the provider to be invoked multiple times per line. We want only to do that when there actually is more data later on the line. Additionally, we want to skip over lines which contain no new highlight items. The TS query cursor already tells us what the next position with more data is, so there is no need to reinvoke the range callback before that. NB: this removes the double buffering introduced in #32619 which is funtamentally incompatible with this (nvim core is supposed to keep track of long ranges by itself, without requiring a callback reinvoke blitz). Need to adjust the priorities some other way to fix the same issue.
2025-09-01feat(progress): better default format + history sync #35533Shadman1
Problem: The default progress message doesn't account for message-status. Also, the title and percent sections don't get written to history. And progress percent is hard to find with variable length messages. Solution: Apply highlighting on Title based on status. And sync the formated msg in history too. Also updates the default progress message format to {title}: {percent}% msg
2025-09-01feat(lua): vim.wait() returns callback results #35588Justin M. Keyes1
Problem: The callback passed to `vim.wait` cannot return results directly, it must set upvalues or globals. local rv1, rv2, rv3 local ok = vim.wait(200, function() rv1, rv2, rv3 = 'a', 42, { ok = { 'yes' } } return true end) Solution: Let the callback return values after the first "status" result. local ok, rv1, rv2, rv3 = vim.wait(200, function() return true, 'a', 42, { ok = { 'yes' } } end)
2025-08-31fix(lua): report error in Lua Funcref callback properly (#35555)zeertzjq1
2025-08-28perf: add on_range in treesitter highlightingvanaigr1
2025-08-27refactor: rename ga_concat_strings_sep() to ga_concat_strings() (#35498)zeertzjq1
This adds a missing change from Vim patch 7.4.279. N/A patch: vim-patch:9.1.1691: over-allocation in ga_concat_strings()
2025-08-26feat(api): nvim_echo can emit Progress messages/events #34846Shadman1
Problem: Nvim does not have a core concept for indicating "progress" of long-running tasks. The LspProgress event is specific to LSP. Solution: - `nvim_echo` can emit `kind="progress"` messages. - Emits a `Progress` event. - Includes new fields (id, status, percent) in the `msg_show` ui-event. - The UI is expected to overwrite any message having the same id. - Messages have a globally unique ID. - `nvim_echo` returns the message ID. - `nvim_echo(… {id=…})` updates existing messages. Example: local grp = vim.api.nvim_create_augroup("Msg", {clear = true}) vim.api.nvim_create_autocmd('Progress', { pattern={"term"}, group = grp, callback = function(ev) print(string.format('event fired: %s', vim.inspect(ev))..'\n') end }) -- require('vim._extui').enable({enable=true, msg={target='msg', timeout=1000}}) vim.api.nvim_echo({{'searching'}}, true, {kind='progress', percent=80, status='running', title="terminal(ripgrep)"}) local id = vim.api.nvim_echo({{'searching'}}, true, {kind='progress', status='running', percent=10, title="terminal(ripgrep)"}) vim.api.nvim_echo({}, true, {id = id, kind='progress', percent=20, status = 'running', title='find tests'}) vim.api.nvim_echo({}, true, {id = id, kind='progress', status='running', percent=70}) vim.api.nvim_echo({{'complete'}}, true, {id = id, kind='progress', status='success', percent=100, title="find tests"}) Followups: - Integrate with 'statusline' by listening to the Progress autocmd event. - Integrate progress ui-event with `vim._extui`.
2025-08-21fix(folds): error when deleting lines at end of buffer #35396tao1
Problem: with `foldmethod=expr foldexpr=v:lua.vim.treesitter.foldexpr() foldminlines=0`, deleting lines at the end of the buffer always reports an invalid top error, because the top value (i.e. the start line number of the deletion) is always 1 greater than the total line number of the modified buffer. Solution: remove the ml_line_count validation
2025-08-14refactor(build): remove INCLUDE_GENERATED_DECLARATIONS guardsbfredl17
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-06refactor(build): don't use the preprocessor when generating headersbfredl3
Using the preprocessor before generating prototypes provides some "niceties" but the places that rely on these are pretty few. Vastly simplifying the BUILD SYSTEM is a better trade-off. Unbalancing { } blocks due to the preprocessor is cringe anyway (think of the tree-sitter trees!), write these in a different way. Add some workarounds for plattform specific features. INCLUDE_GENERATED_DECLARATIONS flag is now technically redundant, but will be cleaned up in a follow-up PR as it is a big mess.
2025-07-28fix(messages): 'exrc' / secure messagesJustin M. Keyes1
2025-07-12fix(lua): vim.diff is nil in uv.new_work() thread #34909Justin M. Keyes1
Problem: The "gitsigns" plugin runs `vim.diff` in a thread (`uv.new_work`), but `vim.diff` is nil in that context: Lua callback: …/gitsigns.nvim/lua/gitsigns/diff_int.lua:30: bad argument #1 to 'decode' (string expected, got nil) stack traceback: [C]: in function 'decode' …/gitsigns.nvim/lua/gitsigns/diff_int.lua:30: in function <…/gitsigns.nvim/lua/gitsigns/diff_int.lua:29> Luv thread: …/gitsigns.nvim/lua/gitsigns/diff_int.lua:63: attempt to call field 'diff' (a nil value) Solution: Revert the `stdlib.c` change (set `vim.diff` instead of `vim._diff`).
2025-07-12refactor(lua): rename vim.diff => vim.text.diff #34864Justin M. Keyes2
Problem: `vim.diff()` was introduced before we had the `vim.text` module, where it obviously belongs. Solution: Move it.
2025-07-02fix(treesitter): ensure TSLuaTree is always immutableRodrigodd1
Problem: The previous fix in #34314 relies on copying the tree in `tree_root` to ensure the `TSNode`'s tree cannot be mutated. But that causes the problem where two calls to `tree_root` return nodes from different copies of a tree, which do not compare as equal. This has broken at least one plugin. Solution: Make all `TSTree`s on the Lua side always immutable, avoiding the need to copy the tree in `tree_root`, and make the only mutation point, `tree_edit`, copy the tree instead.
2025-06-29fix(exrc): exrc knows its own location (#34638)Yochem van Rosmalen2
fix(exrc): lua exrc files know their location Problem: 'exrc' files are inherently bound to their location / workspace and therefore require to "know" their location on the filesystem. However, currently using `debug.getinfo(1, 'S')` returns `"<nvim>"`. Solution: Include the filepath as chunkname in `loadstring()` and `nlua_exec()`.
2025-06-06fix(treesitter): ensure TSNode's tree is immutableRodrigodd1
Problem: TSNode contains a `const TSTree*` and a `const void *id`. The `id` points to Tree-sitter's internal type `Subtree`, which resides inside the `TSTree` but may be deallocated if the `TSTree` is mutated (which is likely why it is `const`). The Lua method `TSTree:edit()` mutates the tree, which can deallocate `id`. See #25254 and #31758. Solution: To avoid this, we now make a copy of the tree before pushing its root to the Lua stack. This also removes the fenv from TSLuaTree, as it was only used when pushing the tree root to the Lua stack. We also copy the tree in `node_tree`. `ts_tree_copy()` just increments a couple of reference counters, so it's relatively cheap to call.
2025-06-01fix(api): add missing nargs field to user command Lua callbacks #34210glepnir1
Problem: nvim_create_user_command() Lua callbacks were missing the documented nargs field in the options table passed to the callback function. Solution: Add nargs field derivation from command argument type flags in nlua_do_ucmd(), using the same logic as nvim_parse_cmd().
2025-05-13refactor(treesitter): move functions from executor.c to treesitter.cLewis Russell2