@@ -68,28 +68,10 @@ async function isEsyProject() {
6868 return false ;
6969}
7070
71- async function isBSProject ( ) {
72- // TODO: we need to use workspace.workspaceFolders here and run LSP server per
73- // root. For now we'll just run LSP per workspace.
74- const root = vscode . workspace . rootPath ;
75- if ( root == null ) {
76- return false ;
77- }
78-
79- const bsconfigJson = path . join ( root , "bsconfig.json" ) ;
80-
81- if ( await exists ( bsconfigJson ) ) {
82- return true ;
83- }
84-
85- return false ;
86- }
87-
8871export async function launch ( context : vscode . ExtensionContext ) : Promise < void > {
8972 const isEasyProject = await isEsyProject ( ) ;
90- const isBucklescriptProject = await isBSProject ( ) ;
73+
9174 return launchMerlinLsp ( context , {
92- isBucklescriptProject,
9375 useEsy : isEasyProject ,
9476 } ) ;
9577}
@@ -98,33 +80,19 @@ function getPrebuiltExecutablesPath() {
9880 return path . join ( __dirname , `../../../executables/${ process . platform } ` ) ;
9981}
10082
101- function getMerlinLspPath ( isBucklescriptProject : boolean ) {
102- const reasonConfig = vscode . workspace . getConfiguration ( "reason" ) ;
103- let merlinLspPath = reasonConfig . get < string | null > ( "path.ocamlmerlin-lsp" , null ) ;
104-
105- if ( merlinLspPath == null ) {
106- merlinLspPath = isWin ? "ocamlmerlin-lsp.exe" : "ocamlmerlin-lsp" ;
83+ function getMerlinLspPath ( useEsy : boolean ) {
84+ let merlinLspPath = isWin ? "ocamlmerlin-lsp.exe" : "ocamlmerlin-lsp" ;
10785
108- if ( isBucklescriptProject ) {
109- merlinLspPath = path . join ( getPrebuiltExecutablesPath ( ) , merlinLspPath ) ;
110- }
86+ if ( ! useEsy ) {
87+ merlinLspPath = path . join ( getPrebuiltExecutablesPath ( ) , merlinLspPath ) ;
11188 }
11289
11390 return merlinLspPath ;
11491}
11592
116- function getMerlinReasonDir ( ) {
117- const reasonConfig = vscode . workspace . getConfiguration ( "reason" ) ;
118- const merlinReasonPath = reasonConfig . get < string | null > ( "path.ocamlmerlin-reason" , null ) ;
119-
120- if ( merlinReasonPath == null ) return getPrebuiltExecutablesPath ( ) ;
121-
122- return path . dirname ( merlinReasonPath ) ;
123- }
124-
125- function getMerlinLspOptions ( options : { useEsy : boolean ; isBucklescriptProject : boolean } ) {
126- const merlinLsp = getMerlinLspPath ( options . isBucklescriptProject ) ;
127- const merlinReasonDir = getMerlinReasonDir ( ) ;
93+ function getMerlinLspOptions ( options : { useEsy : boolean } ) {
94+ const merlinLsp = getMerlinLspPath ( options . useEsy ) ;
95+ const pth = options . useEsy ? process . env . PATH : `${ getPrebuiltExecutablesPath ( ) } :${ process . env . PATH } ` ;
12896
12997 let run ;
13098 if ( options . useEsy ) {
@@ -148,7 +116,7 @@ function getMerlinLspOptions(options: { useEsy: boolean; isBucklescriptProject:
148116 MERLIN_LOG : "-" ,
149117 OCAMLFIND_CONF : "/dev/null" ,
150118 OCAMLRUNPARAM : "b" ,
151- PATH : merlinReasonDir ,
119+ PATH : pth ,
152120 } ,
153121 } ,
154122 } ,
@@ -160,18 +128,15 @@ function getMerlinLspOptions(options: { useEsy: boolean; isBucklescriptProject:
160128 MERLIN_LOG : "-" ,
161129 OCAMLFIND_CONF : "/dev/null" ,
162130 OCAMLRUNPARAM : "b" ,
163- PATH : merlinReasonDir ,
131+ PATH : pth ,
164132 } ,
165133 } ,
166134 } ,
167135 } ;
168136 return serverOptions ;
169137}
170138
171- export async function launchMerlinLsp (
172- context : vscode . ExtensionContext ,
173- options : { useEsy : boolean ; isBucklescriptProject : boolean } ,
174- ) : Promise < void > {
139+ export async function launchMerlinLsp ( context : vscode . ExtensionContext , options : { useEsy : boolean } ) : Promise < void > {
175140 const serverOptions = getMerlinLspOptions ( options ) ;
176141 const reasonConfig = vscode . workspace . getConfiguration ( "reason" ) ;
177142
0 commit comments