aboutsummaryrefslogtreecommitdiff
path: root/editors/code
diff options
context:
space:
mode:
authorShuiRuTian <[email protected]>2021-01-11 06:45:35 +0000
committerShuiRuTian <[email protected]>2021-01-11 06:45:35 +0000
commitf7cb9e9fbe50e5d0e23e81b8b5b90405ef5c1931 (patch)
tree147a80040e3513a0be3f6fb4c59a6d0dd1a0ecee /editors/code
parentb9d52444cf621e474e0117e70c335dde2cbf3515 (diff)
move logic from client to server.
Diffstat (limited to 'editors/code')
-rw-r--r--editors/code/src/client.ts20
1 files changed, 0 insertions, 20 deletions
diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts
index 772892b07..539e487ec 100644
--- a/editors/code/src/client.ts
+++ b/editors/code/src/client.ts
@@ -51,32 +51,12 @@ export function createClient(serverPath: string, cwd: string, extraEnv: Env): lc
51 'Rust Analyzer Language Server Trace', 51 'Rust Analyzer Language Server Trace',
52 ); 52 );
53 53
54 const workspace: lc.WorkspaceMiddleware = {
55 willRenameFiles: function <P extends vscode.FileRenameEvent, R extends Thenable<vscode.WorkspaceEdit | null | undefined>>(this: void, data: P, next: (data: P) => R) {
56 // why add this function rather than default:
57 // 1. change `url` parameter to happy format for url crate. (folder should end with '/')
58 // 2. filter some change in here.
59 // 2.1 rename from or to `mod.rs` should be special.
60 // 2.2 not all folder change should be cared, only those have files with ".rs" postfix.
61 const newFiles = data.files.map((file) => {
62 const isFolder = !file.oldUri.path.endsWith(".rs");
63 return !isFolder ? file : {
64 oldUri: vscode.Uri.file(file.oldUri.path + '/'),
65 newUri: vscode.Uri.file(file.newUri.path + '/')
66 };
67 });
68 data = { ...data, files: newFiles };
69 return next(data);
70 }
71 };
72
73 const clientOptions: lc.LanguageClientOptions = { 54 const clientOptions: lc.LanguageClientOptions = {
74 documentSelector: [{ scheme: 'file', language: 'rust' }], 55 documentSelector: [{ scheme: 'file', language: 'rust' }],
75 initializationOptions: vscode.workspace.getConfiguration("rust-analyzer"), 56 initializationOptions: vscode.workspace.getConfiguration("rust-analyzer"),
76 diagnosticCollectionName: "rustc", 57 diagnosticCollectionName: "rustc",
77 traceOutputChannel, 58 traceOutputChannel,
78 middleware: { 59 middleware: {
79 workspace,
80 provideDocumentSemanticTokens(document: vscode.TextDocument, token: vscode.CancellationToken, next: DocumentSemanticsTokensSignature): vscode.ProviderResult<vscode.SemanticTokens> { 60 provideDocumentSemanticTokens(document: vscode.TextDocument, token: vscode.CancellationToken, next: DocumentSemanticsTokensSignature): vscode.ProviderResult<vscode.SemanticTokens> {
81 return semanticHighlightingWorkaround(next, document, token); 61 return semanticHighlightingWorkaround(next, document, token);
82 }, 62 },