Skip to content

Commit d22d885

Browse files
committed
feat: add lsp extension
1 parent 72ac825 commit d22d885

File tree

13 files changed

+1218
-8
lines changed

13 files changed

+1218
-8
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ jobs:
3232
- name: Install deps
3333
run: pnpm install
3434

35-
# - name: Build
36-
# run: pnpm run build
35+
- name: Build
36+
run: pnpm run build
3737

3838
# - name: Lint
3939
# run: pnpm run lint

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
client/out
12
node_modules
2-
*.vsix
3+
*.vsix
4+
tsconfig.tsbuildinfo

.vscode/extensions.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"esbenp.prettier-vscode",
66
"github.vscode-github-actions",
77
"kravets.vscode-publint",
8+
"ms-vscode.extension-test-runner",
89
"pflannery.vscode-versionlens",
910
"redhat.vscode-yaml"
1011
]

.vscode/launch.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
// A launch configuration that launches the extension inside a new window
1+
// A launch configuration that compiles the extension and then opens it inside a new window
22
// Use IntelliSense to learn about possible attributes.
33
// Hover to view descriptions of existing attributes.
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
{
66
"version": "0.2.0",
77
"configurations": [
88
{
9-
"name": "Extension",
9+
"name": "Run Extension",
1010
"type": "extensionHost",
1111
"request": "launch",
12-
"args": ["--extensionDevelopmentPath=${workspaceFolder}"]
12+
"runtimeExecutable": "${execPath}",
13+
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
14+
"outFiles": ["${workspaceFolder}/client/out/**/*.js"],
15+
"autoAttachChildProcesses": true
1316
}
1417
]
1518
}

.vscode/settings.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,13 @@
33
"files.associations": {
44
"*.json5": "jsonc"
55
},
6+
"files.exclude": {
7+
"out": false,
8+
"dist": false
9+
},
10+
"search.exclude": {
11+
"out": true,
12+
"dist": true
13+
},
614
"typescript.tsdk": "node_modules/typescript/lib"
715
}

.vscodeignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
.vscode/**
22
.vscode-test/**
3+
out/**
4+
node_modules/**
5+
src/**
36
.gitignore
7+
.yarnrc
48
vsc-extension-quickstart.md
9+
**/tsconfig.json
10+
**/*.map
11+
**/*.ts
12+
**/.vscode-test.*

client/package.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "@hsml/lsp-client",
3+
"version": "0.1.0",
4+
"description": "HSML Language Server Client",
5+
"scripts": {
6+
"build": "run-s build:clean build:code",
7+
"build:clean": "rimraf out",
8+
"build:code": "tsup-node",
9+
"ts-check": "tsc",
10+
"vscode:prepublish": "tsc -p ./"
11+
},
12+
"repository": {
13+
"type": "git",
14+
"url": "https://github.com/Shinigami92/vscode-hsml"
15+
},
16+
"license": "MIT",
17+
"author": {
18+
"name": "Christopher Quadflieg",
19+
"email": "chrissi92@hotmail.de",
20+
"url": "https://github.com/Shinigami92"
21+
},
22+
"publisher": "hsml-lab",
23+
"activationEvents": [],
24+
"dependencies": {
25+
"vscode-languageclient": "9.0.1"
26+
},
27+
"devDependencies": {
28+
"@types/vscode": "1.98.0",
29+
"tsup": "8.4.0"
30+
},
31+
"engines": {
32+
"vscode": "^1.98.0"
33+
}
34+
}

client/src/extension.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import type { ExtensionContext } from 'vscode';
2+
import { workspace } from 'vscode';
3+
import type {
4+
Executable,
5+
LanguageClientOptions,
6+
ServerOptions,
7+
} from 'vscode-languageclient/node';
8+
import { LanguageClient } from 'vscode-languageclient/node';
9+
10+
let client: LanguageClient | undefined;
11+
12+
export function activate(context: ExtensionContext) {
13+
console.debug('[@hsml/lsp-client:activate]', context);
14+
15+
const run: Executable = {
16+
command: '/Users/shinigami/OpenSource/Shinigami92/hsml/target/debug/hsml',
17+
args: ['lsp'],
18+
};
19+
20+
const serverOptions: ServerOptions = {
21+
run,
22+
debug: {
23+
...run,
24+
},
25+
};
26+
27+
const clientOptions: LanguageClientOptions = {
28+
documentSelector: [{ scheme: 'file', language: 'hsml' }],
29+
synchronize: {
30+
fileEvents: workspace.createFileSystemWatcher('**/*.hsml'),
31+
},
32+
};
33+
34+
client = new LanguageClient(
35+
'languageServerHsml',
36+
'HSML Language Server',
37+
serverOptions,
38+
clientOptions
39+
);
40+
41+
console.debug('[@hsml/lsp-client:activate]', 'starting client');
42+
client.start();
43+
}
44+
45+
export function deactivate(): Promise<void> | undefined {
46+
console.debug('[@hsml/lsp-client:deactivate]');
47+
if (!client) {
48+
return undefined;
49+
}
50+
51+
console.debug('[@hsml/lsp-client:deactivate]', 'stopping client');
52+
return client.stop();
53+
}

client/tsconfig.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"lib": ["ES2022"],
5+
"noEmit": true,
6+
"rootDir": "src",
7+
"strict": true
8+
},
9+
"include": ["src"],
10+
"exclude": ["node_modules"]
11+
}

client/tsup.config.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { defineConfig } from 'tsup';
2+
3+
export default defineConfig({
4+
entry: ['src/extension.ts'],
5+
external: ['vscode'],
6+
outDir: 'out',
7+
clean: true,
8+
format: 'cjs',
9+
target: ['es2022', 'node20'],
10+
platform: 'node',
11+
minify: false,
12+
bundle: true,
13+
});

0 commit comments

Comments
 (0)