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.
67 lines
1.7 KiB
67 lines
1.7 KiB
3 years ago
|
import {
|
||
|
BaseSource,
|
||
|
Candidate,
|
||
3 years ago
|
} from "https://deno.land/x/ddc_vim@v0.13.0/types.ts#^";
|
||
3 years ago
|
|
||
|
import {
|
||
3 years ago
|
batch,
|
||
3 years ago
|
Denops,
|
||
3 years ago
|
vars,
|
||
3 years ago
|
} from "https://deno.land/x/ddc_vim@v0.13.0/deps.ts#^";
|
||
|
|
||
3 years ago
|
type Params = {};
|
||
3 years ago
|
|
||
|
export class Source extends BaseSource {
|
||
3 years ago
|
async onInit(args: {
|
||
3 years ago
|
denops: Denops;
|
||
3 years ago
|
}): Promise<void> {
|
||
|
await batch(args.denops, async (denops) => {
|
||
3 years ago
|
await vars.g.set(denops, "ddc#source#ddc_vim_lsp#_results", []);
|
||
|
await vars.g.set(denops, "ddc#source#ddc_vim_lsp#_requested", false);
|
||
|
await vars.g.set(denops, "ddc#source#ddc_vim_lsp#_prev_input", "");
|
||
3 years ago
|
});
|
||
|
}
|
||
|
|
||
3 years ago
|
async gatherCandidates(args: {
|
||
3 years ago
|
denops: Denops;
|
||
|
context: Context;
|
||
|
completeStr: string;
|
||
3 years ago
|
}): Promise<Candidate[]> {
|
||
3 years ago
|
const prevInput = await vars.g.get(
|
||
|
args.denops,
|
||
|
"ddc#source#ddc_vim_lsp#_prev_input",
|
||
|
);
|
||
|
const requested = await vars.g.get(
|
||
|
args.denops,
|
||
|
"ddc#source#ddc_vim_lsp#_requested",
|
||
|
);
|
||
3 years ago
|
if (args.context.input == prevInput && requested) {
|
||
|
return await vars.g.get(args.denops, "ddc#source#ddc_vim_lsp#_results");
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
const lspservers = await args.denops.call("lsp#get_allowed_servers");
|
||
3 years ago
|
if (lspservers.length === 0) {
|
||
|
return [];
|
||
|
}
|
||
|
|
||
3 years ago
|
await batch(args.denops, async (denops) => {
|
||
3 years ago
|
await vars.g.set(denops, "ddc#source#ddc_vim_lsp#_results", []);
|
||
|
await vars.g.set(denops, "ddc#source#ddc_vim_lsp#_requested", false);
|
||
3 years ago
|
await vars.g.set(
|
||
|
denops,
|
||
|
"ddc#source#ddc_vim_lsp#_prev_input",
|
||
|
args.context.input,
|
||
|
);
|
||
3 years ago
|
|
||
3 years ago
|
// NOTE: choose first lsp server
|
||
3 years ago
|
await denops.call("ddc_vim_lsp#request", lspservers[0]);
|
||
3 years ago
|
});
|
||
3 years ago
|
|
||
|
return [];
|
||
3 years ago
|
}
|
||
3 years ago
|
|
||
|
params(): Params {
|
||
|
return {};
|
||
|
}
|
||
3 years ago
|
}
|