Skip to content

Commit

Permalink
fix: standalone support
Browse files Browse the repository at this point in the history
close #828
  • Loading branch information
fannheyward committed Aug 2, 2021
1 parent af3680f commit 602c4d7
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { CodeActionKind, Command, Executable, LanguageClient, LanguageClientOptions, ServerOptions, StaticFeature, Uri, workspace } from 'coc.nvim';
import { existsSync } from 'fs';
import { join } from 'path';
import { CodeAction, CodeActionParams, CodeActionRequest } from 'vscode-languageserver-protocol';
import { Env } from './config';
import { isRustDocument } from './ctx';
Expand Down Expand Up @@ -49,7 +51,8 @@ export function createClient(bin: string, extra: Env): LanguageClient {
};

let initializationOptions = workspace.getConfiguration('rust-analyzer');
if (workspace.workspaceFolders.length === 0) {
const standalone = workspace.workspaceFolder ? !existsSync(join(Uri.parse(workspace.workspaceFolder.uri).fsPath, 'Cargo.toml')) : true;
if (standalone) {
const docs = workspace.documents.filter((doc) => isRustDocument(doc.textDocument));
if (docs.length) {
initializationOptions = { detachedFiles: docs.map((doc) => Uri.parse(doc.uri).fsPath), ...initializationOptions };
Expand Down

0 comments on commit 602c4d7

Please sign in to comment.