|
1 | 1 | import {
|
2 | 2 | createConnection,
|
3 | 3 | createServer,
|
4 |
| - createTypeScriptProject, |
| 4 | + createSimpleProject, |
5 | 5 | loadTsdkByPath,
|
6 |
| -} from "@volar/language-server/node"; |
7 |
| -import { create as createCssService } from "volar-service-css"; |
8 |
| -import { create as createEmmetService } from "volar-service-emmet"; |
9 |
| -import { create as createTypeScriptServices } from "volar-service-typescript"; |
10 |
| -import { getLanguagePlugin } from "./language-plugin"; |
| 6 | +} from '@volar/language-server/node' |
| 7 | +import { getLanguagePlugin } from 'ts-macro' |
| 8 | +import { create as createCssService } from 'volar-service-css' |
| 9 | +import { create as createEmmetService } from 'volar-service-emmet' |
| 10 | +import { create as createTypeScriptServices } from 'volar-service-typescript' |
| 11 | +export { getLanguagePlugin } |
11 | 12 |
|
12 |
| -const connection = createConnection(); |
13 |
| -const server = createServer(connection); |
| 13 | +const connection = createConnection() |
| 14 | +const server = createServer(connection) |
14 | 15 |
|
15 |
| -connection.listen(); |
| 16 | +connection.listen() |
16 | 17 |
|
17 |
| -connection.onInitialize((params) => { |
| 18 | +connection.onInitialize(async (params) => { |
18 | 19 | const tsdk = loadTsdkByPath(
|
19 | 20 | params.initializationOptions.typescript.tsdk,
|
20 | 21 | params.locale,
|
21 |
| - ); |
22 |
| - const project = createTypeScriptProject( |
23 |
| - tsdk.typescript, |
24 |
| - tsdk.diagnosticMessages, |
25 |
| - () => ({ |
26 |
| - languagePlugins: [getLanguagePlugin(tsdk.typescript)], |
27 |
| - }), |
28 |
| - ); |
29 |
| - |
30 |
| - return server.initialize(params, project, [ |
31 |
| - createCssService(), |
32 |
| - createEmmetService(), |
33 |
| - ...createTypeScriptServices(tsdk.typescript).filter( |
34 |
| - (plugin) => plugin.name === "typescript-syntactic", |
35 |
| - ), |
36 |
| - ]); |
37 |
| -}); |
38 |
| - |
39 |
| -connection.onInitialized(server.initialized); |
40 |
| - |
41 |
| -connection.onShutdown(server.shutdown); |
| 22 | + ) |
| 23 | + |
| 24 | + const result = await server.initialize( |
| 25 | + params, |
| 26 | + createSimpleProject([ |
| 27 | + getLanguagePlugin(tsdk.typescript, params.workspaceFolders![0].uri), |
| 28 | + ]), |
| 29 | + [ |
| 30 | + createCssService(), |
| 31 | + createEmmetService(), |
| 32 | + ...createTypeScriptServices(tsdk.typescript).filter( |
| 33 | + (plugin) => plugin.name === 'typescript-syntactic', |
| 34 | + ), |
| 35 | + ], |
| 36 | + ) |
| 37 | + |
| 38 | + result.capabilities.semanticTokensProvider = undefined |
| 39 | + |
| 40 | + return result |
| 41 | +}) |
| 42 | + |
| 43 | +connection.onInitialized(server.initialized) |
| 44 | + |
| 45 | +connection.onShutdown(server.shutdown) |
0 commit comments