From f7a0ebcdc0fada21c1fb1d6502f5bd75d8eb6144 Mon Sep 17 00:00:00 2001 From: Lin Tianchuan <47070449+1024th@users.noreply.github.com> Date: Fri, 19 Jul 2024 22:53:22 +0800 Subject: [PATCH] fix(mappings): add a note for overriding mapping Related issue: https://github.com/AstroNvim/AstroNvim/issues/2353#issuecomment-1787490855 --- src/content/docs/recipes/mappings.mdx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/content/docs/recipes/mappings.mdx b/src/content/docs/recipes/mappings.mdx index a61d575c7..0349058ed 100644 --- a/src/content/docs/recipes/mappings.mdx +++ b/src/content/docs/recipes/mappings.mdx @@ -9,6 +9,12 @@ Mappings can be customized through [AstroCore](https://github.com/AstroNvim/astr These tables are a direct conversion to the `vim.keymap.set({mode}, {lhs}, {rhs}, {opts})` Lua API. The first key into the table is the `{mode}`, the second key into the table is the `{lhs}`, and the element there is the `{opts}` table with the `{rhs}` in the first key. Also AstroLSP supports adding a `cond` key which can dictate when the mapping should be attached (this is described in detail in the [AstroLSP plugin configuration documentation](https://github.com/AstroNvim/astrolsp#%EF%B8%8F-configuration)) Here is a simple plugin specification example of setting both core and LSP mappings: +:::note + +If you want to override a default mapping, the key needs to exactly match (case sensitive) the existing definition in the table; otherwise, there is a race condition. AstroCore uses capital modifiers. + +::: + ```lua title="lua/plugins/mappings.lua" return { { @@ -33,7 +39,7 @@ return { -- this is useful for naming menus ["b"] = { name = "Buffers" }, -- quick save - -- [""] = { ":w!", desc = "Save File" }, -- change description but the same command + -- [""] = { ":w!", desc = "Save File" }, -- change description but the same command }, t = { -- setting a mapping to false will disable it