Skip to content

n-shift/mappy.nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Status License Neovim Lua

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

  • version param creates an alias for mappy:stable or mappy:nightly function. 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_event called
  • config.version set
-- 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()

About

Simple wrapper around vim.keymap.set

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages