Skip to content

Commit 5ceb346

Browse files
committed
feat: add action source
1 parent 86e0fb1 commit 5ceb346

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type { Detail } from "jsr:@vim-fall/core@^0.2.1/item";
2+
import type { Source } from "jsr:@vim-fall/core@^0.2.1/source";
3+
import type { Action } from "jsr:@vim-fall/core@^0.2.1/action";
4+
5+
/**
6+
* Create a source for actions.
7+
*/
8+
export function action(
9+
actions: Record<string, Action<Detail>>,
10+
): Source<Action<Detail>> {
11+
return {
12+
collect: async function* () {
13+
yield* Object.entries(actions).map(([name, action], id) => ({
14+
id,
15+
value: name,
16+
detail: action,
17+
}));
18+
},
19+
};
20+
}

denops/fall/main/picker.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
loadUserConfig,
1313
} from "../config.ts";
1414
import { isOptions, isParams, isStringArray } from "../util/predicate.ts";
15+
import { action as buildActionSource } from "../extension/source/action.ts";
1516
import { Picker } from "../picker.ts";
1617

1718
let zindex = 50;
@@ -68,15 +69,7 @@ async function startPicker(
6869
const actionPicker = stack.use(
6970
new Picker({
7071
name: "@action",
71-
source: {
72-
collect: async function* () {
73-
yield* Object.entries(params.actions).map(([name, action], id) => ({
74-
id,
75-
value: name,
76-
detail: action,
77-
}));
78-
},
79-
},
72+
source: buildActionSource(params.actions),
8073
...getActionPickerParams(),
8174
zindex,
8275
}),

0 commit comments

Comments
 (0)