$ show liuchengxu/vim-which-key
vim-which-key is a Vim/Neovim plugin that provides an interactive keybinding guide. When a leader key is pressed, it intercepts subsequent keystrokes and displays available mappings in a popup or split window. The plugin dynamically parses native Vim mappings for the given prefix and merges them with user-defined description dictionaries to show meaningful labels and group names. It supports both Vim's popup API and Neovim's floating windows, offering a modern, non-intrusive UI. The architecture is modular: mapping parsing, layout rendering, window management, and key input handling are separated into distinct autoload modules. The code demonstrates solid Vimscript engineering, with careful handling of edge cases like timeout, exit codes, special keys, and fallback to native mappings.
The LLM identified 1 files worth highlighting for reuse:
This module calculates the optimal layout for displaying keybinding items: it computes the number of rows and columns based on terminal width, item count, and configuration options like centering and alignment. It supports both horizontal and vertical sort orders, and can group dictionary entries together. The layout logic is self-contained, taking a dictionary of mappings and returning formatted rows of strings. It could be reused by any Vim plugin that needs to display a grid of key-value pairs in a popup or buffer, with minimal adaptation.