File tree Expand file tree Collapse file tree 3 files changed +13
-14
lines changed Expand file tree Collapse file tree 3 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -2,18 +2,14 @@ import * as lc from 'vscode-languageclient';
22import * as vscode from 'vscode' ;
33
44import { Config } from './config' ;
5- import { ensureServerBinary } from './installation/server' ;
65import { CallHierarchyFeature } from 'vscode-languageclient/lib/callHierarchy.proposed' ;
76
8- export async function createClient ( config : Config ) : Promise < null | lc . LanguageClient > {
7+ export async function createClient ( config : Config , serverPath : string ) : Promise < lc . LanguageClient > {
98 // '.' Is the fallback if no folder is open
109 // TODO?: Workspace folders support Uri's (eg: file://test.txt).
1110 // It might be a good idea to test if the uri points to a file.
1211 const workspaceFolderPath = vscode . workspace . workspaceFolders ?. [ 0 ] ?. uri . fsPath ?? '.' ;
1312
14- const serverPath = await ensureServerBinary ( config . serverSource ) ;
15- if ( ! serverPath ) return null ;
16-
1713 const run : lc . Executable = {
1814 command : serverPath ,
1915 options : { cwd : workspaceFolderPath } ,
Original file line number Diff line number Diff line change @@ -23,16 +23,10 @@ export class Ctx {
2323 this . extCtx = extCtx ;
2424 }
2525
26- async startServer ( ) {
26+ async startServer ( serverPath : string ) {
2727 assert ( this . client == null ) ;
2828
29- const client = await createClient ( this . config ) ;
30- if ( ! client ) {
31- throw new Error (
32- "Rust Analyzer Language Server is not available. " +
33- "Please, ensure its [proper installation](https://github.com/rust-analyzer/rust-analyzer/tree/master/docs/user#vs-code)."
34- ) ;
35- }
29+ const client = await createClient ( this . config , serverPath ) ;
3630
3731 this . pushCleanup ( client . start ( ) ) ;
3832 await client . onReady ( ) ;
Original file line number Diff line number Diff line change @@ -5,18 +5,27 @@ import { activateInlayHints } from './inlay_hints';
55import { activateStatusDisplay } from './status_display' ;
66import { Ctx } from './ctx' ;
77import { activateHighlighting } from './highlighting' ;
8+ import { ensureServerBinary } from './installation/server' ;
89
910let ctx : Ctx | undefined ;
1011
1112export async function activate ( context : vscode . ExtensionContext ) {
1213 ctx = new Ctx ( context ) ;
1314
15+ const serverPath = await ensureServerBinary ( ctx . config . serverSource ) ;
16+ if ( serverPath == null ) {
17+ throw new Error (
18+ "Rust Analyzer Language Server is not available. " +
19+ "Please, ensure its [proper installation](https://github.com/rust-analyzer/rust-analyzer/tree/master/docs/user#vs-code)."
20+ ) ;
21+ }
22+
1423 // Note: we try to start the server before we activate type hints so that it
1524 // registers its `onDidChangeDocument` handler before us.
1625 //
1726 // This a horribly, horribly wrong way to deal with this problem.
1827 try {
19- await ctx . startServer ( ) ;
28+ await ctx . startServer ( serverPath ) ;
2029 } catch ( e ) {
2130 vscode . window . showErrorMessage ( e . message ) ;
2231 }
You can’t perform that action at this time.
0 commit comments