beta version for folder rename

This commit is contained in:
ShuiRuTian 2021-01-10 01:29:08 +08:00
parent c08391ce32
commit 0d86e22229
3 changed files with 34 additions and 4 deletions

View file

@ -51,12 +51,24 @@ export function createClient(serverPath: string, cwd: string, extraEnv: Env): lc
'Rust Analyzer Language Server Trace',
);
const workspace:lc.WorkspaceMiddleware = {
willRenameFiles:function<P extends vscode.FileRenameEvent,R extends Thenable<vscode.WorkspaceEdit | null | undefined>>(this: void, data: P, next:(data: P) => R ){
// why add this function rather than default:
// 1. change `url` parameter to happy format for url crate. (folder should end with '/')
// 2. filter some change in here.
// 2.1 rename from or to `mod.rs` should be special.
// 2.2 not all folder change should be cared, only those have files with ".rs" postfix.
return next(data);
}
}
const clientOptions: lc.LanguageClientOptions = {
documentSelector: [{ scheme: 'file', language: 'rust' }],
initializationOptions: vscode.workspace.getConfiguration("rust-analyzer"),
diagnosticCollectionName: "rustc",
traceOutputChannel,
middleware: {
workspace,
provideDocumentSemanticTokens(document: vscode.TextDocument, token: vscode.CancellationToken, next: DocumentSemanticsTokensSignature): vscode.ProviderResult<vscode.SemanticTokens> {
return semanticHighlightingWorkaround(next, document, token);
},