From 7e25cb1e5f2499d8c08fd6e66ad7990e2f644e0f Mon Sep 17 00:00:00 2001 From: skovhus Date: Fri, 17 Apr 2020 21:50:00 +0200 Subject: [PATCH] Update tsconfig and vscode tasks setup Based on https://github.com/microsoft/vscode-extension-samples/blob/e1ecdaec8974b938e7a92589faa233e1691d251f/lsp-sample/.vscode/launch.json --- .vscode/launch.json | 35 ++++++++++++++++++++++++++--- .vscode/settings.json | 1 - .vscode/tasks.json | 13 ++++++----- docs/development-guide.md | 8 ------- package.json | 9 ++++---- server/package.json | 4 +--- server/tsconfig.json | 8 ++++--- tsconfig.eslint.json | 2 +- tsconfig.base.json => tsconfig.json | 10 +++++++++ vscode-client/package.json | 6 ++--- vscode-client/src/extension.ts | 12 ++++++++-- vscode-client/tsconfig.json | 8 ++++--- 12 files changed, 77 insertions(+), 39 deletions(-) rename tsconfig.base.json => tsconfig.json (67%) diff --git a/.vscode/launch.json b/.vscode/launch.json index 01d0f4791..69cc13d49 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,3 +1,5 @@ +// A launch configuration that compiles the extension and then opens it inside a new window +// https://github.com/microsoft/vscode-extension-samples/blob/e1ecdaec8974b938e7a92589faa233e1691d251f/lsp-sample/.vscode/launch.json { "version": "0.2.0", "configurations": [ @@ -9,12 +11,39 @@ "args": [ "--extensionDevelopmentPath=${workspaceRoot}/vscode-client" ], - "stopOnEntry": false, - "sourceMaps": true, "outFiles": [ "${workspaceRoot}/vscode-client/out/**/*.js" ], - "preLaunchTask": "compile" + "preLaunchTask": { + "type": "npm", + "script": "watch" + } + }, + { + "type": "node", + "request": "attach", + "name": "Attach to Server", + "port": 6009, + "restart": true, + "outFiles": ["${workspaceRoot}/server/out/**/*.js"] + }, + { + "name": "Language Server E2E Test", + "type": "extensionHost", + "request": "launch", + "runtimeExecutable": "${execPath}", + "args": [ + "--extensionDevelopmentPath=${workspaceRoot}", + "--extensionTestsPath=${workspaceRoot}/vscode-client/out/test/index", + "${workspaceRoot}/vscode-client/testFixture" + ], + "outFiles": ["${workspaceRoot}/vscode-client/out/test/**/*.js"] + } + ], + "compounds": [ + { + "name": "Client + Server", + "configurations": ["Launch Client", "Attach to Server"] } ] } diff --git a/.vscode/settings.json b/.vscode/settings.json index 2bcd9637d..aeb62227b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,5 @@ { "files.exclude": { - "vscode-client/out": true, "server/out": true }, "search.exclude": { diff --git a/.vscode/tasks.json b/.vscode/tasks.json index ff0fc7023..1f6adeda2 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -2,17 +2,18 @@ "version": "2.0.0", "tasks": [ { - "label": "compile", "type": "npm", - "script": "compile", - "group": "build", + "script": "watch", + "problemMatcher": "$tsc-watch", + "isBackground": true, "presentation": { "panel": "dedicated", "reveal": "never" }, - "problemMatcher": [ - "$tsc" - ] + "group": { + "kind": "build", + "isDefault": true + } } ] } diff --git a/docs/development-guide.md b/docs/development-guide.md index 78a01f2cc..4e3297a61 100644 --- a/docs/development-guide.md +++ b/docs/development-guide.md @@ -59,8 +59,6 @@ View to launch the `Launch Client` task. This will open a new vscode window with extension loaded. It also looks for changes to your client code and recompiles it whenever you save your changes. -As the server is embedded into the - ### Atom See the [ide-bash][ide-bash] package for Atom. Due to how Atom packages are @@ -77,12 +75,6 @@ yarn link-server After that follow the steps above to work on the client. -If you make any changes to the server, you need to recompile it: - -``` -yarn compile:server -``` - ## Working on the server (standalone) diff --git a/package.json b/package.json index f2d121a8e..e600dadd9 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,8 @@ "scripts": { "clean": "rm -rf *.log */*.log */out node_modules vscode-client/node_modules server/node_modules", "postinstall": "cd server && yarn install && cd ../vscode-client && yarn install && cd ..", - "compile": "yarn run compile:server && yarn run compile:client", - "compile:client": "cd vscode-client && yarn run compile", - "compile:server": "cd server && yarn run compile", + "compile": "tsc -b", + "watch": "tsc -b -w", "lint": "yarn lint:bail --fix", "lint:bail": "eslint . --ext js,ts,tsx --cache", "test": "jest --runInBand", @@ -13,8 +12,8 @@ "test:watch": "yarn run test --watch", "verify": "yarn run lint && yarn run compile && yarn run test", "verify:bail": "yarn run lint:bail && yarn run compile && yarn run test:coverage", - "reinstall-server": "npm uninstall -g bash-language-server && yarn compile:server && npm i -g ./server", - "link-server": "npm uninstall -g bash-language-server && yarn compile:server && yarn unlink bash-language-server && cd server && yarn link && cd ../vscode-client && yarn link bash-language-server" + "reinstall-server": "npm uninstall -g bash-language-server && yarn compile && npm i -g ./server", + "link-server": "npm uninstall -g bash-language-server && yarn compile && yarn unlink bash-language-server && cd server && yarn link && cd ../vscode-client && yarn link bash-language-server" }, "devDependencies": { "@types/jest": "^25.1.3", diff --git a/server/package.json b/server/package.json index 75a1870a5..b93dd36f1 100644 --- a/server/package.json +++ b/server/package.json @@ -29,9 +29,7 @@ "web-tree-sitter": "^0.16.2" }, "scripts": { - "compile": "rm -rf out && ../node_modules/.bin/tsc -p ./", - "compile:watch": "../node_modules/.bin/tsc -w -p ./", - "prepublishOnly": "yarn run compile" + "prepublishOnly": "cd ../ && yarn run compile" }, "devDependencies": { "@types/fuzzy-search": "^2.1.0", diff --git a/server/tsconfig.json b/server/tsconfig.json index 4bb2e797a..8f65526f9 100644 --- a/server/tsconfig.json +++ b/server/tsconfig.json @@ -1,12 +1,14 @@ { - "extends": "../tsconfig.base.json", + "extends": "../tsconfig.json", "compilerOptions": { "outDir": "out", + "rootDir": "src", "lib": [ "dom", // Required by @types/turndown "es2016" ], - "strict": true, - } + }, + "include": ["src"], + "exclude": ["node_modules", "../testing", "src/__tests__"] } diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 2a1bdc616..529f15530 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -1,5 +1,5 @@ { - "extends": "./tsconfig.base.json", + "extends": "./tsconfig.json", "exclude": [ "node_modules" ], diff --git a/tsconfig.base.json b/tsconfig.json similarity index 67% rename from tsconfig.base.json rename to tsconfig.json index 8d4211ac9..4a2ece93c 100644 --- a/tsconfig.base.json +++ b/tsconfig.json @@ -10,12 +10,22 @@ "lib": [ "es2016" ], + "rootDir": ".", "sourceMap": true }, + "include": [ + "testing" + ], "exclude": [ "node_modules", "**/__tests__/*", + "vscode-client/out", + "server/out", "server/setupJest.ts", "testing" + ], + "references": [ + { "path": "./vscode-client" }, + { "path": "./server" } ] } diff --git a/vscode-client/package.json b/vscode-client/package.json index 9252850cb..13013a38b 100644 --- a/vscode-client/package.json +++ b/vscode-client/package.json @@ -25,7 +25,7 @@ "activationEvents": [ "onLanguage:shellscript" ], - "main": "./out/src/extension", + "main": "./out/extension", "contributes": { "configuration": { "type": "object", @@ -50,9 +50,7 @@ } }, "scripts": { - "vscode:prepublish": "yarn run compile", - "compile": "rm -rf out && ../node_modules/.bin/tsc -p ./", - "compile:watch": "../node_modules/.bin/tsc -w -p ./" + "vscode:prepublish": "cd.. && yarn run compile" }, "dependencies": { "bash-language-server": "1.13.0", diff --git a/vscode-client/src/extension.ts b/vscode-client/src/extension.ts index d2ede6f34..139ae781b 100644 --- a/vscode-client/src/extension.ts +++ b/vscode-client/src/extension.ts @@ -27,16 +27,24 @@ export async function activate(context: ExtensionContext) { } const serverExecutable = { - module: context.asAbsolutePath(path.join('out', 'src', 'server.js')), + module: context.asAbsolutePath(path.join('out', 'server.js')), transport: TransportKind.ipc, options: { env, }, } + const debugServerExecutable = { + ...serverExecutable, + options: { + ...serverExecutable.options, + execArgv: ['--nolazy', '--inspect=6009'], + }, + } + const serverOptions: ServerOptions = { run: serverExecutable, - debug: serverExecutable, + debug: debugServerExecutable, } const clientOptions: LanguageClientOptions = { diff --git a/vscode-client/tsconfig.json b/vscode-client/tsconfig.json index 19cdcac49..43eb7cd07 100644 --- a/vscode-client/tsconfig.json +++ b/vscode-client/tsconfig.json @@ -1,7 +1,9 @@ { - "extends": "../tsconfig.base.json", + "extends": "../tsconfig.json", "compilerOptions": { "outDir": "out", - "rootDir": "." - } + "rootDir": "src" + }, + "include": ["src"], + "exclude": ["node_modules", "../testing"] }