Skip to content

Commit

Permalink
fix(mappings): add a note for overriding mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
1024th authored and mehalter committed Jul 19, 2024
1 parent 6ccf649 commit f7a0ebc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/content/docs/recipes/mappings.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
{
Expand All @@ -33,7 +39,7 @@ return {
-- this is useful for naming menus
["<Leader>b"] = { name = "Buffers" },
-- quick save
-- ["<C-s>"] = { ":w!<cr>", desc = "Save File" }, -- change description but the same command
-- ["<C-S>"] = { ":w!<cr>", desc = "Save File" }, -- change description but the same command
},
t = {
-- setting a mapping to false will disable it
Expand Down

0 comments on commit f7a0ebc

Please sign in to comment.