Skip to content

Commit

Permalink
Add names param
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Jun 2, 2024
1 parent eab4cb3 commit 8da7119
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 13 additions & 3 deletions denops/@ddu-sources/dpp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { Denops, vars } from "https://deno.land/x/ddu_vim@v4.1.0/deps.ts";
import { ActionData } from "https://deno.land/x/ddu_kind_file@v0.7.1/file.ts";
import { Plugin } from "../dpp/types.ts";

type Params = Record<string, never>;
type Params = {
names: string[];
};

type Action = {
path: string;
Expand All @@ -24,13 +26,19 @@ export class Source extends BaseSource<Params> {
}): ReadableStream<Item<ActionData>[]> {
return new ReadableStream({
async start(controller) {
const plugins = Object.values(
let plugins = Object.values(
await vars.g.get(
args.denops,
"dpp#_plugins",
),
) as Plugin[];

if (args.sourceParams.names.length > 0) {
plugins = plugins.filter((plugin) =>
args.sourceParams.names.indexOf(plugin.name) >= 0
);
}

const items = plugins.map((plugin) => {
return {
word: plugin.name,
Expand All @@ -54,6 +62,8 @@ export class Source extends BaseSource<Params> {
> = {};

override params(): Params {
return {};
return {
names: [],
};
}
}
3 changes: 3 additions & 0 deletions doc/dpp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,9 @@ DDU SOURCES *dpp-ddu-sources*
dpp
Nominates dpp plugins as items.

params:
{names}: Plugin names.
(Default: [])

==============================================================================
EXAMPLES *dpp-examples*
Expand Down

0 comments on commit 8da7119

Please sign in to comment.