Skip to content

Commit

Permalink
Fix running the extension (withastro#181)
Browse files Browse the repository at this point in the history
I'm not sure how my setup was different but I was unable to get the extension to run locally without adding a binary. This mirrors what Svelte does so I'm assuming it's the way it's supposed to be loaded.
  • Loading branch information
matthewp committed May 8, 2021
1 parent b4c072d commit 60e482a
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
15 changes: 6 additions & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@
"version": "0.2.0",
"configurations": [
{
"type": "pwa-extensionHost",
"request": "launch",
"name": "Launch Client",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
"outFiles": ["${workspaceRoot}/tools/astro-vscode/dist/**/*.js"],
"preLaunchTask": {
"type": "npm",
"script": "build:vscode"
}
"args": ["--extensionDevelopmentPath=${workspaceRoot}/tools/astro-vscode"],
"outFiles": ["${workspaceRoot}/tools/astro-vscode/dist/**/*.js"]
},
{
"type": "node",
"request": "attach",
"name": "Attach to Server",
"port": 6040,
"restart": true,
"outFiles": ["${workspaceRoot}/tools/astro-languageserver/dist/**/*.js"]
"outFiles": ["${workspaceRoot}/tools/astro-languageserver/dist/**/*.js"],
"skipFiles": ["<node_internals>/**"]
}
],
"compounds": [
Expand Down
6 changes: 6 additions & 0 deletions tools/astro-languageserver/bin/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#! /usr/bin/env node

// eslint-disable-next-line @typescript-eslint/no-var-requires
const { startServer } = require('../dist/index');

startServer();
3 changes: 2 additions & 1 deletion tools/astro-languageserver/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "dist",
"rootDir": "src"
"rootDir": "src",
"target": "ES2020"
},
"include": ["src"],
"exclude": ["node_modules"]
Expand Down
20 changes: 20 additions & 0 deletions tools/astro-vscode/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Contributing

## Development workflow

In the monorepo first install and build Astro:

```shell
yarn install
yarn build
```

To start the development server run:

```shell
yarn dev:vscode
```

Then in the __Debug__ panel select __Launch Extension__ from the dropdown and click the run button.

<img width="558" alt="Screen Shot 2021-05-07 at 8 51 37 AM" src="https://user-images.githubusercontent.com/361671/117452223-807e5580-af11-11eb-8404-dd615784408a.png">
4 changes: 3 additions & 1 deletion tools/astro-vscode/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export async function activate(context: vscode.ExtensionContext) {
/** */
function createLanguageService(context: vscode.ExtensionContext, mode: 'doc', id: string, name: string, port: number) {
const { workspace } = vscode;
const serverModule = context.asAbsolutePath(require.resolve('astro-languageserver'));
const serverModule = require.resolve('astro-languageserver/bin/server.js');
const debugOptions = { execArgv: ['--nolazy', '--inspect=' + port] };
const serverOptions: lsp.ServerOptions = {
run: { module: 'astro-languageserver', transport: lsp.TransportKind.ipc },
Expand Down Expand Up @@ -60,6 +60,8 @@ function createLanguageService(context: vscode.ExtensionContext, mode: 'doc', id
};
const disposable = activateTagClosing(tagRequestor, { astro: true }, 'html.autoClosingTags');
context.subscriptions.push(disposable);
}).catch(err => {
console.error('Astro, unable to load language server.', err);
});

return client;
Expand Down

0 comments on commit 60e482a

Please sign in to comment.