Skip to content

Commit

Permalink
Integrate with parent project (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-wiemer authored Aug 21, 2024
1 parent c958994 commit bfda9c1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 24 deletions.
24 changes: 7 additions & 17 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,18 @@
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionDevelopmentKind=web"
],
"outFiles": [
"${workspaceFolder}/client/dist/**/*.js"
],
"outFiles": ["${workspaceFolder}/client/dist/**/*.js"],
"preLaunchTask": "npm: watch-web"
},
{
"type": "extensionHost",
"request": "launch",
"name": "Launch Client",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}"
],
"env": {
"VSCODE_AHK_SERVER_PATH": "out"
},
"outFiles": [
"${workspaceRoot}/client/dist/**/*.js"
]
"args": ["--extensionDevelopmentPath=${workspaceRoot}"],
"env": { "VSCODE_AHK_SERVER_PATH": "server/dist/server.js" },
"outFiles": ["${workspaceRoot}/client/dist/**/*.js"],
"preLaunchTask": "npm: build:dev"
},
{
"type": "node",
Expand All @@ -46,10 +39,7 @@
"compounds": [
{
"name": "Client + Server",
"configurations": [
"Launch Client",
"Attach to Server"
]
"configurations": ["Launch Client", "Attach to Server"]
}
]
}
}
4 changes: 1 addition & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@
"typescript.preferences.quoteStyle": "single",
"git.ignoreLimitWarning": true,
"AutoHotkey2.InterpreterPath": "c:\\Program Files\\AutoHotkey\\v2\\AutoHotkey64.exe",
"[ahk2]": {
"editor.formatOnSave": false
}
"editor.formatOnSave": false
}
7 changes: 5 additions & 2 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ const textdecoders: TextDecoder[] = [new TextDecoder('utf8', { fatal: true }), n
const isWindows = process.platform === 'win32';

export async function activate(context: ExtensionContext) {
console.log('ahk2 activated');
/** Absolute path to `server.js` */
// .replace(/^.*[\\/]/, '') is used to get the last part of the path
const serverModule = context.asAbsolutePath(`server/${process.env.VSCODE_AHK_SERVER_PATH ?? __dirname.replace(/^.*[\\/]/, '')}/server.js`);
const defaultServerModule = context.asAbsolutePath(`ahk2/server/dist/server.js`);
const serverModule = process.env.VSCODE_AHK_SERVER_PATH ? context.asAbsolutePath(process.env.VSCODE_AHK_SERVER_PATH) : defaultServerModule;
console.log('serverModule:', serverModule);

// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
Expand Down Expand Up @@ -113,6 +115,7 @@ export async function activate(context: ExtensionContext) {

// Start the client. This will also launch the server
client.start().then(() => {
console.log('Language client started');
Object.entries(request_handlers).forEach(handler => client.onRequest(...handler));
onDidChangegetInterpreter();
if (window.activeTextEditor?.document.languageId === 'ahk2')
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
"main": "./client/dist/extension",
"browser": "./client/dist/browserClientMain",
"scripts": {
"prebuild": "npm run clean",
"build": "webpack --mode production --devtool hidden-source-map",
"prebuild:dev": "npm run clean",
"build:dev": "webpack",
"chrome": "vscode-test-web --browserType=chromium --extensionDevelopmentPath=. ./test-data",
"clean": "del-cli client/dist server/dist/*.js*",
"clean//": "Remove both the compiled extension and compiled test files",
Expand All @@ -47,9 +51,9 @@
"pretest": "npm run compile-test",
"test": "cd client && vscode-test",
"test-grammar": "vscode-tmgrammar-snap syntaxes/samples/*.{ahk1,ahk2}",
"test//": "Run tests. Requires the extension to be compiled",
"test//": "Run tests",
"validate": "npm run clean && npm run vscode:prepublish && npm run test-grammar && npm run test && npm run package",
"vscode:prepublish": "webpack --mode production --devtool hidden-source-map",
"vscode:prepublish": "npm run build",
"watch": "tsc -b -w",
"watch-web": "webpack --watch"
},
Expand Down

0 comments on commit bfda9c1

Please sign in to comment.