Skip to content

Commit 635d7b3

Browse files
committed
vscode: Setup launch config like rust-analyzer
1 parent 304b97b commit 635d7b3

File tree

5 files changed

+124
-24
lines changed

5 files changed

+124
-24
lines changed

.vscode/launch.json

+57-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,66 @@
22
"version": "0.2.0",
33
"configurations": [
44
{
5+
"name": "Run Extension",
56
"type": "extensionHost",
67
"request": "launch",
7-
"name": "Launch Client",
88
"runtimeExecutable": "${execPath}",
9-
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
10-
"outFiles": ["${workspaceRoot}/omniwsa-vscode/client/out/**/*.js"],
11-
"autoAttachChildProcesses": true,
12-
"preLaunchTask": { "type": "npm", "script": "watch" }
9+
"args": ["--disable-extensions", "--extensionDevelopmentPath=${workspaceFolder}/omniwsa-vscode"],
10+
"outFiles": ["${workspaceFolder}/omniwsa-vscode/client/out/**/*.js"],
11+
"preLaunchTask": "Build Server and Extension",
12+
"skipFiles": ["<node_internals>/**/*.js"],
13+
"env": { "OMNIWSA_LS_DEBUG_PATH": "${workspaceFolder}/target/debug/omniwsa-ls" }
14+
},
15+
{
16+
"name": "Run Extension (Release Build)",
17+
"type": "extensionHost",
18+
"request": "launch",
19+
"runtimeExecutable": "${execPath}",
20+
"args": ["--disable-extensions", "--extensionDevelopmentPath=${workspaceFolder}/omniwsa-vscode"],
21+
"outFiles": ["${workspaceFolder}/omniwsa-vscode/client/out/**/*.js"],
22+
"preLaunchTask": "Build Server (Release) and Extension",
23+
"skipFiles": ["<node_internals>/**/*.js"],
24+
"env": { "OMNIWSA_LS_DEBUG_PATH": "${workspaceFolder}/target/release/omniwsa-ls" }
25+
},
26+
{
27+
"name": "Run With Extensions",
28+
"type": "extensionHost",
29+
"request": "launch",
30+
"runtimeExecutable": "${execPath}",
31+
"args": [
32+
"--disable-extension",
33+
"thaliaarchi.omniwsa",
34+
"--extensionDevelopmentPath=${workspaceFolder}/omniwsa-vscode"
35+
],
36+
"outFiles": ["${workspaceFolder}/omniwsa-vscode/client/out/**/*.js"],
37+
"preLaunchTask": "Build Server and Extension",
38+
"skipFiles": ["<node_internals>/**/*.js"],
39+
"env": { "OMNIWSA_LS_DEBUG_PATH": "${workspaceFolder}/target/debug/omniwsa-ls" }
40+
},
41+
{
42+
"name": "Run With Extensions (Release Build)",
43+
"type": "extensionHost",
44+
"request": "launch",
45+
"runtimeExecutable": "${execPath}",
46+
"args": [
47+
"--disable-extension",
48+
"thaliaarchi.omniwsa",
49+
"--extensionDevelopmentPath=${workspaceFolder}/omniwsa-vscode"
50+
],
51+
"outFiles": ["${workspaceFolder}/omniwsa-vscode/client/out/**/*.js"],
52+
"preLaunchTask": "Build Server (Release) and Extension",
53+
"skipFiles": ["<node_internals>/**/*.js"],
54+
"env": { "OMNIWSA_LS_DEBUG_PATH": "${workspaceFolder}/target/release/omniwsa-ls" }
55+
},
56+
{
57+
"name": "Run Installed Extension",
58+
"type": "extensionHost",
59+
"request": "launch",
60+
"runtimeExecutable": "${execPath}",
61+
"args": ["--disable-extensions", "--extensionDevelopmentPath=${workspaceFolder}/omniwsa-vscode"],
62+
"outFiles": ["${workspaceFolder}/omniwsa-vscode/client/out/**/*.js"],
63+
"preLaunchTask": "Build Extension",
64+
"skipFiles": ["<node_internals>/**/*.js"]
1365
}
1466
]
1567
}

.vscode/tasks.json

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"version": "2.0.0",
3+
"tasks": [
4+
{
5+
"label": "Build Extension in Background",
6+
"group": "build",
7+
"type": "npm",
8+
"script": "watch",
9+
"path": "omniwsa-vscode/",
10+
"problemMatcher": { "base": "$tsc-watch", "fileLocation": ["relative", "${workspaceFolder}/omniwsa-vscode/"] },
11+
"isBackground": true
12+
},
13+
{
14+
"label": "Build Extension",
15+
"group": "build",
16+
"type": "npm",
17+
"script": "build",
18+
"path": "omniwsa-vscode/",
19+
"problemMatcher": { "base": "$tsc", "fileLocation": ["relative", "${workspaceFolder}/omniwsa-vscode/"] }
20+
},
21+
{
22+
"label": "Build Server",
23+
"group": "build",
24+
"type": "shell",
25+
"command": "cargo build --package omniwsa-ls",
26+
"problemMatcher": "$rustc"
27+
},
28+
{
29+
"label": "Build Server (Release)",
30+
"group": "build",
31+
"type": "shell",
32+
"command": "cargo build --package omniwsa-ls --release",
33+
"problemMatcher": "$rustc"
34+
},
35+
{
36+
"label": "Build Server and Extension",
37+
"dependsOn": ["Build Server", "Build Extension"],
38+
"problemMatcher": "$rustc"
39+
},
40+
{
41+
"label": "Build Server (Release) and Extension",
42+
"dependsOn": ["Build Server (Release)", "Build Extension"],
43+
"problemMatcher": "$rustc"
44+
}
45+
]
46+
}

omniwsa-ls/src/main.rs

+15-8
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use std::{
77
use lsp_server::{Connection, Message, Request, Response};
88
use lsp_types::{
99
request::{Request as _, SemanticTokensFullRequest},
10-
InitializeParams, SemanticToken, SemanticTokens, SemanticTokensFullOptions,
11-
SemanticTokensLegend, SemanticTokensOptions, SemanticTokensParams, SemanticTokensResult,
12-
SemanticTokensServerCapabilities, ServerCapabilities, WorkDoneProgressOptions,
10+
InitializeParams, SemanticToken, SemanticTokenModifier, SemanticTokenType, SemanticTokens,
11+
SemanticTokensFullOptions, SemanticTokensLegend, SemanticTokensOptions, SemanticTokensParams,
12+
SemanticTokensResult, SemanticTokensServerCapabilities, ServerCapabilities,
1313
};
1414
use serde_json::{from_value as from_json, to_value as to_json};
1515

@@ -36,12 +36,19 @@ fn server_capabilities() -> ServerCapabilities {
3636
ServerCapabilities {
3737
semantic_tokens_provider: Some(SemanticTokensServerCapabilities::SemanticTokensOptions(
3838
SemanticTokensOptions {
39-
work_done_progress_options: WorkDoneProgressOptions {
40-
work_done_progress: Some(true), // TODO
41-
},
39+
work_done_progress_options: Default::default(),
4240
legend: SemanticTokensLegend {
43-
token_types: vec![], // TODO
44-
token_modifiers: vec![], // TODO
41+
token_types: vec![
42+
SemanticTokenType::FUNCTION,
43+
SemanticTokenType::KEYWORD,
44+
SemanticTokenType::COMMENT,
45+
SemanticTokenType::STRING,
46+
SemanticTokenType::NUMBER,
47+
],
48+
token_modifiers: vec![
49+
SemanticTokenModifier::DECLARATION,
50+
SemanticTokenModifier::DEFINITION,
51+
],
4552
},
4653
range: Some(false),
4754
full: Some(SemanticTokensFullOptions::Bool(true)),

omniwsa-vscode/client/src/extension.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as path from "path";
1+
import { env } from "process";
22
import { ExtensionContext } from "vscode";
33

44
import {
@@ -11,15 +11,10 @@ import {
1111
let client: LanguageClient;
1212

1313
export function activate(context: ExtensionContext) {
14+
const command = env.OMNIWSA_LS_DEBUG_PATH ?? "omniwsa-ls";
1415
const serverOptions: ServerOptions = {
15-
run: {
16-
command: context.asAbsolutePath(path.join("..", "target", "release", "omniwsa-ls")),
17-
transport: TransportKind.stdio
18-
},
19-
debug: {
20-
command: context.asAbsolutePath(path.join("..", "target", "debug", "omniwsa-ls")),
21-
transport: TransportKind.stdio
22-
},
16+
run: { command, transport: TransportKind.stdio },
17+
debug: { command, transport: TransportKind.stdio },
2318
};
2419

2520
const clientOptions: LanguageClientOptions = {

omniwsa-vscode/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"languages": [{ "id": "whitespace-assembly", "extensions": [".wsa"], "aliases": ["Whitespace assembly", "wsa"] }]
1717
},
1818
"scripts": {
19-
"vscode:prepublish": "npm run compile",
20-
"compile": "tsc -b",
19+
"vscode:prepublish": "npm run build",
20+
"build": "tsc -b",
2121
"watch": "tsc -b -w",
2222
"lint": "eslint",
2323
"postinstall": "cd client && npm install"

0 commit comments

Comments
 (0)