Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/9999years/batteries.nvim

Ergonomic Neovim Lua bindings for mappings and commands
https://github.com/9999years/batteries.nvim

neovim

Last synced: 23 days ago
JSON representation

Ergonomic Neovim Lua bindings for mappings and commands

Awesome Lists containing this project

README

        

# batteries.nvim

Ergonomic Neovim Lua bindings.

See `:h batteries` or [9999years.github.io/batteries.nvim][docs] for thorough
documentation.

[docs]: https://9999years.github.io/batteries.nvim/

# batteries.map()

Define key mappings:

```lua
-- :nnoremap og Browse
require("batteries").map {
-- When I hit `\og`...
"og",
-- Execute the `:Browse` command.
"Browse",
-- Set a description:
"Open file on GitHub",
}

-- Define multiple mappings with a common prefix together:
require("batteries").map {
prefix = "",
{ "t", "Telescope", "Telescope" },
-- Buffer local mapping:
{ "f", "Telescope find_files", "Find files", buffer = 3 },
}
```

The following definitions are equivalent:

```lua
require("batteries").map {
prefix = "f",
name = "+file",
{ "f", "Telescope find_files", "Find file" },
{ "r", "Telescope oldfiles", "Open recent file" },
{ "n", "enew", "New file" },
}

require("batteries").map {
{ prefix = "f", name = "+file" },
{ "ff", "Telescope find_files", "Find file" },
{ "fr", "Telescope oldfiles", "Open recent file" },
{ "fn", "enew", "New file" },
}
```

# batteries.cmd()

Define a command:

```lua
require("batteries").cmd {
range = true,
nargs = 0,
"Browse",
",OpenGithubFile",
}

require("batteries").cmd {
nargs = "?",
complete = "filetype",
"EditFtplugin",
"call misc#EditFtplugin()",
}
```