Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mappings): add a note for overriding mapping #158

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably mention that we normalize on the keycode casing used in the official vimdocs such as :h keycodes


:::

```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