Add a FileProvider to auto-completion
This commit is contained in:
@@ -119,6 +119,7 @@ export function initConnection(connection: Connection) {
|
||||
|
||||
connection.onCompletion(async ({position, textDocument}: TextDocumentPositionParams): Promise<CompletionItem[]> => {
|
||||
return await onCompletion(
|
||||
connection,
|
||||
position,
|
||||
documents.get(textDocument.uri)!,
|
||||
client,
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
import {complete} from "@github/actions-languageservice/complete";
|
||||
import {Octokit} from "@octokit/rest";
|
||||
import {CompletionItem, Position} from "vscode-languageserver";
|
||||
import {CompletionItem, Connection, Position} from "vscode-languageserver";
|
||||
import {TextDocument} from "vscode-languageserver-textdocument";
|
||||
import {contextProviders} from "./context-providers";
|
||||
import {getFileProvider} from "./file-provider";
|
||||
import {RepositoryContext} from "./initializationOptions";
|
||||
import {TTLCache} from "./utils/cache";
|
||||
import {valueProviders} from "./value-providers";
|
||||
|
||||
export async function onCompletion(
|
||||
connection: Connection,
|
||||
position: Position,
|
||||
document: TextDocument,
|
||||
client: Octokit | undefined,
|
||||
repoContext: RepositoryContext | undefined,
|
||||
cache: TTLCache
|
||||
): Promise<CompletionItem[]> {
|
||||
return await complete(
|
||||
document,
|
||||
position,
|
||||
repoContext && valueProviders(client, repoContext, cache),
|
||||
repoContext && contextProviders(client, repoContext, cache)
|
||||
);
|
||||
return await complete(document, position, {
|
||||
valueProviderConfig: repoContext && valueProviders(client, repoContext, cache),
|
||||
contextProviderConfig: repoContext && contextProviders(client, repoContext, cache),
|
||||
fileProvider: getFileProvider(client, cache, repoContext?.workspaceUri, async path => {
|
||||
return await connection.sendRequest("actions/readFile", {path});
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user