diff --git a/README.md b/README.md index 11098f5..5bb6537 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,6 @@ Define your keymaps, commands, and autocommands as simple Lua tables, building a - [Configuration](#configuration) - [Troubleshooting Frecency Sort](#troubleshooting-frecency-sort) - [Keymap Development Utilities](./doc/MAPPING_DEVELOPMENT.md) -- [`which-key.nvim` Integration](./doc/WHICH_KEY.md) - [Lua API](./doc/API.md) - [Extensions](./doc/EXTENSIONS.md) - [Table Structures](./doc/table_structures/README.md) @@ -34,8 +33,8 @@ Define your keymaps, commands, and autocommands as simple Lua tables, building a ## Features - Define your keymaps, commands, `augroup`/`autocmd`s, and even arbitrary Lua functions to run on the fly, as simple Lua tables, then bind them with `legendary.nvim` -- Integration with [which-key.nvim](https://github.com/folke/which-key.nvim), use your existing `which-key.nvim` tables with `legendary.nvim` -- Integration with [lazy.nvim](https://github.com/folke/lazy.nvim), automatically load keymaps defined via `lazy.nvim`'s `keys` property on plugin specs +- Integration with [which-key.nvim](https://github.com/folke/which-key.nvim), use your existing `which-key.nvim` tables with `legendary.nvim` (see [extensions](./doc/EXTENSIONS.md#which-keynvim)) +- Integration with [lazy.nvim](https://github.com/folke/lazy.nvim), automatically load keymaps defined via `lazy.nvim`'s `keys` property on plugin specs (see [extensions](./doc/EXTENSIONS.md#lazynvim)) - Execute normal, insert, and visual mode keymaps, commands, autocommands, and Lua functions when you select them - Show your most recently executed items at the top when triggered via `legendary.nvim` (can be disabled via config) - Uses `vim.ui.select()` so it can be hooked up to a fuzzy finder using something like [dressing.nvim](https://github.com/stevearc/dressing.nvim) for a VS Code command palette like interface diff --git a/doc/EXTENSIONS.md b/doc/EXTENSIONS.md index d9d05ec..d02a6a7 100644 --- a/doc/EXTENSIONS.md +++ b/doc/EXTENSIONS.md @@ -72,13 +72,16 @@ into `legendary.nvim`. require('legendary').setup({ extensions = { lazy_nvim = true, - } + }, }) ``` ### `Which-Key.nvim` Automatically load key mappings defined by [which-key.nvim](https://github.com/folke/which-key.nvim) into `legendary.nvim`. +For `auto_register` to work, `which-key.nvim` must be loaded on `runtimepath` before `legendary.nvim` initializes, +but `legendary.nvim` must initialize the extension before `require('which-key').register()` is called. Alternatively, +you can just pass your `which-key` tables to `legendary` directly. ```lua require('legendary').setup({ diff --git a/doc/WHICH_KEY.md b/doc/WHICH_KEY.md deleted file mode 100644 index 1a9a31b..0000000 --- a/doc/WHICH_KEY.md +++ /dev/null @@ -1,42 +0,0 @@ -# `which-key.nvim` Integration - -Already a `which-key.nvim` user? Use your existing `which-key.nvim` tables with `legendary.nvim`! - -There's a couple ways you can choose to do it: - -```lua --- automatically register which-key.nvim tables with legendary.nvim --- when you register them with which-key.nvim. --- `setup()` must be called before `require('which-key).register()` -require('legendary').setup({ which_key = { auto_register = true } }) --- now this will register them with both which-key.nvim and legendary.nvim -require('which-key').register(your_which_key_tables, your_which_key_opts) - --- or, pass them through setup() directly -require('which-key').register(your_which_key_tables, your_which_key_opts) -require('legendary').setup({ - which_key = { - mappings = your_which_key_tables, - opts = your_which_key_opts, - -- false if which-key.nvim handles binding them, - -- set to true if you want legendary.nvim to handle binding - -- the mappings; if not passed, true by default - do_binding = false, - }, -}) - --- or, if you'd prefer to manually register with legendary.nvim -require('which-key').register(your_which_key_tables, your_which_key_opts) -require('legendary.util.which-key').bind_whichkey( - your_which_key_tables, - your_which_key_opts, - -- false if which-key.nvim handles binding them, - -- set to true if you want legendary.nvim to handle binding - -- the mappings; if not passed, true by default. - false, - -- true if you want to use item groups, - -- false if you want to add the items to the toplevel list - -- in legendary.nvim; defaults to true if omitted. - true, -) -```