Skip to content

Commit

Permalink
Convert vscode to typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
jdesrosiers committed Jun 30, 2024
1 parent 31d1f49 commit 8310bc5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ jobs:
- run: cd language-server && npm run type-check
- run: cd language-server && npm run lint
- run: cd vscode && npm ci
- run: cd vscode && npm run type-check
- run: cd vscode && npm run lint
- run: cd vscode && npm run build
26 changes: 26 additions & 0 deletions vscode/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"main": "./out/extension.js",
"scripts": {
"lint": "eslint src",
"type-check": "tsc --noEmit",
"vscode:prepublish": "npm run build-client -- --minify && npm run build-server -- --minify",
"build": "npm run build-client -- --sourcemap && npm run build-server -- --sourcemap",
"build-client": "esbuild ./src/extension.js --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node",
"build-client": "esbuild ./src/extension.ts --bundle --outfile=out/extension.js --external:vscode --format=cjs --platform=node",
"build-server": "esbuild ../language-server/src/server.js --bundle --main-fields=module,main --outfile=out/server.js --external:vscode --format=cjs --platform=node",
"package": "vsce package --out=dist",
"publish": "vsce publish"
Expand All @@ -16,6 +17,8 @@
"license": "MIT",
"repository": "github:hyperjump-io/json-schema-language-tools",
"devDependencies": {
"@types/node": "*",
"@types/vscode": "*",
"@vscode/vsce": "*",
"esbuild": "*",
"eslint": "*",
Expand Down
21 changes: 10 additions & 11 deletions vscode/src/extension.js → vscode/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"use strict";
const path = require("node:path");
const { LanguageClient, TransportKind, MarkupKind } = require("vscode-languageclient");
import * as path from "node:path";
import { LanguageClient, TransportKind, MarkupKind } from "vscode-languageclient/node.js";

import type { ExtensionContext } from "vscode";

let client;

const activate = (context) => {
let client: LanguageClient | undefined;

const activate = async (context: ExtensionContext) => {
const serverModule = context.asAbsolutePath(path.join("out", "server.js"));
const serverOptions = {
run: {
Expand All @@ -16,15 +17,13 @@ const activate = (context) => {
module: serverModule,
transport: TransportKind.ipc,
options: {
execArgc: ["--nolazy", "--inspect=6009"]
execArgv: ["--nolazy", "--inspect=6009"]
}
}
};

const clientOptions = {
documentSelector: [
{ scheme: "file", language: "json" }
],
documentSelector: [{ scheme: "file", language: "json" }],
capabilities: {
textDocument: {
hover: {
Expand All @@ -35,9 +34,9 @@ const activate = (context) => {
};

client = new LanguageClient("jsonSchemaLanguageServer", "JSON Schema Language Server", serverOptions, clientOptions);
client.start();
await client.start();
};

const deactivate = () => client?.stop();
const deactivate = async () => client?.stop();

module.exports = { activate, deactivate };
3 changes: 2 additions & 1 deletion vscode/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
"strict": true,
"checkJs": true,
"skipLibCheck": true
}
},
"exclude": ["out"]
}

0 comments on commit 8310bc5

Please sign in to comment.