···11-// The module 'vscode' contains the VS Code extensibility API
22-// Import the module and reference it with the alias vscode in your code below
11+import * as path from 'path';
32import * as vscode from 'vscode';
33+import { workspace, ExtensionContext } from 'vscode';
44+import {
55+ LanguageClient,
66+ LanguageClientOptions,
77+ ServerOptions,
88+ TransportKind,
99+ Trace
1010+} from 'vscode-languageclient/node';
41155-// This method is called when your extension is activated
66-// Your extension is activated the very first time the command is executed
77-export function activate(context: vscode.ExtensionContext) {
1212+import { AssistantPanelController } from './AssistantPanelController';
81399- // Use the console to output diagnostic information (console.log) and errors (console.error)
1010- // This line of code will only be executed once when your extension is activated
1111- console.log('Congratulations, your extension "pterodactyl-language-client" is now active!');
1414+let client: LanguageClient | undefined;
12151313- // The command has been defined in the package.json file
1414- // Now provide the implementation of the command with registerCommand
1515- // The commandId parameter must match the command field in package.json
1616- const disposable = vscode.commands.registerCommand('pterodactyl-language-client.helloWorld', () => {
1717- // The code you place here will be executed every time your command is executed
1818- // Display a message box to the user
1919- vscode.window.showInformationMessage('Hello World from pterodactyl-language-client!');
2020- });
1616+export function activate(context: ExtensionContext) {
1717+ console.log("Jon activate!");
1818+1919+ let assistantPanelController = new AssistantPanelController(context);
2020+2121+ // Update panel whenever the active editor changes
2222+ context.subscriptions.push(
2323+ vscode.window.onDidChangeActiveTextEditor(editor => assistantPanelController.update(editor))
2424+ );
21252222- context.subscriptions.push(disposable);
2626+ // Populate panel for the editor open at activation
2727+ assistantPanelController.update(vscode.window.activeTextEditor);
2828+2929+ // Path to your language server executable
3030+ // If it’s a Swift binary, give the absolute path
3131+ const serverCommand = "/Users/jon/Developer/swift-pterodactyl/.build/debug/PterodactylLanguageServer";
3232+3333+ const serverOptions: ServerOptions = {
3434+ command: serverCommand,
3535+ args: [],
3636+ transport: TransportKind.stdio
3737+ };
3838+3939+ const clientOptions: LanguageClientOptions = {
4040+ documentSelector: [{ scheme: 'file', language: 'pterodactyl' }],
4141+ synchronize: {
4242+ fileEvents: workspace.createFileSystemWatcher('**/*.ptero')
4343+ },
4444+ outputChannel: vscode.window.createOutputChannel("Pterodactyl Server"),
4545+ traceOutputChannel: vscode.window.createOutputChannel('LSP Trace'),
4646+ };
4747+4848+ client = new LanguageClient(
4949+ 'pterodactylLanguageServer', // ID
5050+ 'Pterodactyl Language Server', // Name
5151+ serverOptions,
5252+ clientOptions
5353+ );
5454+5555+ client.setTrace(Trace.Verbose);
5656+ client.start();
2357}
24582525-// This method is called when your extension is deactivated
2626-export function deactivate() {}
5959+export function deactivate(): Thenable<void> | undefined {
6060+ if (!client) {
6161+ return undefined;
6262+ }
6363+ return client.stop();
6464+}
+15-16
tsconfig.json
···11{
22- "compilerOptions": {
33- "module": "Node16",
44- "target": "ES2022",
55- "outDir": "out",
66- "lib": [
77- "ES2022"
88- ],
99- "sourceMap": true,
1010- "rootDir": "src",
1111- "strict": true, /* enable all strict type-checking options */
1212- /* Additional Checks */
1313- // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
1414- // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
1515- // "noUnusedParameters": true, /* Report errors on unused parameters. */
1616- }
1717-}
22+ "compilerOptions": {
33+ "module": "commonjs", // VS Code extensions use CommonJS
44+ "target": "es2020", // Modern enough for Node 14+
55+ "outDir": "out", // Compiled JS goes here
66+ "lib": ["es2020"], // JS standard library
77+ "sourceMap": true, // Optional, useful for debugging
88+ "rootDir": "src", // Source TypeScript files
99+ "strict": true, // Enable strict type checking
1010+ "esModuleInterop": true, // Needed for importing some modules
1111+ "resolveJsonModule": true, // Optional, for importing JSON
1212+ "skipLibCheck": true // Skip checking node_modules types
1313+ },
1414+ "include": ["src"],
1515+ "exclude": ["node_modules", "out"]
1616+}