Run prettier on language server
This commit is contained in:
@@ -8,18 +8,15 @@ import {
|
||||
ProposedFeatures,
|
||||
TextDocumentPositionParams,
|
||||
TextDocuments,
|
||||
TextDocumentSyncKind,
|
||||
TextDocumentSyncKind
|
||||
} from "vscode-languageserver/node";
|
||||
|
||||
import { hover, validate } from "@github/actions-languageservice";
|
||||
import { TextDocument } from "vscode-languageserver-textdocument";
|
||||
import {
|
||||
InitializationOptions,
|
||||
RepositoryContext,
|
||||
} from "./initializationOptions";
|
||||
import { onCompletion } from "./on-completion";
|
||||
import { TTLCache } from "./utils/cache";
|
||||
import { valueProviders } from "./value-providers";
|
||||
import {hover, validate} from "@github/actions-languageservice";
|
||||
import {TextDocument} from "vscode-languageserver-textdocument";
|
||||
import {InitializationOptions, RepositoryContext} from "./initializationOptions";
|
||||
import {onCompletion} from "./on-completion";
|
||||
import {TTLCache} from "./utils/cache";
|
||||
import {valueProviders} from "./value-providers";
|
||||
|
||||
// Create a connection for the server, using Node's IPC as a transport.
|
||||
// Also include all preview / proposed LSP features.
|
||||
@@ -39,9 +36,7 @@ let hasDiagnosticRelatedInformationCapability = false;
|
||||
connection.onInitialize((params: InitializeParams) => {
|
||||
const capabilities = params.capabilities;
|
||||
|
||||
hasWorkspaceFolderCapability = !!(
|
||||
capabilities.workspace && !!capabilities.workspace.workspaceFolders
|
||||
);
|
||||
hasWorkspaceFolderCapability = !!(capabilities.workspace && !!capabilities.workspace.workspaceFolders);
|
||||
hasDiagnosticRelatedInformationCapability = !!(
|
||||
capabilities.textDocument &&
|
||||
capabilities.textDocument.publishDiagnostics &&
|
||||
@@ -59,17 +54,17 @@ connection.onInitialize((params: InitializeParams) => {
|
||||
textDocumentSync: TextDocumentSyncKind.Full,
|
||||
completionProvider: {
|
||||
resolveProvider: false,
|
||||
triggerCharacters: [":", "."],
|
||||
triggerCharacters: [":", "."]
|
||||
},
|
||||
hoverProvider: true,
|
||||
},
|
||||
hoverProvider: true
|
||||
}
|
||||
};
|
||||
|
||||
if (hasWorkspaceFolderCapability) {
|
||||
result.capabilities.workspace = {
|
||||
workspaceFolders: {
|
||||
supported: true,
|
||||
},
|
||||
supported: true
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -78,7 +73,7 @@ connection.onInitialize((params: InitializeParams) => {
|
||||
|
||||
connection.onInitialized(() => {
|
||||
if (hasWorkspaceFolderCapability) {
|
||||
connection.workspace.onDidChangeWorkspaceFolders((_event) => {
|
||||
connection.workspace.onDidChangeWorkspaceFolders(_event => {
|
||||
connection.console.log("Workspace folder change event received.");
|
||||
});
|
||||
}
|
||||
@@ -86,7 +81,7 @@ connection.onInitialized(() => {
|
||||
|
||||
// The content of a text document has changed. This event is emitted
|
||||
// when the text document first opened or when its content has changed.
|
||||
documents.onDidChangeContent((change) => {
|
||||
documents.onDidChangeContent(change => {
|
||||
validateTextDocument(change.document);
|
||||
});
|
||||
|
||||
@@ -95,41 +90,34 @@ async function validateTextDocument(textDocument: TextDocument): Promise<void> {
|
||||
textDocument,
|
||||
valueProviders(
|
||||
sessionToken,
|
||||
repos.find((repo) => textDocument.uri.startsWith(repo.workspaceUri)),
|
||||
repos.find(repo => textDocument.uri.startsWith(repo.workspaceUri)),
|
||||
cache
|
||||
)
|
||||
);
|
||||
|
||||
connection.sendDiagnostics({ uri: textDocument.uri, diagnostics: result });
|
||||
connection.sendDiagnostics({uri: textDocument.uri, diagnostics: result});
|
||||
}
|
||||
|
||||
connection.onDidChangeWatchedFiles((_change) => {
|
||||
connection.onDidChangeWatchedFiles(_change => {
|
||||
// Monitored files have change in VSCode
|
||||
connection.console.log("We received an file change event");
|
||||
});
|
||||
|
||||
// This handler provides the initial list of the completion items.
|
||||
connection.onCompletion(
|
||||
async ({
|
||||
connection.onCompletion(async ({position, textDocument}: TextDocumentPositionParams): Promise<CompletionItem[]> => {
|
||||
return await onCompletion(
|
||||
position,
|
||||
textDocument,
|
||||
}: TextDocumentPositionParams): Promise<CompletionItem[]> => {
|
||||
return await onCompletion(
|
||||
position,
|
||||
documents.get(textDocument.uri)!,
|
||||
sessionToken,
|
||||
repos.find((repo) => textDocument.uri.startsWith(repo.workspaceUri)),
|
||||
cache
|
||||
);
|
||||
}
|
||||
);
|
||||
documents.get(textDocument.uri)!,
|
||||
sessionToken,
|
||||
repos.find(repo => textDocument.uri.startsWith(repo.workspaceUri)),
|
||||
cache
|
||||
);
|
||||
});
|
||||
|
||||
connection.onHover(
|
||||
async ({ position, textDocument }: HoverParams): Promise<Hover | null> => {
|
||||
const r = await hover(documents.get(textDocument.uri)!, position);
|
||||
return r;
|
||||
}
|
||||
);
|
||||
connection.onHover(async ({position, textDocument}: HoverParams): Promise<Hover | null> => {
|
||||
const r = await hover(documents.get(textDocument.uri)!, position);
|
||||
return r;
|
||||
});
|
||||
|
||||
// Make the text document manager listen on the connection
|
||||
// for open, change and close text document events
|
||||
|
||||
Reference in New Issue
Block a user