|
@ -4,7 +4,9 @@ import { |
|
|
} from "https://deno.land/x/ddc_vim@v0.4.2/types.ts#^"; |
|
|
} from "https://deno.land/x/ddc_vim@v0.4.2/types.ts#^"; |
|
|
|
|
|
|
|
|
import { |
|
|
import { |
|
|
|
|
|
batch, |
|
|
Denops, |
|
|
Denops, |
|
|
|
|
|
vars, |
|
|
} from "https://deno.land/x/ddc_vim@v0.4.2/deps.ts#^"; |
|
|
} from "https://deno.land/x/ddc_vim@v0.4.2/deps.ts#^"; |
|
|
|
|
|
|
|
|
import { |
|
|
import { |
|
@ -12,25 +14,41 @@ import { |
|
|
} from "https://deno.land/x/denops_std@v1.8.1/anonymous/mod.ts"; |
|
|
} from "https://deno.land/x/denops_std@v1.8.1/anonymous/mod.ts"; |
|
|
|
|
|
|
|
|
export class Source extends BaseSource { |
|
|
export class Source extends BaseSource { |
|
|
|
|
|
async onInit(args: { |
|
|
|
|
|
denops: Denops, |
|
|
|
|
|
}): Promise<void> { |
|
|
|
|
|
await batch(args.denops, async (denops) => { |
|
|
|
|
|
vars.g.set(denops, "ddc#source#ddc_vim_lsp#_results", []); |
|
|
|
|
|
vars.g.set(denops, "ddc#source#ddc_vim_lsp#_requested", false); |
|
|
|
|
|
vars.g.set(denops, "ddc#source#ddc_vim_lsp#_prev_input", ""); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
async gatherCandidates(args: { |
|
|
async gatherCandidates(args: { |
|
|
denops: Denops, |
|
|
denops: Denops, |
|
|
context: Context, |
|
|
context: Context, |
|
|
completeStr: string, |
|
|
completeStr: string, |
|
|
}): Promise<Candidate[]> { |
|
|
}): Promise<Candidate[]> { |
|
|
|
|
|
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"); |
|
|
|
|
|
if (args.context.input == prevInput && requested) { |
|
|
|
|
|
return await vars.g.get(args.denops, "ddc#source#ddc_vim_lsp#_results"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
const lspservers = await args.denops.call("lsp#get_allowed_servers"); |
|
|
const lspservers = await args.denops.call("lsp#get_allowed_servers"); |
|
|
if (lspservers.length === 0) { |
|
|
if (lspservers.length === 0) { |
|
|
return []; |
|
|
return []; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return new Promise((resolve) => { |
|
|
await batch(args.denops, async (denops) => { |
|
|
|
|
|
vars.g.set(denops, "ddc#source#ddc_vim_lsp#_results", []); |
|
|
|
|
|
vars.g.set(denops, "ddc#source#ddc_vim_lsp#_requested", false); |
|
|
|
|
|
vars.g.set(denops, "ddc#source#ddc_vim_lsp#_prev_input", args.context.input); |
|
|
|
|
|
|
|
|
// NOTE: choose first lsp server
|
|
|
// NOTE: choose first lsp server
|
|
|
args.denops.call("ddc_vim_lsp#request", lspservers[0], args.denops.name, once(args.denops, (response) => { |
|
|
denops.call("ddc_vim_lsp#request", lspservers[0]); |
|
|
resolve(response); |
|
|
|
|
|
})[0]) |
|
|
|
|
|
}) |
|
|
|
|
|
.then((cs: Candidate[]) => { |
|
|
|
|
|
return cs; |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return []; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|