aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/keymap.lua
Commit message (Collapse)AuthorAge
* fix(lua): enable assignment type checking in runtime codeLewis Russell2026-09-25
| | | | | | | | | | | Enable EmmyLua's assign-type-mismatch diagnostic after correcting the runtime annotations and assignments it flags. Correct option, tuple, and return types, and use separate locals when a value changes representation. Add guards and narrow casts where needed so the runtime passes the stricter check. Regenerate the affected docs. AI-assisted
* perf(hightlight): compute only bounds for non-blockwise highlightsVolodymyr Chernetskyi2026-09-16
| | | | | | | | | | | | | Problem: vim.hl.range() computes a segment for every selected line, then discards all but the outer endpoints for characterwise and linewise highlights. This makes highlighting large yanks and puts unnecessarily expensive. Solution: Use getregionpos() with bounds=true for these highlights. Also use bounds in the keymap example that only needs the first and last selected lines. AI-assisted
* fix(keymap): report the documented parameter name #41633Volodymyr Chernetskyi2026-09-02
| | | | | | | | Problem: Invalid `modes` parameter for `vim.keymap.del()` reports wrong parameter name `"mode"`. Solution: Report correct parameter name `"mode"` instead.
* fix(api): add `lhs` option for keymap deletionBarrett Ruth2026-07-25
|
* docs: misc, options, pos/rangeJustin M. Keyes2026-05-30
|
* feat(lua): support table `lhs` in vim.keymap.set()/del() #39948Olivia Kinnear2026-05-29
| | | | | | | | | | | | | | | | | Problem: It is repetitive to map multiple keymaps to do the same thing. Here are some cases where being able to do this would be useful: -- Visual movement for both j/k and down/up: vim.keymap.set({ 'n', 'x' }, { 'j', '<Down>' }, 'v:count == 0 ? "gj" : "j"', { expr = true }) vim.keymap.set({ 'n', 'x' }, { 'k', '<Up>' }, 'v:count == 0 ? "gk" : "k"', { expr = true }) -- Map multiple keys to `<Nop>` concisely: vim.keymap.set({ 'n', 'x' }, { '<Leader>', '<Localleader>', '<CR>' }, '<Nop>') -- Remove multiple keymaps at once: vim.keymap.del('n', { 'gri', 'grn', 'grr' }) Solution: Support the `lhs` of `vim.keymap.set()` and `vim.keymap.del()` being a table, in the same way that `modes` can be.
* fix(lua): drop support for boolean `buf` in `vim.keymap` #38432skewb1k2026-03-23
| | | | | | | | | | | Problem: `vim.keymap.*.Opts.buf` allows `boolean` aliases for more widely used `integer?` values, `true` -> `0` and `false` -> `nil`. This conversion is unnecessary and can be handled at call sites. Solution: As a follow-up to deprecating the `buffer` option, drop support for boolean values for the new `buf` option. The deprecated `buffer` continues to support booleans for backward compatibility.
* feat(lua): replace `buffer` with `buf` in vim.keymap.set/del #38360skewb1k2026-03-21
| | | | | | The `buffer` option remains functional but is now undocumented. Providing both will raise an error. Since providing `buf` was disallowed before, there is no code that will break due to using `buffer` alongside `buf`.
* docs(lua): vim.keymap.set takes no `noremap` #37723Christian Clason2026-02-05
| | | | | | | Problem: Unlike `nvim_keymap_set`, `vim.keymap.set` uses the non-negated `remap` instead of `:set`'s `noremap`, but the documentation for this got lost sometime before Nvim 0.10. Solution: Restore the lost documentation and make it more explicit.
* docs(lua): iInconsistent vim.keymap param name #37026Bryan Turns2025-12-20
| | | | | | | | Problem: vim.keymap.del has 'modes' as it's first argument while vim.keymap.set has 'mode' as it's first argument despite both 'mode' and 'modes' taking in the same type input of String or String[]. Solution: Updated vim.keymap.set docs to refer to it's first argument as 'modes'.
* docs: getpos, getregion, lspJustin M. Keyes2025-11-15
|
* docs: api, pack, events, developJustin M. Keyes2025-07-10
|
* feat(vim.validate): improve fast form and deprecate spec formLewis Russell2024-10-21
| | | | | | | | | | | | | | Problem: `vim.validate()` takes two forms when it only needs one. Solution: - Teach the fast form all the features of the spec form. - Deprecate the spec form. - General optimizations for both forms. - Add a `message` argument which can be used alongside or in place of the `optional` argument.
* refactor(lua): vim.keymap.set tests, docs #30511Justin M. Keyes2024-09-25
|
* refactor(lua): type annotationsLewis Russell2024-03-16
|
* feat(docs): replace lua2dox.luaLewis Russell2024-02-27
| | | | | | | | | | | | | | | | | | | | | | | | | | Problem: The documentation flow (`gen_vimdoc.py`) has several issues: - it's not very versatile - depends on doxygen - doesn't work well with Lua code as it requires an awkward filter script to convert it into pseudo-C. - The intermediate XML files and filters makes it too much like a rube goldberg machine. Solution: Re-implement the flow using Lua, LPEG and treesitter. - `gen_vimdoc.py` is now replaced with `gen_vimdoc.lua` and replicates a portion of the logic. - `lua2dox.lua` is gone! - No more XML files. - Doxygen is now longer used and instead we now use: - LPEG for comment parsing (see `scripts/luacats_grammar.lua` and `scripts/cdoc_grammar.lua`). - LPEG for C parsing (see `scripts/cdoc_parser.lua`) - Lua patterns for Lua parsing (see `scripts/luacats_parser.lua`). - Treesitter for Markdown parsing (see `scripts/text_utils.lua`). - The generated `runtime/doc/*.mpack` files have been removed. - `scripts/gen_eval_files.lua` now instead uses `scripts/cdoc_parser.lua` directly. - Text wrapping is implemented in `scripts/text_utils.lua` and appears to produce more consistent results (the main contributer to the diff of this change).
* feat(lua): add noref to deepcopyLewis Russell2024-01-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | Problem: Currently `deepcopy` hashes every single tables it copies so it can be reused. For tables of mostly unique items that are non recursive, this hashing is unnecessarily expensive Solution: Port the `noref` argument from Vimscripts `deepcopy()`. The below benchmark demonstrates the results for two extreme cases of tables of different sizes. One table that uses the same table lots of times and one with all unique tables. | test | `noref=false` (ms) | `noref=true` (ms) | | -------------------- | ------------------ | ----------------- | | unique tables (50) | 6.59 | 2.62 | | shared tables (50) | 3.24 | 6.40 | | unique tables (2000) | 23381.48 | 2884.53 | | shared tables (2000) | 3505.54 | 14038.80 | The results are basically the inverse of each other where `noref` is much more performance on tables with unique fields, and `not noref` is more performant on tables that reuse fields.
* docs: fix type warningsMaria José Solano2023-09-23
|
* docs: replace <pre> with ``` (#25136)Gregory Anders2023-09-14
|
* docs(lua): adds links to related keymap functions to keymap.set (#24337)Mathias Fußenegger2023-07-13
| | | Might help with discovery, given that there is no `keymap.get()`
* docs: various clarifications (#23999)zeertzjq2023-06-12
| | | | | Close #18907 Close #20314 Close #23749
* docs: fix typos (#23917)Jonas Strittmatter2023-06-10
|
* docs: naming conventions, guidelinesJustin M. Keyes2023-02-22
| | | | close #21063
* docs(gen): support language annotation in docstringsChristian Clason2022-12-02
|
* docs(lua): opts in `vim.keymap.{set,del}` can be optional (#20255)Lewis Russell2022-09-20
|
* docs(lua): clarify vim.keymap.set() opts (#19761)Antoine Cotten2022-08-14
|
* docs: fix typos (#19588)dundargoc2022-08-03
| | | | Co-authored-by: zeertzjq <zeertzjq@outlook.com> Co-authored-by: notomo <notomo.motono@gmail.com>
* test: improve mapping tests and docs (#19619)zeertzjq2022-08-02
|
* feat(api): add replace_keycodes to nvim_set_keymap (#19598)ii142022-08-01
|
* chore: format runtime with styluaChristian Clason2022-05-09
|
* fix(lua): don't mutate opts parameter of vim.keymap.del (#18227)Andrey Mishchenko2022-04-23
| | | | | | `vim.keymap.del` takes an `opts` parameter that lets caller refer to and delete buffer-local mappings. For some reason the implementation of `vim.keymap.del` mutates the table that is passed in, setting `opts.buffer` to `nil`. This is wrong and also undocumented.
* docs: vim.keymap.set can specify buffer as an optionatusy2022-04-21
|
* fix(keymap): don't coerce false to ''Lewis Russell2022-04-01
|
* feat(keymap): return nil from an expr keymapLewis Russell2022-03-24
| | | | | For Lua callback expr keymaps, returning `nil` or `false` is equivalent to an empty string
* chore: fix typos (#17670)dundargoc2022-03-17
| | | Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* chore: fix typos (#17331)dundargoc2022-03-10
| | | | | | Co-authored-by: Hongyi Lyu <hongyi.lyu95@gmail.com> Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: notomo <notomo.motono@gmail.com> Co-authored-by: zeertzjq <zeertzjq@outlook.com>
* chore: remove <Plug> detection from vim.keymapshadmansaleh2022-02-27
|
* feat(lua): add vim.keymapshadmansaleh2022-01-04
This introduces two new functions `vim.keymap.set` & `vim.keymap.del` differences compared to regular set_keymap: - remap is used as opposite of noremap. By default it's true for <Plug> keymaps and false for others. - rhs can be lua function. - mode can be a list of modes. - replace_keycodes option for lua function expr maps. (Default: true) - handles buffer specific keymaps Examples: ```lua vim.keymap.set('n', 'asdf', function() print("real lua function") end) vim.keymap.set({'n', 'v'}, '<leader>lr', vim.lsp.buf.references, {buffer=true}) vim.keymap.set('n', '<leader>w', "<cmd>w<cr>", {silent = true, buffer = 5 }) vim.keymap.set('i', '<Tab>', function() return vim.fn.pumvisible() == 1 and "<C-n>" or "<Tab>" end, {expr = true}) vim.keymap.set('n', '[%', '<Plug>(MatchitNormalMultiBackward)') vim.keymap.del('n', 'asdf') vim.keymap.del({'n', 'i', 'v'}, '<leader>w', {buffer = 5 }) ```