| 171 | } |
| 172 | |
| 173 | function createTs7Client(tsGoPath: string): LanguageClient { |
| 174 | const isNative = |
| 175 | tsGoPath.includes(`typescript-${process.platform}-${process.arch}`) || |
| 176 | tsGoPath.includes(`native-preview-${process.platform}-${process.arch}`) || |
| 177 | tsGoPath.endsWith('/lib/tsc') || |
| 178 | tsGoPath.endsWith('/tsc.exe') || |
| 179 | tsGoPath.endsWith('/tsgo.exe') || |
| 180 | tsGoPath.endsWith('/built/local/tsc') || |
| 181 | tsGoPath.endsWith('/built/local/tsgo'); |
| 182 | const ts7ServerOptions: ServerOptions = isNative |
| 183 | ? { |
| 184 | command: tsGoPath, |
| 185 | args: ['--lsp', '--stdio'], |
| 186 | } |
| 187 | : { |
| 188 | command: process.execPath, |
| 189 | args: [tsGoPath, '--lsp', '--stdio'], |
| 190 | options: { |
| 191 | env: { |
| 192 | ...process.env, |
| 193 | ELECTRON_RUN_AS_NODE: '1', |
| 194 | }, |
| 195 | }, |
| 196 | }; |
| 197 | |
| 198 | const ts7OutputChannel = vscode.window.createOutputChannel('Angular TS 7 Server', {log: true}); |
| 199 | const ts7ClientOptions: LanguageClientOptions = { |
| 200 | outputChannel: ts7OutputChannel, |
| 201 | documentSelector: [{scheme: 'file', language: 'typescript'}], |
| 202 | middleware: new Proxy( |
| 203 | {}, |
| 204 | { |
| 205 | get(target, prop) { |
| 206 | if ( |
| 207 | typeof prop === 'string' && |
| 208 | (prop.startsWith('provide') || prop.startsWith('resolve')) |
| 209 | ) { |
| 210 | // Return a function that returns undefined to suppress the provider |
| 211 | return () => undefined; |
| 212 | } |
| 213 | // use default behavior |
| 214 | return undefined; |
| 215 | }, |
| 216 | }, |
| 217 | ), |
| 218 | synchronize: { |
| 219 | fileEvents: vscode.workspace.createFileSystemWatcher('**/*.ts'), |
| 220 | }, |
| 221 | }; |
| 222 | |
| 223 | return new LanguageClient( |
| 224 | 'ng-ts-server', |
| 225 | 'Angular TS 7 Server', |
| 226 | ts7ServerOptions, |
| 227 | ts7ClientOptions, |
| 228 | ); |
| 229 | } |
| 230 | |