summaryrefslogtreecommitdiffstatshomepage
path: root/src/nvim/api
AgeCommit message (Collapse)AuthorFiles
2026-04-24fix(api): leak preview callback LuaRef in nvim_create_user_command #39357Barrett Ruth1
Problem: Invalid `nvim_create_user_command` calls can leak the `preview` callback reference after Neovim has taken ownership of it. 1. build with {a,l}san 2. run: ```sh <path/to/nvim> --headless -u NONE --clean +'lua for i = 1, 100 do pcall(vim.api.nvim_create_user_command, "some very epic stuff" .. i, {}, -- NOTE: this is INVALID (not a function or string) { preview = function() end }) end vim.cmd("qa!") ' +qa ``` 3. see: ``` 100 lua references were leaked! ``` Solution: Clear `preview_luaref` in `err:`.
2026-04-24feat(api): nvim_echo(percent=nil) means "unknown" progress #39029Peter Cardenas1
Problem: No way to signal "unknown" or "indeterminate" progress percentage. Solution: Treat percent=nil as "indeterminate" percent.
2026-04-20fix(api): expose fg_indexed/bg_indexed in nvim_get_hl #39210glepnir1
Problem: fg_indexed/bg_indexed were dropped from nvim_get_hl output due to a wrong short_keys guard. HL_FG_INDEXED also wasn't cleared in hl_blend_attrs, and HLATTRS_DICT_SIZE was too small. Solution: Remove the short_keys guard, clear HL_FG_INDEXED in hl_blend_attrs, bump HLATTRS_DICT_SIZE to 24, and clarify docs that these flags mean rgb is an approximation of the cterm palette index.
2026-04-20vim-patch:partial:9.2.0368: too many strlen() calls when adding strings to ↵zeertzjq1
dicts (#39237) Problem: too many strlen() calls when adding strings to dicts Solution: Refactor code to use string_T, use dict_add_string_len() instead of dict_add_string() (John Marriott) Additionally: - In textprop.c, in function prop_fill_dict() use a string_T to store local variable text_align. - In popupwin.c, use a string_T to store struct member pp_name in struct poppos_entry_T. - In mark.c, refactor function add_mark() to pass in the length of argument mname. - In insexpand.c: ->Use a string_T to store the elements of static array ctrl_x_mode_names. ->Refactor function trigger_complete_done_event(): ->->change type of argument char_u *word to string_T *word. ->->make one access of array ctrl_x_mode_names instead of two. ->Refactor function ins_compl_mode() to accept a string_T to return the resulting string. - In fileio.c: ->Refactor function getftypewfd() to accept a string_T to return the resulting string. ->In function create_readdirex_item() use a string_T to store local variable q. - In cmdexpand.c, store global cmdline_orig as a string_T. - In autocmd.c, in function f_autocmd_get() use a string_T to store local variables event_name and group_name. Measure their lengths once when they are assigned so they are not remeasured on each call to dict_add_string() in the subsequent for loop. - In channel.c, in function channel_part_info() drop local variable status and use s instead. Make s a string_T. closes: vim/vim#19999 https://github.com/vim/vim/commit/c13232699db413e735f30b5649c78a7f38a9a069 Co-authored-by: John Marriott <basilisk@internode.on.net>
2026-04-18docs: misc #39045Justin M. Keyes1
2026-04-17fix(lsp): limit number of created highlight groups (#39133)Evgeni Chasnovski1
* fix(api): allow silencing "Too many highlight groups" error Problem: Using Lua's `vim.api.nvim_set_hl(0, 'New', {...})` can fail if there are too many existing highlight groups. However, this error can not be silenced with `pcall`. Solution: Make it possible to silence in `nvim_set_hl` and `nvim_get_hl_id_by_name`. * fix(lsp): limit number of groups created by `document_color()` Problem: A file can contain many string colors that would be highlighted by an LSP server. If this number crosses 19999 (maximum number of allowed highlight groups), there are general issues with creating other highlight groups, which can break functionality outside of `vim.lsp.document_color`. Solution: Limit number of highlight groups that are created by `vim.lsp.document_color` to 10000 (half of allowed maximum). This is not a 100% solution (since there can exist more than 10000 other highlight groups), but explicitly checking number of groups is slow and 10000 should (hopefully) be enough for most use cases.
2026-04-18fix(terminal): forward streamed bracketed paste properly (#39152)zeertzjq1
2026-04-16test: lint naming conventions #39117Justin M. Keyes3
Problem: Naming conventions are not automatically checked. Solution: Add a check to the doc generator. Eventually we should extract this somehow, but that will require refactoring the doc generator... Note: this also checks non-public functions, basically anything that passes through `gen_eval_files.lua` and `gen_vimdoc.lua`. And that's a good thing.
2026-04-15refactor(api): rename "window" to "win" (positional parameters) #39083Justin M. Keyes3
continues d0af4cd9094f. This commit renames positional parameters. This is only "cosmetic", but is intended to make it extra clear which name is preferred, since people often copy existing code despite the guidelines in `:help dev-naming`.
2026-04-15refactor(api): rename buffer to buf (positional parameters) #39013Justin M. Keyes7
In 3a4a66017b74, 4d3a67cd6201, df8d98173cbc we renamed "buffer" to "buf" in dict parameters and return-values. This commit renames positional parameters. This is only "cosmetic", but is intended to make it extra clear which name is preferred, since people often copy existing code despite the guidelines in `:help dev-naming`.
2026-04-14feat(api): use zindex to determine dimmed cursor shape #39054luukvbaal1
Problem: The cursor shape is changed to indicate when it is behind an unfocused floating window (since a2b92a5e). This behavior cannot be controlled by a floating window that doesn't want to dim the cursor. Solution: Assign a zindex-offset of 50 to the zindex of the current window. To not dim the cursor when creating a floating window on top of the current window one can assign the zindex accordingly.
2026-04-14build(clang-analyzer): suppress clang-analyzer-security.ArrayBoundJustin M. Keyes1
Problem: clang 21 promoted alpha.security.ArrayBoundV2 to security.ArrayBound (stable). This new check reports false-positive "out of bound access" errors in drawline.c and vimscript.c, where the analyzer constructs impossible paths (e.g. concealed line with draw_text=false yet ptr advanced past the NUL terminator, or root AST node with a "next" sibling). Per-line NOLINT suppression doesn't work because the analyzer finds multiple paths to the same false positive. Solution: Disable clang-analyzer-security.ArrayBound globally in the clang-analyzer cmake target until the check matures. Co-Authored-By: Claude
2026-04-14docs: lsp, options, api #38980Justin M. Keyes1
docs: lsp, options - revert bogus change to `_meta/builtin_types.lua` from 3a4a66017b74 Close #38991 Co-authored-by: David Mejorado <david.mejorado@gmail.com>
2026-04-13feat(api): rename buffer to buf in retval #38900Justin M. Keyes3
In 3a4a66017b74192caaf9af9af172bdc08e0c1608, 4d3a67cd620152d11ab9b5f5bdd973f84cc2d44b we renamed "buffer" to "buf" in dict parameters. This commit also renames such keys in dict return-values.
2026-04-12feat(api): nvim_set_hl can set "font" #37668glepnir2
Problem: Cannot set highlight group fonts via API, only via :highlight command. Solution: Add font parameter in nvim_set_hl().
2026-04-12Merge #38882 docsJustin M. Keyes1
2026-04-12fix(api): nvim_get_hl drops groups defined with link_global #38492glepnir2
Problem: hlgroup2dict passes &ns_id to ns_get_hl twice. The first call (link=true) sets *ns_hl = 0 when link_global is set, so the second call and the sg_cleared guard both see ns_id == 0 and bail out. The group is silently dropped from the result. Solution: use a temporary copy of ns_id for each ns_get_hl call so the original value is preserved.
2026-04-12docs: miscJustin M. Keyes1
Close #38748 Close #38866 Co-authored-by: Mario Loriedo <mario.loriedo@gmail.com> Co-authored-by: Anakin Childerhose <anakin@childerhose.ca>
2026-04-09fix(messages): truncate warning messages only in display (#38901)zeertzjq2
For now, add a private "_truncate" flag to nvim_echo, using a truncation method similar to showmode().
2026-04-08feat(api): rename buffer to buf #35330Jordan3
Problem: `:help dev-name-common` states that "buf" should be used instead of "buffer" but there are cases where buffer is mentioned in the lua API. Solution: - Rename occurrences of "buffer" to "buf" for consistency with the documentation. - Support (but deprecate) "buffer" for backwards compatibility. Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2026-04-08fix(api)!: nvim_clear_autocmds() "event" handlingSean Dewar1
Problem: nvim_clear_autocmds() does not type check "event" correctly, and also treats an empty array "event" like nil. Solution: fix type checking. Treat empty array "event" as a no-op, like nvim_exec_autocmds(). Add some extra tests. Likewise the nil handling change may be considered breaking if anyone (unintentionally) relied on that. It was also true that integer, function, etc. "event"s would also be treated like nil! Note that an empty string "event" is still an error, as that's must be an exact match on an event name.
2026-04-08docs(api): nvim_exec_autocmds() default "pattern"Sean Dewar1
Problem: nvim_exec_autocmds() documentation incorrectly describes the default for "pattern" as *, when it's actually the current file name (like :doautocmd). Solution: correct it. Add a test.
2026-04-08fix(api)!: empty non-nil autocmd "pattern" handlingSean Dewar1
Problem: in autocmd APIs, a non-nil "pattern" containing only empty 'sub'-patterns is silently treated as nil, causing the fallback value to be unexpectedly used instead. Solution: for nvim_create_autocmd(), raise a validation error (as no autocmds would be created). For nvim_{exec,clear}_autocmds(), make it a no-op (as matching no autocmds is not an error).
2026-04-02feat(:restart): reattach all UIs (#38683)zeertzjq2
This is quite easy since [command] is now only executed once on UIEnter.
2026-03-31fix(:restart): only pass --headless when there is no UI (#38580)zeertzjq1
Change --embed so that the first UI can be on non-stdio channel even if neither --headless nor --listen is passed.
2026-03-29fix(:connect): formalize connect event #38543Justin M. Keyes1
Also document it.
2026-03-29refactor(:restart): execute [command] on UIEnter (#38541)zeertzjq2
This avoids having to pass it in the UI event.
2026-03-28fix(:restart): formalize restart event #35223Sathya Pramodh3
Problem: The "restart" event has some problems: - all UI clients must implement a somewhat complex set of setups - UI must be on the same machine as the server - only works for the "current" UI - race/edge case: If the user config has errors / waiting for input, are all UIs able to attach while Nvim is waiting for input? Solution: - Perform the restart on the server, not the client. - Pass listen address (instead of CLI args) in the UI event. - Simplifies UI logic: they only need to attach to new address. - Opens the door for more enhancements in the future, such as allowing all UIs to reattach instead of only the "current" UI. Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: Justin M. Keyes <justinkz@gmail.com>
2026-03-28docs: news #38464Justin M. Keyes1
2026-03-28fix(progress): require "source" for progress-message #38514Shadman1
Problem: - Progress-events are filtered by "source". But "source" is not required by nvim_echo. - Without "++nested" (force=false), nvim_echo in an event-handler does not trigger Progress events. - vim.health does not declare a "source". Solution: - Make source mandatory for progress-messages - Enable ++nested (force=true) by default when firing Progress event. - Set "source" in vim.health module.
2026-03-27feat(progress): set Progress-event pattern to "source" #38495Shadman2
Problem: Currently, there's no way to distinguish progress messages coming from different sources. Nor can Progress event be easily filtered based on source. Solution: - Add "source" field to nvim_echo-opts. - The Progress event pattern is now defined by the "source" field. - Include the "title" as ev.data. - Unrelated change: set force=false to disable nesting.
2026-03-25feat(api): nvim_set_hl{update:boolean} #37546glepnir2
Problem: nvim_set_hl always replaces all attributes. Solution: Add update field. When true, merge with existing attributes instead of replacing. Unspecified attributes are preserved. If highlight group doesn't exist, falls back to reset mode.
2026-03-24docs: api, plugins, ui2Justin M. Keyes2
2026-03-23fix(lua): drop support for boolean `buf` in `vim.keymap` #38432skewb1k1
Problem: `vim.keymap.*.Opts.buf` allows `boolean` aliases for more widely used `integer?` values, `true` -> `0` and `false` -> `nil`. This conversion is unnecessary and can be handled at call sites. Solution: As a follow-up to deprecating the `buffer` option, drop support for boolean values for the new `buf` option. The deprecated `buffer` continues to support booleans for backward compatibility.
2026-03-21feat(lua): replace `buffer` with `buf` in vim.keymap.set/del #38360skewb1k1
The `buffer` option remains functional but is now undocumented. Providing both will raise an error. Since providing `buf` was disallowed before, there is no code that will break due to using `buffer` alongside `buf`.
2026-03-19fix(terminal): don't poll for output during scrollback refresh (#38365)zeertzjq1
Problem: If buffer update callbacks poll for uv events during terminal scrollback refresh, new output from PTY process may lead to incorrect scrollback. Solution: Don't poll for output to the same terminal as the one being refreshed.
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-18fix(api): nvim_get_option_value FileType autocmd handling #37414Sean Dewar1
Problem: nvim_get_option_value with "filetype" set silently returns incorrect defaults if autocommands are blocked, like when they're already running. Solution: Allow its FileType autocommands to nest: `do_filetype_autocmd(force=true)`. Also error if executing them fails, rather than silently return wrong defaults. Endless nesting from misbehaving scripts should be prevented by the recursion limit in apply_autocmds_group, which is 10.
2026-03-17docs: api, lsp, messages, intro #38327Justin M. Keyes3
2026-03-16fix(api): use standard error messagesJustin M. Keyes10
2026-03-16docs: miscJustin M. Keyes1
2026-03-16fix(api): nvim_open_tabpage positional "enter"Sean Dewar2
Problem: nvim_open_tabpage's "enter" argument is optional, which is inconsistent with nvim_open_win. Solution: make it a (non-optional) positional argument, like nvim_open_win. Also change "enter"'s description to be more like nvim_open_win's doc.
2026-03-16fix(api): nvim_open_tabpage "after" like :[count]tabSean Dewar1
Problem: "after" in nvim_open_tabpage is inconsistent with how a count works with :tab, :tabnew, etc. Plus, the name "after" implies it's inserted after that number. Solution: internally offset by 1. Allow negative numbers to mean after current. Hmm, should we even reserve sentinels for after current? Callers can probably just use nil...
2026-03-16fix: nvim_open_tabpage cleanup, fixes, more testsSean Dewar1
- Cleanup, remove redundant comments, add more tests. - Enhance win_new_tabpage rather than create a new function for !enter, and use a different approach that minimizes side-effects. Return the tabpage_T * and first win_T * it allocated. - Disallow during textlock, like other APIs that open windows. - Remove existing win_alloc_firstwin error handling from win_new_tabpage; it's not needed, and looks incorrect. (enter_tabpage is called for curtab, which is not the old tabpage! Plus newtp is not freed) - Fix checks after creating the tabpage: - Don't fail if buf wasn't set successfully; the tab page may still be valid regardless. Set buffer like nvim_open_win, possibly blocking Enter/Leave events. (except BufWinEnter) - tp_curwin may not be the initial window opened by win_new_tabpage. Use the win_T * it returns instead, which is the real first window it allocated, regardless of autocmd shenanigans. - Properly check whether tab page was freed; it may have also been freed before win_set_buf. Plus, it may not be safe to read its handle!
2026-03-16feat(api): add nvim_open_tabpageWill Hopkins3
Problem: no API function for opening a new tab page and returning its handle, or to open without entering. Solution: add nvim_open_tabpage.
2026-03-14fix(api): improve external window validationSean Dewar1
Problem: "win" is allowed in external window configs in some cases. External window converted to normal float can't move tabpages in one nvim_win_set_config call. External window can't be turned into a normal split. Solution: disallow setting "win" for external windows. Allow external window to move tabpages, which turns it non-external. Allow external window to be turned into a (non-external) split. parse_win_config has more validation issues from not considering the window's existing config enough (not from this PR). For example, zindex can be set for an existing split if "split"/"vertical" isn't given, despite intending for that to be an error. Plus the logic is confusing. It could do with a refactor at some point...
2026-03-14fix(api): disallow moving window between tabpages in more casesSean Dewar1
Problem: more cases where it may not be safe to move a window between tabpages. Solution: check them. Rather speculative... I haven't spend much time looking, but I didn't find existing code that sets these locks to skip checking win_valid. (what I did find called it anyway, like in win_close) Still, I think it's a good precaution for what future code might do. If the fact that nvim_win_set_config *actually* moves windows between tabpages causes unforeseen issues, "faking" it like ":wincmd T" may be an alternative: split a new window, close the old one, but instead also block autocmds, copy the old window's config, and give it its handle?
2026-03-14feat(api): nvim_win_set_config can move split to other tp as floatwinSean Dewar1
Problem: not possible for nvim_win_set_config to convert a split to a floatwin, then move it to another tabpage in one call. Solution: allow it.
2026-03-14fix(api): relax config validation for "win"Sean Dewar1
Problem: only possible to move floats between tabpages if relative=win, which has the restrictive effect of also anchoring it to the target window. Solution: allow "win" without "relative" or "split"/"vertical". Only assume missing "win" is 0 if relative=win is given to maintain that behaviour. (or when configuring a new window) Also add an error when attempting to change a split into a float that's in another tabpage, as this isn't actually supported yet. (until the next commit) Maybe this could do with some bikeshedding. Unclear if "win" should require "relative" to be given, like with "row"/"col"; this can be annoying though as specifying "relative" requires other fields to be given too.
2026-03-14refactor(window): lastwin_nofloating takes tpSean Dewar1