@@ -68,28 +68,10 @@ async function isEsyProject() {
68
68
return false ;
69
69
}
70
70
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
-
88
71
export async function launch ( context : vscode . ExtensionContext ) : Promise < void > {
89
72
const isEasyProject = await isEsyProject ( ) ;
90
- const isBucklescriptProject = await isBSProject ( ) ;
73
+
91
74
return launchMerlinLsp ( context , {
92
- isBucklescriptProject,
93
75
useEsy : isEasyProject ,
94
76
} ) ;
95
77
}
@@ -98,33 +80,19 @@ function getPrebuiltExecutablesPath() {
98
80
return path . join ( __dirname , `../../../executables/${ process . platform } ` ) ;
99
81
}
100
82
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" ;
107
85
108
- if ( isBucklescriptProject ) {
109
- merlinLspPath = path . join ( getPrebuiltExecutablesPath ( ) , merlinLspPath ) ;
110
- }
86
+ if ( ! useEsy ) {
87
+ merlinLspPath = path . join ( getPrebuiltExecutablesPath ( ) , merlinLspPath ) ;
111
88
}
112
89
113
90
return merlinLspPath ;
114
91
}
115
92
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 } ` ;
128
96
129
97
let run ;
130
98
if ( options . useEsy ) {
@@ -148,7 +116,7 @@ function getMerlinLspOptions(options: { useEsy: boolean; isBucklescriptProject:
148
116
MERLIN_LOG : "-" ,
149
117
OCAMLFIND_CONF : "/dev/null" ,
150
118
OCAMLRUNPARAM : "b" ,
151
- PATH : merlinReasonDir ,
119
+ PATH : pth ,
152
120
} ,
153
121
} ,
154
122
} ,
@@ -160,18 +128,15 @@ function getMerlinLspOptions(options: { useEsy: boolean; isBucklescriptProject:
160
128
MERLIN_LOG : "-" ,
161
129
OCAMLFIND_CONF : "/dev/null" ,
162
130
OCAMLRUNPARAM : "b" ,
163
- PATH : merlinReasonDir ,
131
+ PATH : pth ,
164
132
} ,
165
133
} ,
166
134
} ,
167
135
} ;
168
136
return serverOptions ;
169
137
}
170
138
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 > {
175
140
const serverOptions = getMerlinLspOptions ( options ) ;
176
141
const reasonConfig = vscode . workspace . getConfiguration ( "reason" ) ;
177
142
0 commit comments