Make it easier to build a local package

Prioritize the debug or unprefixed lsp binaries in the search and update
the README.
This commit is contained in:
Simon Hausmann 2021-04-09 10:51:12 +02:00
parent 5e8b738b70
commit 9da837f5a0
3 changed files with 30 additions and 13 deletions

View file

@ -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.

View file

@ -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",

View file

@ -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;
}