summaryrefslogtreecommitdiffstatshomepage
path: root/test/functional/api/keymap_spec.lua
AgeCommit message (Collapse)AuthorFiles
2026-04-24fix(api): LuaRef leak in nvim_set_keymap on LHS too long (>=66 bytes) #39351Barrett Ruth1
Problem: `nvim_set_keymap` leaks the `callback` `LuaRef` when the LHS is too long. Solution: Make `set_maparg_lhs_rhs` transfer `rhs_lua` to `MapArguments` up front so the caller always owns the ref.
2026-04-13feat(api): rename buffer to buf in retval #38900Justin M. Keyes1
In 3a4a66017b74192caaf9af9af172bdc08e0c1608, 4d3a67cd620152d11ab9b5f5bdd973f84cc2d44b we renamed "buffer" to "buf" in dict parameters. This commit also renames such keys in dict return-values.
2026-03-16fix(api): use standard error messagesJustin M. Keyes1
2026-01-07fix(mappings): always include replace_keycodes in mapping dicts (#37272)zeertzjq1
Omitting replace_keycodes when it is false causes some confusion as its default value is unclear. In nvim_set_keymap() it defaults to false, but in vim.keymap.set() it defaults to true when it matters.
2025-07-08test(api): nvim_get_keymap returns correct lhsraw and lhsrawaltzeertzjq1
2025-04-01fix(api): nvim_set_keymap() throws error even in pcall() #33228tstsrt1
Problem: When `nvim_set_keymap` tries to overwrite a `<unique>` mapping, it throws an error even when called in `pcall`. Solution: src/nvim/mapping.c:buf_do_map no longer calls `semsg`. Its callers now decide whether to ignore the error, or use `semsg` (not caught)/`api_set_error` (caught by `pcall`).
2025-03-30fix(api): use E226 instead of E227 for duplicate abbreviation (#33159)zeertzjq1
2025-03-29fix(api): use original LHS in keymap error message #33135Gregory Anders1
When setting a keymap with "unique" that already exists the error message contains the LHS of the keymap with termcodes replaced. In particular this means that keys like <Tab> show as an actual tab character, meaning the error message displays as "Mapping already exists for ", which is hard to debug for users. Instead, display the original LHS (without any simplification or parsed termcodes). This rperesents exactly what the user passed to the `lhs` argument of `nvim_set_keymap`, which makes it easier to find where the offending keymap is.
2024-04-23test: improve test conventionsdundargoc1
Specifically, functions that are run in the context of the test runner are put in module `test/testutil.lua` while the functions that are run in the context of the test session are put in `test/functional/testnvim.lua`. Closes https://github.com/neovim/neovim/issues/27004.
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-10refactor(test): inject after_each differentlyLewis Russell1
2024-04-08test: improve test conventionsdundargoc1
Work on https://github.com/neovim/neovim/issues/27004.
2024-04-06test: reduce sleep for file timestamp change (#28196)zeertzjq1
Now that Nvim always supports nanotime, sleeping for some milliseconds is enough.
2024-01-20feat(api): support getting abbreviations (#26868)Raphael1
2024-01-12test: rename (meths, funcs) -> (api, fn)Lewis Russell1
2024-01-12test: normalise nvim bridge functionsLewis Russell1
- remove helpers.cur*meths - remove helpers.nvim
2024-01-12test: typing for helpers.methsLewis Russell1
2024-01-12test: remove helpers.sleep()Lewis Russell1
2024-01-03refactor: format test/*Justin M. Keyes1
2023-11-29refactor: move some constants out of vim_defs.h (#26298)zeertzjq1
2023-11-09vim-patch:8.2.4932: not easy to filter the output of maplist()zeertzjq1
Problem: Not easy to filter the output of maplist(). Solution: Add mode_bits to the dictionary. (Ernie Rael, closes vim/vim#10356) https://github.com/vim/vim/commit/d8f5f766219273a8579947cc80b92580b6988a4b Co-authored-by: Ernie Rael <errael@raelity.com>
2023-11-09vim-patch:8.2.4861: it is not easy to restore saved mappingszeertzjq1
Problem: It is not easy to restore saved mappings. Solution: Make mapset() accept a dict argument. (Ernie Rael, closes vim/vim#10295) https://github.com/vim/vim/commit/51d04d16f21e19d6eded98f9530d84089102f925 Co-authored-by: Ernie Rael <errael@raelity.com>
2023-11-09vim-patch:8.2.4140: maparg() does not indicate the type of scriptzeertzjq1
Problem: maparg() does not indicate the type of script where it was defined. Solution: Add "scriptversion". https://github.com/vim/vim/commit/a9528b39a666dbaa026320f73bae4b1628a7fe51 Co-authored-by: Bram Moolenaar <Bram@vim.org>
2023-11-09refactor(api): simplify nvim_set_keymap shortname check (#25945)zeertzjq1
2023-06-10test: more tests for nvim_{set,del}_keymap with abbreviation (#23970)zeertzjq1
2023-06-09feat(api): support abbreviations in nvim_set_keymapbfredl1
closes #19198
2023-05-10fix(redo): make redo of Lua mappings in op-pending mode work (#23566)zeertzjq1
2023-03-26test: use exec_capture() in more places (#22787)zeertzjq1
Problem: Using `meths.exec2("code", { output = true })` is too verbose. Solution: Use exec_capture() in more places.
2023-03-25feat(api): nvim_exec2(), deprecate nvim_exec() #19032Evgeni Chasnovski1
Problem: The signature of nvim_exec() is not extensible per ":help api-contract". Solution: Introduce nvim_exec2() and deprecate nvim_exec().
2022-11-02docs: fix typosdundargoc1
2022-09-30docs: fix typos (#20394)dundargoc1
Co-authored-by: Raphael <glephunter@gmail.com> Co-authored-by: smjonas <jonas.strittmatter@gmx.de> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
2022-08-31refactor(mappings)!: mapblock_fill_dict() use API Dictionary (#20020)zeertzjq1
This introduces the following breaking changes: - nvim_get_keymap now always returns a LuaRef object as "callback" for a Lua mapping regardless of how it is called. The LuaRef object can be called from Lua and Vim script, but is lost over RPC. - maparg() now returns a Funcref instead of a ref number as "callback" for a Lua mapping. The Funcref can be called from Lua and Vim script, but is lost over RPC. This may also make nvim_get_keymap faster, but make maparg() slower.
2022-08-03feat(lua): print source locations of lua callbacks (#19597)ii141
Co-authored-by: ii14 <ii14@users.noreply.github.com>
2022-08-02test: improve mapping tests and docs (#19619)zeertzjq1
2022-08-01test: fix api/keymap_spec.lua testszeertzjq1
2022-08-01feat(api): add replace_keycodes to nvim_set_keymap (#19598)ii141
2022-06-15feat(logging): include test-id in log messagesJustin M. Keyes1
Problem: 1. Log messages (especially in CI) are hard to correlate with tests. 2. Since b353a5c05f02 #11886, dumplog() prints the logs next to test failures. This is noisy and gets in the way of the test results. Solution: 1. Associate an incrementing id with each test and include it in log messages. - FUTURE: add v:name so Nvim instances can be formally "named"? 2. Mention "child" in log messages if the current Nvim is a child (based on the presence of $NVIM). BEFORE: DBG … 12345 UI: event DBG … 12345 log_server_msg:722: RPC ->ch 1: … DBG … 12345 UI: flush DBG … 12345 inbuf_poll:444: blocking... events_enabled=1 events_pending=0 DBG … 23454 UI: stop INF … 23454 os_exit:594: Nvim exit: 0 AFTER: DBG … T57 UI: event DBG … T57 log_server_msg:722: RPC ->ch 1: … DBG … T57 UI: flush DBG … T57 inbuf_poll:444: blocking... events_enabled=1 events_pending=0 DBG … T57/child UI: stop INF … T57/child os_exit:594: Nvim exit: 0
2022-06-01refactor: correct comments and assertions about mapping rhs <Nop> (#18821)zeertzjq1
Also avoid referring to mappings as "keymaps" in commands and docs. *map_empty_rhs* *map-empty-rhs* You can create an empty {rhs} by typing nothing after a single CTRL-V (you have to type CTRL-V two times). Unfortunately, you cannot do this in a vimrc file.
2022-04-29fix(mappings): fix double-free when unmapping simplifiable Lua mappingzeertzjq1
2022-04-29vim-patch:8.1.2145: cannot map <C-H> when modifyOtherKeys is enabledzeertzjq1
Problem: Cannot map <C-H> when modifyOtherKeys is enabled. Solution: Add the <C-H> mapping twice, both with modifier and as 0x08. Use only the first one when modifyOtherKeys has been detected. https://github.com/vim/vim/commit/459fd785e4a8d044147a3f83a5fca8748528aa84 Add REPTERM_NO_SPECIAL instead of REPTERM_SPECIAL because the meaning of "special" is different between Vim and Nvim. Omit seenModifyOtherKeys as Nvim supports attaching multiple UIs. Omit tests as they send terminal codes. Keep the behavior of API functions.
2022-03-02test: move two mapping tests to ex_cmds/map_spec.luazeertzjq1
2022-02-28feat(lua): show proper verbose output for lua configurationshadmansaleh1
`:verbose` didn't work properly with lua configs (For example: options or keymaps are set from lua, just say that they were set from lua, doesn't say where they were set at. This fixes that issue. Now `:verbose` will provide filename and line no when option/keymap is set from lua. Changes: - compiles lua/vim/keymap.lua as vim/keymap.lua - When souring a lua file current_sctx.sc_sid is set to SID_LUA - Moved finding scripts SID out of `do_source()` to `get_current_script_id()`. So it can be reused for lua files. - Added new function `nlua_get_sctx` that extracts current lua scripts name and line no with debug library. And creates a sctx for it. NOTE: This function ignores C functions and blacklist which currently contains only vim/_meta.lua so vim.o/opt wrappers aren't targeted. - Added function `nlua_set_sctx` that changes provided sctx to current lua scripts sctx if a lua file is being executed. - Added tests in tests/functional/lua/verbose_spec.lua - add primary support for additional types (:autocmd, :function, :syntax) to lua verbose Note: These can't yet be directly set from lua but once that's possible :verbose should work for them hopefully :D - add :verbose support for nvim_exec & nvim_command within lua Currently auto commands/commands/functions ... can only be defined by nvim_exec/nvim_command this adds support for them. Means if those Are defined within lua with vim.cmd/nvim_exec :verbose will show their location . Though note it'll show the line no on which nvim_exec call was made.
2022-02-16feat(mappings): considering map description when filtering (#17423)Shadman1
2022-02-16fix: <Nop> not shown in :map commandsshadmansaleh1
2022-01-10fix(completion): prevent K_LUA from closing pumzeertzjq1
2022-01-01feat(api): add support for lua function & description in keymapshadmansaleh1
Behavioral changes: 1. Added support for lua function in keymaps in -------------------------------------------- - nvim_set_keymap Can set lua function as keymap rhs like following: ```lua vim.api.nvim_{buf_}set_keymap('n', '<leader>lr', '', {callback = vim.lsp.buf.references}) ``` Note: lua function can only be set from lua . If api function being called from viml or over rpc this option isn't available. - nvim_{buf_}get_keymap When called from lua, lua function is returned is `callback` key . But in other cases callback contains number of the function ref. - :umap, nvim_del_keymap & nvim_buf_del_keymap clears lua keymaps correctly. - :map commands for displaing rhs . For lua keymaps rhs is displayed as <Lua function ref_no> Note: lua keymap cannot be set through viml command / functions. - mapargs() When dict is false it returns string in `<Lua function ref_no>` format (same format as :map commands). When dict is true it returns ref_no number in `callback` key. - mapcheck() returns string in `<Lua function ref_no>` format (same format as :map commands). 2. Added support for keymap description --------------------------------------- - nvim_{buf_}set_keymap: added `desc` option in opts table . ```lua vim.api.nvim_set_keymap('n', '<leader>w', '<cmd>w<cr>', {desc='Save current file'}) ``` - nvim_{buf_}get_keymap: contains `desc` in returned list. - commands like `:nmap <leader>w` will show description in a new line below rhs. - `maparg()` return dict contains `desc`.
2021-10-03refactor(api): handle option dicts properlyBjörn Linse1
Do not copy a lot of lua strings (dict keys) to just strequal() them Just compare them directly to a dedicated hash function. feat(generators): HASHY McHASHFACE
2021-01-03fix: check for valid buffer handles in modify_keymap (#13543)Thomas Vigouroux1
Fixes #13541 Neovim would crash when trying to map a key on non existant buffer
2020-11-13feat(lua): improve error message to make it actionable (#13276)Alvaro Muñoz1
* improve error message to make it actionable
2020-06-04vim-patch:8.2.0491: cannot recognize a <script> mapping using maparg()Jan Edmund Lazo1
Problem: Cannot recognize a <script> mapping using maparg(). Solution: Add the "script" key. (closes vim/vim#5873) https://github.com/vim/vim/commit/2da0f0c445da3c9b35b2a0cd595d10e81ad2a6f9