Overview
The mapping configuration uses the nvim name shorcuts as:
<C>
-> Ctrl<leader>
-> Space<A>
-> alt<S>
-> shift
- The default mappings are defined in
core.mappings
(`core/mappings.lua). - Alternatively, you can use
NvCheatsheet
orTelescope keymaps
to list all mappings.
Mapping format
In order to list custom shortcuts in NvCheatsheet, make sure to use the following format
-- opts is an optional parameter
["keys"] = {"action", "description", opts = {}},
["<C-n>"] = {"<cmd> NvimTreeToggle <CR>", "Toggle nvimtree"},
["<leader>ff"] = {"<cmd> Telescope <CR>", "Telescope"},
-- opts can have the props: buffer, silent, noremap, nowait and so on.
-- All standard key binding opts are supported.
[";"] = { ":", "enter cmdline", opts = { nowait = true } },
-- For a more complex keymap
["<leader>tt"] = {
function()
require("base46").toggle_transparency()
end,
"toggle transparency",
},
Add new mappings
-
In order to add or customize the mappings, make sure that you follow the expected file structure for NvChad.
-
The default mappings are loaded from
core.mappings
, and it is recommended that you place your mappings insidecustom.mappings
file. -
Remember that the mappings must have a vim mode:
n
(for normal),v
(for visual),i
(for insert) and so on. -
custom/chadrc.lua
M.mappings = require "custom.mappings"
- custom/mappings.lua
local M = {}
-- In order to disable a default keymap, use
M.disabled = {
n = {
["<leader>h"] = "",
["<C-a>"] = ""
}
}
-- Your custom mappings
M.abc = {
n = {
["<C-n>"] = {"<cmd> Telescope <CR>", "Telescope"},
["<C-s>"] = {":Telescope Files <CR>", "Telescope Files"}
},
i = {
["jk"] = { "<ESC>", "escape insert mode" , opts = { nowait = true }},
-- ...
}
}
return M
Mappings will be automatically loaded. You don't need to load them manually!
Manually load mappings
Even though it is not required, you can manually load your mappings
M.some_plugin_name = {
plugin = true, -- Important
n = {
["<C-n>"] = {"<cmd> Telescope <CR>", "Telescope"}
}
}
-- Now to load it
require("core.utils").load_mappings("someplugin")