aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private
Commit message (Collapse)AuthorAge
* feat(api): add err field to nvim_echo() optsLuuk van Baal2025-01-09
| | | | | | | | 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`.
* refactor: iwyu #31637Justin M. Keyes2024-12-23
| | | Result of `make iwyu` (after some "fixups").
* refactor(api): always use TRY_WRAP #31600luukvbaal2024-12-17
| | | | | | | 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.
* fix(api): not using TRY_WRAP, generic error messages #31595Justin M. Keyes2024-12-16
| | | | | | | | | | | 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`.
* feat(keysets): teach Union and LuaRefOfLewis Russell2024-11-25
|
* fix(api): nvim_echo free text memory with invalid highlight (#31243)luukvbaal2024-11-17
| | | Fix regression from #31195
* fix(api): validation, documentation of hl_group #31195luukvbaal2024-11-16
| | | | | | | | 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.
* refactor(message): propagate highlight id instead of attrsLuuk van Baal2024-11-08
| | | | | | | 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.
* vim-patch:9.1.0824: too many strlen() calls in register.c (#31022)zeertzjq2024-11-01
| | | | | | | | | | | 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>
* refactor(api)!: rename Dictionary => DictJustin M. Keyes2024-09-23
| | | | | | | | | | | | | | 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.
* fix(api): nvim_buf_get_text() crashes with large negative column #28740vanaigr2024-09-03
| | | | | | | | | | 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.
* fix(highlight): fix the seg fault caused by the invalid linked hl idsWilliam Wong2024-08-14
|
* refactor(shada): rework msgpack decoding without msgpack-cbfredl2024-08-05
| | | | | | | 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.
* refactor(declarations): also generate prototypes for functions in headersbfredl2024-07-13
| | | | | | | | | | | 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).
* refactor(typval)!: remove distinction of binary and nonbinary stringsbfredl2024-06-27
| | | | | | | | | | | | | | | | | | | | | 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.
* refactor(typval): don't use msgpack_packer for msgpackdump()bfredl2024-06-24
| | | | Step towords completely eliminating msgpack_packer.
* refactor(shada): use msgpack_sbuffer lessbfredl2024-06-11
| | | | | | | Work towards getting rid of libmsgpack depedency eventually. msgpack_sbuffer is just a string buffer, we can use our own String type.
* fixup: apply the change on more filesJames Tirta Halim2024-06-04
|
* test: API can return Lua function to Lua code (#28380)zeertzjq2024-04-17
|
* test: make mapping tests more consistent (#28368)zeertzjq2024-04-16
| | | | | | - 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.
* test: getting autocmd Lua callback in Vimscript (#28367)zeertzjq2024-04-16
| | | Also remove unnecessary variable in API converter.
* refactor: use ml_get_buf_len() in API code (#27825)zeertzjq2024-03-12
|
* refactor(msgpack): allow flushing buffer while packing msgpackbfredl2024-03-07
| | | | | | | | | | | | | | 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).
* refactor(metadata): generate all metadata in luabfredl2024-02-28
| | | | | | | | 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)
* refactor(api): make freeing of return-value opt-in instead of opt outbfredl2024-02-21
| | | | | | | | | 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).
* refactor(api): use arena for nvim_put and nvim_pastebfredl2024-02-19
|
* refactor(api): use arena for metadata; msgpack_rpc_to_object delenda estbfredl2024-02-18
| | | | | | 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.
* refactor(api): use arena for autocmdsbfredl2024-02-18
|
* refactor(api): use an arena for mappingsbfredl2024-02-18
|
* refactor(eval): use arena when converting typvals to Objectbfredl2024-02-15
| | | | | | | | | | | | 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.
* refactor(lua): use Arena when converting from lua stack to API argsbfredl2024-02-13
| | | | | | | | | | | | 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.
* refactor(api): use arena for nvim_parse_cmd()bfredl2024-02-09
|
* refactor(api): make cstr_as_string accept "const char*"bfredl2024-02-09
| | | | | In the context a String inside an Object/Dictionary etc is consumed, it is considered to be read-only.
* refactor(api): use keydict and arena for more api return valuesbfredl2024-02-08
| | | | | | | 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.
* fix(api): limit depth of nvim_cmd (#27225)zeertzjq2024-01-27
|
* refactor(api): give "hl_group" more accurate _meta typebfredl2024-01-22
| | | | | These can either be number or string in lua, so we can specify this directly as "number|string".
* refactor(api): use hl id directly in nvim_buf_set_extmarkglepnir2024-01-20
|
* refactor(IWYU): fix headersdundargoc2024-01-11
| | | | | | Remove `export` pramgas from defs headers as it causes IWYU to believe that the definitions from the defs headers comes from main header, which is not what we really want.
* refactor: follow style guidedundargoc2023-12-30
|
* refactor(IWYU): add "private" pragma to more generated headers (#26706)zeertzjq2023-12-22
| | | | | "export" only prevents IWYU from adding these headers if the headers that export them are included, while "private" ensures that IWYU never adds these headers.
* refactor: run IWYU on entire repodundargoc2023-12-21
| | | | Reference: https://github.com/neovim/neovim/issues/6371.
* fix(api): don't set coladd of mark (#26648)zeertzjq2023-12-19
|
* refactor: move some anonymous enums back to non-defs headers (#26622)zeertzjq2023-12-18
| | | | | | | | | | It isn't really useful to put anonymous enums only used as arguments to functions calls in _defs.h headers, as they will only be used by a file that calls those functions, which requires including a non-defs header. Also move os_msg() and os_errmsg() back to message.h, as on Windows they are actual functions instead of macros. Also remove gettext.h and globals.h from private/helpers.h.
* refactor: move non-symbols to defs.h headersdundargoc2023-12-17
|
* refactor: object_to_vim() cannot failJustin M. Keyes2023-12-07
| | | | | Since the parent commit, object_to_vim() can't fail, so callers don't need to check its result.
* feat(rpc): allow empty string key in msgpack => Vim conversionJustin M. Keyes2023-12-07
| | | | | | | | | | | | | | | | Problem: Since e057b38e7037 #20757 we support empty key in JSON encode/decode, but we don't allow it in RPC object => Vim dict conversion. But empty string is a valid key in Vim dicts and the msgpack spec. Empty string key was disallowed in 7c01d5ff9286 (2014) but that commit/PR doesn't explicitly discuss it, so presumably it was a "seems reasonable" decision (or Vimscript didn't allow empty keys until later). Solution: Remove the check in `object_to_vim()`. Note that `tv_dict_item_alloc_len` will invoke `memcpy(…, 0)` but that's allowed by the C spec: https://stackoverflow.com/a/3751937/152142
* refactor(IWYU): move UI and LineFlags to ui_defs.h (#26318)zeertzjq2023-11-30
|
* build: don't define FUNC_ATTR_* as empty in headers (#26317)zeertzjq2023-11-30
| | | | | | FUNC_ATTR_* should only be used in .c files with generated headers. Defining FUNC_ATTR_* as empty in headers causes misuses of them to be silently ignored. Instead don't define them by default, and only define them as empty after a .c file has included its generated header.
* refactor: fix headers with IWYUdundargoc2023-11-28
|
* refactor: fix runtime_defs.h (#26259)zeertzjq2023-11-28
|