Skip to content

Commit 1b45356

Browse files
committed
Make it easier to build latest/custom yaml-language-server.
Since vscode-yaml depends on yaml-language-server directly, the latest version will always be under node_modules. For contributors, it's convenient to test against an instance built from sources. Assume local instance is in a sibling directory called 'yaml-language-server'. Signed-off-by: Roland Grunberg <rgrunber@redhat.com>
1 parent 730a826 commit 1b45356

3 files changed

Lines changed: 18 additions & 19 deletions

File tree

.vscode/launch.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"outFiles": ["${workspaceRoot}/dist/**/*.js"],
1414
"preLaunchTask": "compile typescript",
1515
"env": {
16+
"DEBUG_VSCODE_YAML":"true",
1617
"VSCODE_REDHAT_TELEMETRY_DEBUG":"true"
1718
}
1819
},
@@ -28,7 +29,10 @@
2829
"--extensionTestsPath=${workspaceFolder}/out/test",
2930
"${workspaceRoot}/test/testFixture"
3031
],
31-
"outFiles": ["${workspaceFolder}/out/test/**/*.js"]
32+
"outFiles": ["${workspaceFolder}/out/test/**/*.js"],
33+
"env": {
34+
"DEBUG_VSCODE_YAML":"true"
35+
}
3236
},
3337
{
3438
"name": "Launch Web Extension",

CONTRIBUTING.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,9 @@ All contributions are welcome!
5050

5151
4. Run `yarn install` in both directories to initialize `node_modules` dependencies.
5252

53-
5. In `vscode-yaml/webpack.config.js` set the `config.entry.languageserver` property to:
53+
5. To run the language server in VSCode, click `View -> Debug`, then from the drop down menu beside the green arrow select `Launch Extension (vscode-yaml)`, click the arrow, and a new VSCode window should load with the YAML LS running.
5454

55-
```js
56-
languageserver: './../yaml-language-server/src/server.ts',
57-
```
58-
59-
_This will redirect which YAML LS to use._
60-
61-
6. In `yaml-language-server/.vscode/launch.json` set `outFiles` in the `Attach to server` configuration to:
62-
63-
```js
64-
"outFiles": ["${workspaceFolder}/../vscode-yaml/dist/**/*.js"],
65-
```
66-
67-
7. To run the language server in VSCode, click `View -> Debug`, then from the drop down menu beside the green arrow select `Launch Extension (vscode-yaml)`, click the arrow, and a new VSCode window should load with the YAML LS running.
68-
69-
8. To debug the language server in VSCode, from the same drop down menu
55+
6. To debug the language server in VSCode, from the same drop down menu
7056
select
7157
`Attach (yaml-language-server)`, and click the green arrow to start.
7258
Ensure you've opened a YAML file or else the server would have not yet

src/node/yamlClientMain.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ export async function activate(context: ExtensionContext): Promise<SchemaExtensi
1717
// Create Telemetry Service
1818
const telemetry = await (await getRedHatService(context)).getTelemetryService();
1919

20-
// The YAML language server is implemented in node
21-
const serverModule = context.asAbsolutePath('./dist/languageserver.js');
20+
let serverModule: string;
21+
if (startedFromSources()) {
22+
serverModule = context.asAbsolutePath('../yaml-language-server/out/server/src/server.js');
23+
} else {
24+
// The YAML language server is implemented in node
25+
serverModule = context.asAbsolutePath('./dist/languageserver.js');
26+
}
2227

2328
// The debug options for the server
2429
const debugOptions = { execArgv: ['--nolazy', '--inspect=6009'] };
@@ -41,3 +46,7 @@ export async function activate(context: ExtensionContext): Promise<SchemaExtensi
4146

4247
return startClient(context, newLanguageClient, runtime);
4348
}
49+
50+
function startedFromSources(): boolean {
51+
return process.env['DEBUG_VSCODE_YAML'] === 'true';
52+
}

0 commit comments

Comments
 (0)