From 9da837f5a009e9ad3884d4e88f669bda285ee39d Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 9 Apr 2021 10:51:12 +0200 Subject: [PATCH] Make it easier to build a local package Prioritize the debug or unprefixed lsp binaries in the search and update the README. --- vscode_extension/README.md | 26 +++++++++++++++++++------- vscode_extension/package.json | 2 +- vscode_extension/src/extension.ts | 15 ++++++++++----- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/vscode_extension/README.md b/vscode_extension/README.md index 680b2e025..9eeddfff5 100644 --- a/vscode_extension/README.md +++ b/vscode_extension/README.md @@ -7,6 +7,7 @@ Extension for VSCode which include syntax coloration and a way to start the LSP - Syntax highlighting - Diagnostics from .60 files - Live Preview of a .60 file + - Completion of properties - Jump to definition (currently, only definition of Component) ## Setup @@ -24,7 +25,7 @@ cd vscode_extension npm install ``` -## How to run the LSP +## How to debug the LSP At the moment you need to load this directory in VS code and then start debugging (Run -> Start Debugging). That will "debug" the vs code extension and create a new VS code window. The LSP server binary will be started if previously built @@ -32,10 +33,21 @@ You can see the output in the output pane "SixtyFPS LSP" (that's the drop-down t ## How to build the extension package -To create a `.vsix` package: +To create a `.vsix` package for local installation: - 1. Install `vsce` (via npm for example). - 2. Change to the `vscode_extension` sub-directory. - 3. Install the dependencies: `npm install`. - 4. Build the lsp binaries: `npm compile-lsp`. - 5. Run `vsce package` to create the extension package. +1. Follow the setup steps above to build the lsp binary and install npm dependencies. + +2. Create a `.vsix` package (needs `vsce` installed) + +```sh +npm run local-package +``` +3. Install the `.vsix` file with + +```sh +code --install-extension sixtyfps-vscode-*.vsix +``` + +4. Reload your VS code windows + +Note that the resulting `.vsix` package contains your locally built debug LSP server. It is not suitable for distribution. diff --git a/vscode_extension/package.json b/vscode_extension/package.json index c2235f287..f193d20b9 100644 --- a/vscode_extension/package.json +++ b/vscode_extension/package.json @@ -70,7 +70,7 @@ "scripts": { "vscode:prepublish": "npm run compile", "compile": "tsc -p ./", - "compile-lsp": "./build_lsp.sh", + "local-package": "mkdir -p bin && cp ../target/debug/sixtyfps-lsp bin/ && npx vsce package", "watch": "tsc -watch -p ./", "pretest": "npm run compile && npm run lint", "lint": "eslint src --ext ts", diff --git a/vscode_extension/src/extension.ts b/vscode_extension/src/extension.ts index 7571b9e85..54fe876b2 100644 --- a/vscode_extension/src/extension.ts +++ b/vscode_extension/src/extension.ts @@ -53,12 +53,17 @@ export function activate(context: vscode.ExtensionContext) { return; } - let serverModule = path.join(context.extensionPath, "bin", "sixtyfps-lsp-" + lsp_platform + program_extension); + // Try a local ../target build first, then try the plain bundled binary and finally the architecture specific one. + // A debug session will find the first one, a local package build the second and the distributed vsix the last. + const lspSearchPaths = [ + context.asAbsolutePath(path.join('..', 'target', 'debug', 'sixtyfps-lsp' + program_extension)), + path.join(context.extensionPath, "bin", "sixtyfps-lsp" + program_extension), + path.join(context.extensionPath, "bin", "sixtyfps-lsp-" + lsp_platform + program_extension), + ]; - if (!existsSync(serverModule)) { - serverModule = context.asAbsolutePath(path.join('..', 'target', 'debug', 'sixtyfps-lsp' + program_extension)); - } - if (!existsSync(serverModule)) { + let serverModule = lspSearchPaths.find(path => existsSync(path)); + + if (serverModule == undefined) { console.warn("Could not locate sixtyfps-server server binary, neither in bundled bin/ directory nor relative in ../target"); return; }