You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
957 B

import {
BaseSource,
Candidate,
} from "https://deno.land/x/ddc_vim@v0.13.0/types.ts#^";
import {
GatherCandidatesArguments,
} from "https://deno.land/x/ddc_vim@v0.13.0/base/source.ts#^";
// deno-lint-ignore ban-types
type Params = {};
export class Source extends BaseSource<Params> {
3 years ago
private counter = 0;
async gatherCandidates(
args: GatherCandidatesArguments<Params>,
): Promise<Candidate[]> {
3 years ago
this.counter = (this.counter + 1) % 100;
3 years ago
const lspservers: string[] = await args.denops.call(
"lsp#get_allowed_servers",
// deno-lint-ignore no-explicit-any
) as any;
if (lspservers.length === 0) {
return [];
}
3 years ago
const id = `source/${this.name}/${this.counter}`;
void args.denops.call("ddc_vim_lsp#request", lspservers[0], id);
3 years ago
// TODO: remove as any
const items: Candidate[] = await (args as any).onCallback(id) as any;
3 years ago
return items;
}
params(): Params {
return {};
}
}