Skip to content

Commit

Permalink
Add: allow multiple key bindings to be set
Browse files Browse the repository at this point in the history
  • Loading branch information
tennashi committed Jul 3, 2021
1 parent 19b264f commit 36dde49
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,22 @@ export class ListWidget<T> implements Buffer {
this.#items.map((item) => item.renderFn(item.item)),
);

Object.keys(this.#keybinds).forEach(async (key) => {
denops.dispatcher[`keyHandler`] = async (
index: unknown,
): Promise<void> => {
await this.#keybinds[key](
denops,
this.#items[(index as number)].item,
);
};
denops.dispatcher[`keyHandler`] = async (
key: unknown,
index: unknown,
): Promise<void> => {
await this.#keybinds[key as string](
denops,
this.#items[index as number].item,
);
};

Object.keys(this.#keybinds).forEach(async (key) => {
await execute(
denops,
[
`nmap <buffer> <expr> ${key} denops#notify('${denops.name}', 'keyHandler', [line('.') - 1])`,
],
`nmap <buffer><expr> ${key} denops#notify('${denops.name}', 'keyHandler', ['${
key.replaceAll("<", "<lt>")
}', string(line('.') - 1)])`,
);
});

Expand Down

0 comments on commit 36dde49

Please sign in to comment.