aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/lua/executor.c
Commit message (Collapse)AuthorAge
* fix(lua): pop retval for fast context LuaRefLuuk van Baal2025-01-24
| | | | | | Problem: nlua_call_ref_ctx() does not pop the return value in fast context that did not error. Solution: Fall through to end; calling nlua_call_pop_retval().
* fix(lua): prevent SIGSEGV when lua error is NULL in libuv_worker林玮 (Jade Lin)2025-01-18
| | | | | | | | | | | | | Problem: Calling `xstrdup` with a NULL pointer causes a SIGSEGV if `lua_tostring` returns NULL in `nlua_luv_thread_common_cfpcall`. Crash stack trace: - `_platform_strlen` → `xstrdup` (memory.c:469) - `nlua_luv_thread_common_cfpcall` (executor.c:281) Solution: Check if `lua_tostring` returns NULL and pass NULL to `event_create` to avoid the crash.
* 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").
* fix(messages): proper multiline Lua print() messages #31205luukvbaal2024-11-17
| | | | | | Problem: Separate message emitted for each newline present in Lua print() arguments. Solution: Make msg_multiline() handle NUL bytes. Refactor print() to use msg_multiline(). Refactor vim.print() to use print().
* fix(messages)!: vim.ui_attach message callbacks are unsafeLuuk van Baal2024-11-14
| | | | | | | | Problem: Lua callbacks for "msg_show" events with vim.ui_attach() are executed when it is not safe. Solution: Disallow non-fast API calls for "msg_show" event callbacks. Automatically detach callback after excessive errors. Make sure fast APIs do not modify Nvim state.
* fix(lua): show stacktrace for error in vim.on_key() callback (#31021)zeertzjq2024-11-02
|
* feat(lua): allow vim.on_key() callback to consume the key (#30939)errael2024-11-01
|
* fix(lua): avoid recursive vim.on_key() callback (#30753)zeertzjq2024-10-12
|
* feat(treesitter): add support for wasm parsersLewis Russell2024-08-26
| | | | | | | | | | | | | | | | | | | | Problem: Installing treesitter parser is hard (harder than climbing to heaven). Solution: Add optional support for wasm parsers with `wasmtime`. Notes: * Needs to be enabled by setting `ENABLE_WASMTIME` for tree-sitter and Neovim. Build with `make CMAKE_EXTRA_FLAGS=-DENABLE_WASMTIME=ON DEPS_CMAKE_FLAGS=-DENABLE_WASMTIME=ON` * Adds optional Rust (obviously) and C11 dependencies. * Wasmtime comes with a lot of features that can negatively affect Neovim performance due to library and symbol table size. Make sure to build with minimal features and full LTO. * To reduce re-compilation times, install `sccache` and build with `RUSTC_WRAPPER=<path/to/sccache> make ...`
* fix(input): handle vim.on_key() properly with ALT and K_SPECIAL (#29677)zeertzjq2024-07-13
|
* fix(lua): don't include text after cursor in completion pattern (#29587)zeertzjq2024-07-06
|
* refactor(lua): remove unnecessary strlen() in nlua_expand_pat() (#29388)zeertzjq2024-06-18
| | | | Also change the initial value of `status` to `FAIL`, as that'll avoid unnecessary assignments.
* fix(lua): find length of completion prefix earlier (#29384)zeertzjq2024-06-18
| | | | | Do the expansion right after setting the expand context, so that the length of the completion prefix can be set, but don't do that directly in set_one_cmd_context(), as that's also called by getcmdcompltype().
* refactor: move shared messages to errors.h #26214Justin M. Keyes2024-06-01
|
* refactor(source): remove unnecessary concatenation with Lua (#28499)zeertzjq2024-04-25
|
* fix(lua): only free luarefs when returning from API (#28373)zeertzjq2024-04-17
|
* feat(lua): pass keys before mapping to vim.on_key() callback (#28098)zeertzjq2024-03-31
| | | Keys before mapping (i.e. typed keys) are passed as the second argument.
* test: add a bit more testing for vim.on_key() (#28095)zeertzjq2024-03-29
| | | | | Also: - Don't use NUMBUFLEN as buffer length as its unrelated. - Restore accidentally removed comment from last commit.
* refactor(treesitter): redesign query iteratingLewis Russell2024-03-19
| | | | | | | | | | | | | | | | Problem: `TSNode:_rawquery()` is complicated, has known issues and the Lua and C code is awkwardly coupled (see logic with `active`). Solution: - Add `TSQueryCursor` and `TSQueryMatch` bindings. - Replace `TSNode:_rawquery()` with `TSQueryCursor:next_capture()` and `TSQueryCursor:next_match()` - Do more stuff in Lua - API for `Query:iter_captures()` and `Query:iter_matches()` remains the same. - `treesitter.c` no longer contains any logic related to predicates. - Add `match_limit` option to `iter_matches()`. Default is still 256.
* fix(api/buffer): fix handling of viewport of non-current bufferbfredl2024-03-13
| | | | | | | | | | | A lot of functions in move.c only worked for curwin, alternatively took a `wp` arg but still only work if that happens to be curwin. Refactor those that are needed for update_topline(wp) to work for any window. fixes #27723 fixes #27720
* refactor: use ml_get_buf_len() in API code (#27825)zeertzjq2024-03-12
|
* 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(fileio): remove API shell layer encouraging unnecessary allocationsbfredl2024-02-25
| | | | | | | | | | | | | | | | | | | | | | | | Functions like file_open_new() and file_open_fd_new() which just is a wrapper around the real functions but with an extra xmalloc/xfree around is an anti-pattern. If the caller really needs to allocate a FileDescriptor as a heap object, it can do that directly. FileDescriptor by itself is pretty much a pointer, or rather two: the OS fd index and a pointer to a buffer. So most of the time an extra pointer layer is just wasteful. In the case of scriptin[curscript] in getchar.c, curscript used to mean in practice: N+1 open scripts when curscript>0 zero or one open scripts when curscript==0 Which means scriptin[0] had to be compared to NULL to disambiguate the curscript=0 case. Instead, use curscript==-1 to mean that are no script, then all pointer comparisons dissappear and we can just use an array of structs without extra pointers.
* 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.
* feat(ex_cmds): no error on :lua with {range} and {code} (#27290)luukvbaal2024-02-02
| | | | | | Problem: Erroring when both {range} and {code} are supplied to :lua is inconvenient and may break mappings. Solution: Don't error, ignore {range} and execute {code} when both are supplied.
* fix(lua): avoid internal error when :luado deletes lines (#27262)zeertzjq2024-01-30
|
* docs(lua): update ":{range}lua" docs + error message #27231Justin M. Keyes2024-01-27
| | | | | - `:lua (no file)` is misleading because `:lua` never takes a file arg, unlike `:source`. - Update various related docs.
* feat(ex_cmds): ranged :lua #27167luukvbaal2024-01-26
| | | | | | :{range}lua executes the specified lines in the current buffer as Lua code, regardless of its extension or 'filetype'. Close #27103
* 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: remove os_errmsg and os_msg functionsdundargoc2023-12-23
| | | | Instead replace them with fprintf and printf.
* refactor: run IWYU on entire repodundargoc2023-12-21
| | | | Reference: https://github.com/neovim/neovim/issues/6371.
* refactor: eliminate cyclic includesdundargoc2023-12-20
|
* refactor: move non-symbols to defs.h headersdundargoc2023-12-17
|
* fix(lua): memory leak when using invalid syntax with exists() (#26530)zeertzjq2023-12-12
|
* feat(eval): exists() function supports checking v:lua functions (#26485)Raphael2023-12-12
| | | | Problem: Vimscript function exists() can't check v:lua functions. Solution: Add support for v:lua functions to exists().
* vim-patch:8.2.3695: confusing error for missing key (#26420)zeertzjq2023-12-06
| | | | | | | | Problem: Confusing error for missing key. Solution: Use the actualy key for the error. (closes vim/vim#9241) https://github.com/vim/vim/commit/5c1ec439f0a69e9aa7ece9bbb7d916f48f58be1e Co-authored-by: Bram Moolenaar <Bram@vim.org>
* refactor: change event_create() to a macro (#26343)zeertzjq2023-12-01
| | | A varargs functions can never be inlined, so a macro is faster.
* refactor: fix headers with IWYUdundargoc2023-11-28
|
* build(IWYU): fix includes for undo_defs.hdundargoc2023-11-27
|
* docs: small fixes (#26154)dundargoc2023-11-27
|
* fix(lua): disallow vim.wait() in fast contextsLewis Russell2023-11-27
| | | | | | | `vim.wait()` cannot be called in a fast callback since the main loop cannot be run in that context as it is not reentrant Fixes #26122
* refactor: enable formatting for ternariesdundargoc2023-11-20
| | | | | | This requires removing the "Inner expression should be aligned" rule from clint as it prevents essentially any formatting regarding ternary operators.
* build: bump uncrustify versiondundargoc2023-11-19
| | | | Biggest change is that uncrustify is silent during linting.
* fix(lua): only disable vim.schedule() when closing main loop (#26090)zeertzjq2023-11-17
|
* fix(lua): do not schedule events if Nvim is exitingGregory Anders2023-11-13
| | | | | | If Nvim is in the process of exiting then we do not want to allocate any new refs onto the event loop, because they will not be freed and will result in a memory leak.
* build: remove PVSdundargoc2023-11-12
| | | | | | | We already have an extensive suite of static analysis tools we use, which causes a fair bit of redundancy as we get duplicate warnings. PVS is also prone to give false warnings which creates a lot of work to identify and disable.