summaryrefslogtreecommitdiffstatshomepage
path: root/src/nvim/api/private
AgeCommit message (Collapse)AuthorFiles
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-03-16fix(api): use standard error messagesJustin M. Keyes3
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.
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-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-08-14refactor(build): remove INCLUDE_GENERATED_DECLARATIONS guardsbfredl8
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-07-01fix: type of nvim_echoLewis Russell1
2025-06-26docs(api): document types using LuaCATS typesLewis Russell1
- Render Lua types in api.txt. - Added `DictAs(name)` API type which acts the same as `Dict` (no parens) when generating the dispatchers, but acts the same as `Dict(name)` when generating docs. - Added `Tuple(...)` API type which is the treated the as `Array` for generating the dispatchers, but is used to document richer types. - Added `Enum(...)` API type to better document enums - Improve typing of some API functions. - Improve c_grammar to properly parse API types and replace string pattern logic in the parsers. - Removed all the hardcoded type overrides in gen_eval_files.lua
2025-03-17docs(api): rename "handle" => "id"Justin M. Keyes1
2025-02-25fix(lua): don't override script ID from :source (#32626)zeertzjq1
Problem: When setting an option, mapping etc. from Lua without -V1, the script ID is set to SID_LUA even if there already is a script ID assigned by :source. Solution: Don't set script ID to SID_LUA if it is already a Lua script. Also add _editor.lua to ignorelist to make script context more useful when using vim.cmd().
2025-02-25fix(api): don't override Vimscript SID (#32610)zeertzjq2
Problem: When calling an API from Vimscript to set an option, mapping, etc., :verbose shows that it's set from an API client. Solution: Don't override current_sctx.sc_sid when calling an API from Vimscript. Also fix the inverse case where API channel id is not set when calling an API from RPC. Move channel id into sctx_T to make saving and restoring easier. Related #8329
2025-02-20feat(marks): virtual lines support horizontal scrolling (#32497)zeertzjq1
Add a new field `virt_lines_overflow` that enables horizontal scrolling for virtual lines when set to "scroll".
2025-02-19fix(api): remove invalid assertionsLuuk van Baal1
Problem: `try_leave()` assertions moved in #31600 no longer hold. Solution: Remove the assertions.
2025-01-09feat(api): add err field to nvim_echo() optsLuuk van Baal1
Problem: We want to deprecate `nvim_err_write(ln)()` but there is no obvious replacement (from Lua). Meanwhile we already have `nvim_echo()` with an `opts` argument. Solution: Add `err` argument to `nvim_echo()` that directly maps to `:echoerr`.
2024-12-23refactor: iwyu #31637Justin M. Keyes3
Result of `make iwyu` (after some "fixups").
2024-12-17refactor(api): always use TRY_WRAP #31600luukvbaal2
Problem: Two separate try/end wrappers, that only marginally differ by restoring a few variables. Wrappers that don't restore previous state are dangerous to use in "api-fast" functions. Solution: Remove wrappers that don't restore the previous state. Always use TRY_WRAP.
2024-12-16fix(api): not using TRY_WRAP, generic error messages #31595Justin M. Keyes1
Problem: - API functions using `try_start` directly instead of `TRY_WRAP`, do not surface the underlying error message, and instead show generic things like "Failed to set buffer". - Error handling code is duplicated in the API impl, instead of delegating to the vim buffer/window handling logic. Solution: - Use `TRY_WRAP`.
2024-11-25feat(keysets): teach Union and LuaRefOfLewis Russell1
2024-11-17fix(api): nvim_echo free text memory with invalid highlight (#31243)luukvbaal1
Fix regression from #31195
2024-11-16fix(api): validation, documentation of hl_group #31195luukvbaal1
Problem: Documentation for "hl_group" in nvim_buf_set_extmark() is unclear. "hl_group" in nvim_echo() does not accept highlight group id. Solution: Move documentation for highlight group name/id to first mention of hl_group. Update nvim_echo() to accept highlight group id.
2024-11-08refactor(message): propagate highlight id instead of attrsLuuk van Baal1
Problem: Highlight group id is not propagated to the end of the message call stack, where ext_messages are emitted. Solution: Refactor message functions to pass along highlight group id instead of attr id.
2024-11-01vim-patch:9.1.0824: too many strlen() calls in register.c (#31022)zeertzjq1
Problem: too many strlen() calls in register.c Solution: refactor code, add string_T struct to keep track of string lengths (John Marriott) closes: vim/vim#15952 https://github.com/vim/vim/commit/79f6ffd388299ef3b1c95cbe658785e6e66df144 Co-authored-by: John Marriott <basilisk@internode.on.net>
2024-09-23refactor(api)!: rename Dictionary => DictJustin M. Keyes5
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-09-03fix(api): nvim_buf_get_text() crashes with large negative column #28740vanaigr1
Problem: crash when calling nvim_buf_get_text() with a large negative start_col: call nvim_buf_get_text(0, 0, -123456789, 0, 0, {}) Solution: clamp start_col after subtracting it from the line length.
2024-08-14fix(highlight): fix the seg fault caused by the invalid linked hl idsWilliam Wong1
2024-08-05refactor(shada): rework msgpack decoding without msgpack-cbfredl2
This also makes shada reading slightly faster due to avoiding some copying and allocation. Use keysets to drive decoding of msgpack maps for shada entries.
2024-07-13refactor(declarations): also generate prototypes for functions in headersbfredl1
Before this change, "static inline" functions in headers needed to have their function attributes specified in a completely different way. The prototype had to be duplicated, and REAL_FATTR_ had to be used instead of the public FUNC_ATTR_ names. TODO: need a check that a "header.h.inline.generated.h" file is not forgotten when the first "static inline" function with attributes is added to a header (they would just be silently missing).
2024-06-27refactor(typval)!: remove distinction of binary and nonbinary stringsbfredl1
This is a breaking change which will make refactor of typval and shada code a lot easier. In particular, code that would use or check for v:msgpack_types.binary in the wild would be broken. This appears to be rarely used in existing plugins. Also some cases where v:msgpack_type.string would be used to represent a binary string of "string" type, we use a BLOB instead, which is vimscripts native type for binary blobs, and already was used for BIN formats when necessary. msgpackdump(msgpackparse(data)) no longer preserves the distinction of BIN and STR strings. This is very common behavior for language-specific msgpack bindings. Nvim uses msgpack as a tool to serialize its data. Nvim is not a tool to bit-perfectly manipulate arbitrary msgpack data out in the wild. The changed tests should indicate how behavior changes in various edge cases.
2024-06-24refactor(typval): don't use msgpack_packer for msgpackdump()bfredl1
Step towords completely eliminating msgpack_packer.
2024-06-11refactor(shada): use msgpack_sbuffer lessbfredl1
Work towards getting rid of libmsgpack depedency eventually. msgpack_sbuffer is just a string buffer, we can use our own String type.
2024-06-04fixup: apply the change on more filesJames Tirta Halim1
2024-04-17test: API can return Lua function to Lua code (#28380)zeertzjq1
2024-04-16test: make mapping tests more consistent (#28368)zeertzjq1
- Test maparg() and maplist() in the same test. - Use matches() instead of string.match(). - Avoid overlong lines and strange spacing in exec_lua(). - Revert code change from last PR as the variable may be needed.
2024-04-16test: getting autocmd Lua callback in Vimscript (#28367)zeertzjq1
Also remove unnecessary variable in API converter.
2024-03-12refactor: use ml_get_buf_len() in API code (#27825)zeertzjq1
2024-03-07refactor(msgpack): allow flushing buffer while packing msgpackbfredl2
Before, we needed to always pack an entire msgpack_rpc Object to a continous memory buffer before sending it out to a channel. But this is generally wasteful. it is better to just flush whatever is in the buffer and then continue packing to a new buffer. This is also done for the UI event packer where there are some extra logic to "finish" of an existing batch of nevents/ncalls. This doesn't really stop us from flushing the buffer, just that we need to update the state machine accordingly so the next call to prepare_call() always will start with a new event (even though the buffer might contain overflow data from a large event).
2024-02-28refactor(metadata): generate all metadata in luabfredl1
Then we can just load metadata in C as a single msgpack blob. Which also can be used directly as binarly data, instead of first unpacking all the functions and ui_events metadata to immediately pack it again, which was a bit of a silly walk (and one extra usecase of `msgpack_rpc_from_object` which will get yak shaved in the next PR)
2024-02-21refactor(api): make freeing of return-value opt-in instead of opt outbfredl2
As only a few API functions make use of explicit freeing of the return value, make it opt-in instead. The arena is always present under the hood, so `Arena *arena` arg now doesn't mean anything other than getting access to this arena. Also it is in principle possible to return an allocated value while still using the arena as scratch space for other stuff (unlikely, but there no reason to not allow it).
2024-02-19refactor(api): use arena for nvim_put and nvim_pastebfredl1
2024-02-18refactor(api): use arena for metadata; msgpack_rpc_to_object delenda estbfredl1
Note: kSDItemHeader is something is _written_ by nvim in the shada file to identify it for debugging purposes outside of nvim. But this data wasn't ever used by neovim after reading the file back, So I removed the parsing of it for now.
2024-02-18refactor(api): use arena for autocmdsbfredl1
2024-02-18refactor(api): use an arena for mappingsbfredl2
2024-02-15refactor(eval): use arena when converting typvals to Objectbfredl3
Note: this contains two _temporary_ changes which can be reverted once the Arena vs no-Arena distinction in API wrappers has been removed. Both nlua_push_Object and object_to_vim_take_luaref() has been changed to take the object argument as a pointer. This is not going to be necessary once these are only used with arena (or not at all) allocated Objects. The object_to_vim() variant which leaves luaref untouched might need to stay for a little longer.
2024-02-13refactor(lua): use Arena when converting from lua stack to API argsbfredl2
and for return value of nlua_exec/nlua_call_ref, as this uses the same family of functions. NB: the handling of luaref:s is a bit of a mess. add api_luarefs_free_XX functions as a stop-gap as refactoring luarefs is a can of worms for another PR:s. as a minor feature/bug-fix, nvim_buf_call and nvim_win_call now preserves arbitrary return values.
2024-02-09refactor(api): use arena for nvim_parse_cmd()bfredl1
2024-02-09refactor(api): make cstr_as_string accept "const char*"bfredl1
In the context a String inside an Object/Dictionary etc is consumed, it is considered to be read-only.
2024-02-08refactor(api): use keydict and arena for more api return valuesbfredl2
Implement api_keydict_to_dict as the complement to api_dict_to_keydict Fix a conversion error when nvim_get_win_config gets called from lua, where Float values "x" and "y" didn't get converted to lua numbers.
2024-01-27fix(api): limit depth of nvim_cmd (#27225)zeertzjq1
2024-01-22refactor(api): give "hl_group" more accurate _meta typebfredl1
These can either be number or string in lua, so we can specify this directly as "number|string".