summaryrefslogtreecommitdiffstatshomepage
path: root/src/nvim/lua/executor.c
AgeCommit message (Collapse)AuthorFiles
2024-11-01feat(lua): allow vim.on_key() callback to consume the key (#30939)errael1
2024-10-12fix(lua): avoid recursive vim.on_key() callback (#30753)zeertzjq1
2024-08-26feat(treesitter): add support for wasm parsersLewis Russell1
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 ...`
2024-07-13fix(input): handle vim.on_key() properly with ALT and K_SPECIAL (#29677)zeertzjq1
2024-07-06fix(lua): don't include text after cursor in completion pattern (#29587)zeertzjq1
2024-06-18refactor(lua): remove unnecessary strlen() in nlua_expand_pat() (#29388)zeertzjq1
Also change the initial value of `status` to `FAIL`, as that'll avoid unnecessary assignments.
2024-06-18fix(lua): find length of completion prefix earlier (#29384)zeertzjq1
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().
2024-06-01refactor: move shared messages to errors.h #26214Justin M. Keyes1
2024-04-25refactor(source): remove unnecessary concatenation with Lua (#28499)zeertzjq1
2024-04-17fix(lua): only free luarefs when returning from API (#28373)zeertzjq1
2024-03-31feat(lua): pass keys before mapping to vim.on_key() callback (#28098)zeertzjq1
Keys before mapping (i.e. typed keys) are passed as the second argument.
2024-03-29test: add a bit more testing for vim.on_key() (#28095)zeertzjq1
Also: - Don't use NUMBUFLEN as buffer length as its unrelated. - Restore accidentally removed comment from last commit.
2024-03-19refactor(treesitter): redesign query iteratingLewis Russell1
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.
2024-03-13fix(api/buffer): fix handling of viewport of non-current bufferbfredl1
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
2024-03-12refactor: use ml_get_buf_len() in API code (#27825)zeertzjq1
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-25refactor(fileio): remove API shell layer encouraging unnecessary allocationsbfredl1
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.
2024-02-18refactor(api): use an arena for mappingsbfredl1
2024-02-15refactor(eval): use arena when converting typvals to Objectbfredl1
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 argsbfredl1
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-02feat(ex_cmds): no error on :lua with {range} and {code} (#27290)luukvbaal1
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.
2024-01-30fix(lua): avoid internal error when :luado deletes lines (#27262)zeertzjq1
2024-01-27docs(lua): update ":{range}lua" docs + error message #27231Justin M. Keyes1
- `:lua (no file)` is misleading because `:lua` never takes a file arg, unlike `:source`. - Update various related docs.
2024-01-26feat(ex_cmds): ranged :lua #27167luukvbaal1
:{range}lua executes the specified lines in the current buffer as Lua code, regardless of its extension or 'filetype'. Close #27103
2024-01-11refactor(IWYU): fix headersdundargoc1
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.
2023-12-30refactor: follow style guidedundargoc1
2023-12-23refactor: remove os_errmsg and os_msg functionsdundargoc1
Instead replace them with fprintf and printf.
2023-12-21refactor: run IWYU on entire repodundargoc1
Reference: https://github.com/neovim/neovim/issues/6371.
2023-12-20refactor: eliminate cyclic includesdundargoc1
2023-12-17refactor: move non-symbols to defs.h headersdundargoc1
2023-12-12fix(lua): memory leak when using invalid syntax with exists() (#26530)zeertzjq1
2023-12-12feat(eval): exists() function supports checking v:lua functions (#26485)Raphael1
Problem: Vimscript function exists() can't check v:lua functions. Solution: Add support for v:lua functions to exists().
2023-12-06vim-patch:8.2.3695: confusing error for missing key (#26420)zeertzjq1
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>
2023-12-01refactor: change event_create() to a macro (#26343)zeertzjq1
A varargs functions can never be inlined, so a macro is faster.
2023-11-28refactor: fix headers with IWYUdundargoc1
2023-11-27build(IWYU): fix includes for undo_defs.hdundargoc1
2023-11-27docs: small fixes (#26154)dundargoc1
2023-11-27fix(lua): disallow vim.wait() in fast contextsLewis Russell1
`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
2023-11-20refactor: enable formatting for ternariesdundargoc1
This requires removing the "Inner expression should be aligned" rule from clint as it prevents essentially any formatting regarding ternary operators.
2023-11-19build: bump uncrustify versiondundargoc1
Biggest change is that uncrustify is silent during linting.
2023-11-17fix(lua): only disable vim.schedule() when closing main loop (#26090)zeertzjq1
2023-11-13fix(lua): do not schedule events if Nvim is exitingGregory Anders1
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.
2023-11-12build: remove PVSdundargoc1
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.
2023-11-10fix(f_wait): flush UI before blocking (#25962)zeertzjq1
2023-11-08fix: flush UI state before blocking in vim.wait (#25938)Gregory Anders1
2023-11-08refactor: move defaults into separate module (#25929)Gregory Anders1
Move default mappings and autocommands into a separate module and add comments and docstrings to document each of the defaults.
2023-11-05refactor: the long goodbyedundargoc1
long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types.
2023-10-14fix(ui): empty line before the next message after :silent commandnwounkn1
Problem: The next command after `silent !{cmd}` or `silent lua print('str')` prints an empty line before printing a message, because these commands set `msg_didout = true` despite not printing any messages. Solution: Set `msg_didout = true` only if `msg_silent == 0`
2023-10-02refactor: move cmdline completion types to cmdexpand_defs.h (#25465)zeertzjq1
2023-09-30refactor: reorganize option header files (#25437)zeertzjq1
- Move vimoption_T to option.h - option_defs.h is for option-related types - option_vars.h corresponds to Vim's option.h - option_defs.h and option_vars.h don't include each other