@@ -3,6 +3,7 @@ import * as child_process from 'child_process';
33import * as net from 'net' ;
44import * as portfinder from 'portfinder' ;
55import * as util from 'util' ;
6+
67import {
78 workspace , Disposable , ExtensionContext , languages ,
89 window , commands , InputBoxOptions
@@ -12,20 +13,29 @@ import {
1213 TransportKind , TextDocumentIdentifier , TextDocumentPositionParams ,
1314 StreamInfo
1415} from 'vscode-languageclient' ;
16+ import { homedir } from 'os' ;
1517
1618let languageClient : LanguageClient ;
1719
1820let repl : vscode . Terminal | null = null ;
1921
2022let lspPort : number | null = null ;
2123
24+ function expandHomeDir ( path : string ) : string {
25+ if ( path . startsWith ( '~/' ) ) {
26+ return homedir ( ) + path . slice ( 1 ) ;
27+ }
28+ return path ;
29+ }
30+
2231async function startLSP ( ) {
2332 lspPort = await portfinder . getPortPromise ( {
2433 port : 10003
2534 } ) ;
35+ let lsppath = expandHomeDir ( workspace . getConfiguration ( ) . get < string > ( 'commonlisp.lsppath' ) ! ) ;
2636 return vscode . window . createTerminal ( {
2737 name : "Common Lisp REPL" ,
28- shellPath : "cl-lsp" ,
38+ shellPath : lsppath ,
2939 shellArgs : [ "tcp" , lspPort . toString ( ) ] ,
3040 hideFromUser : true ,
3141 } ) ;
@@ -122,7 +132,6 @@ function backoff<T>(retries: number, fn: () => Promise<T>, delay = 500): Promise
122132export async function activate ( context : ExtensionContext ) {
123133 let serverOptions : ServerOptions ;
124134 serverOptions = async ( ) => {
125- let lsppath = workspace . getConfiguration ( ) . get < string > ( 'commonlisp.lsppath' ) ! ;
126135 let client = new net . Socket ( ) ;
127136 repl = await startLSP ( ) ;
128137 return await backoff ( 5 , ( ) => {
0 commit comments