mappy.nvim
mappy.nvim copied to clipboard
Simple wrapper around vim.keymap.set
mappy.nvim
mappy.nvim is a simple wrapper around vim.keymap.set for nightly builds or vim.api.nvim_set_keymap for stable builds function. Supports tables.
Installation
use({"shift-d/mappy.nvim"})
Planned features
- Telescope picker to view your mappings
Features
- Stable-compatible
- Nested mappings
- Multiple modes
- which-key.nvim integration
- Register mappings based on event
Usage
Setup
versionparam creates an alias formappy:stableormappy:nightlyfunction. By default mappy:map is a placeholder function. Accepts either"nightly"or"stable"
require("mappy")({
version = "stable" | "nightly"
})
Creating a "module"
Use mappy:new() to create a default module.
local module = require("mappy"):new()
Setting values
Adding map table into module
module:set_maps({
lhs = rhs,
nested_ = {
_lhs = rhs,
}
})
Adding options table into module
module:set_opts({
modes = "modechar" | { "mode", "char" },
map = {...} -- Look at the docs of map function's api
})
Setting an event of module
module:set_event("VimEvent") -- see :h events
Mapping
Note that mappy:set_maps function should be called before.
If config.version exists
module:map()
Stable mode
Stable mode is using vim.api.nvim_set_keymap function to set mappings. Useful for 6.1 and previous versions of neovim.
module:stable()
Nightly mode
Nightly mode is using vim.keymap.set function to set mappings. Neovim nightly is required. (probably will included in next stable release of neovim)
module:nightly()
VimEvent-based mapping
Requirements:
mappy:set_eventcalledconfig.versionset
-- storage is a name for table with event map. must be different for every call.
module:event_map(storage)
Which-key integration
Setting map
module:map({
lhs = description,
nested_ = {
_lhs = description
}
})
Setting description
mappy:link()