Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarlevin committed Oct 14, 2024
1 parent f9d6899 commit 268574b
Show file tree
Hide file tree
Showing 12 changed files with 517 additions and 473 deletions.
50 changes: 25 additions & 25 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,31 +637,31 @@ export async function activate(context: vscode.ExtensionContext) {
// vscode.commands.registerCommand("pretext-tools.test", async () => {
// console.log("Running Experiment");
// utils.experiment(context);
// const editor = vscode.window.activeTextEditor;
// const document = editor?.document;
// const position = editor?.selection.active;
// if (document) {
// let labels = await utils.getReferences();
// console.log("Found labels: ", labels);
// }
// if (position) {
// const textUntilPosition = document?.getText(
// new vscode.Range(new vscode.Position(0, 0), position)
// );
// const openedTags = (
// textUntilPosition?.match(/<(\w)+(?![^>]*\/>)/g) || []
// ).map((tag) => tag.slice(1));
// const closedTags = (textUntilPosition?.match(/<\/\w+/g) || []).map(
// (tag) => tag.slice(2)
// );
// const unclosedTags = openedTags.filter(
// (tag) =>
// openedTags.filter(x => x === tag).length > closedTags.filter(x => x === tag).length
// );
// const currentTag = unclosedTags[unclosedTags.length - 1];
// console.log("Current XML Element: ", currentTag);
// }
//})
// const editor = vscode.window.activeTextEditor;
// const document = editor?.document;
// const position = editor?.selection.active;
// if (document) {
// let labels = await utils.getReferences();
// console.log("Found labels: ", labels);
// }
// if (position) {
// const textUntilPosition = document?.getText(
// new vscode.Range(new vscode.Position(0, 0), position)
// );
// const openedTags = (
// textUntilPosition?.match(/<(\w)+(?![^>]*\/>)/g) || []
// ).map((tag) => tag.slice(1));
// const closedTags = (textUntilPosition?.match(/<\/\w+/g) || []).map(
// (tag) => tag.slice(2)
// );
// const unclosedTags = openedTags.filter(
// (tag) =>
// openedTags.filter(x => x === tag).length > closedTags.filter(x => x === tag).length
// );
// const currentTag = unclosedTags[unclosedTags.length - 1];
// console.log("Current XML Element: ", currentTag);
// }
//})
//);
}

Expand Down
100 changes: 50 additions & 50 deletions src/lsp-client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,67 +8,67 @@ import * as vscode from "vscode";
import { workspace, ExtensionContext } from "vscode";

import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
TransportKind,
LanguageClient,
LanguageClientOptions,
ServerOptions,
TransportKind,
} from "vscode-languageclient/node";

let client: LanguageClient;

export function activate(context: ExtensionContext) {
// The server is implemented in node
const serverModule = context.asAbsolutePath(
path.join("out", "lsp-server.js")
);
// The debug options for the server
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
const debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] };
// The server is implemented in node
const serverModule = context.asAbsolutePath(
path.join("out", "lsp-server.js")
);
// The debug options for the server
// --inspect=6009: runs the server in Node's Inspector mode so VS Code can attach to the server for debugging
const debugOptions = { execArgv: ["--nolazy", "--inspect=6009"] };

// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
const serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: {
module: serverModule,
transport: TransportKind.ipc,
options: debugOptions,
},
};
// If the extension is launched in debug mode then the debug server options are used
// Otherwise the run options are used
const serverOptions: ServerOptions = {
run: { module: serverModule, transport: TransportKind.ipc },
debug: {
module: serverModule,
transport: TransportKind.ipc,
options: debugOptions,
},
};

// Options to control the language client
const clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: [{ scheme: "file", language: "pretext" }],
synchronize: {
// Notify the server about file changes to '.clientrc files contained in the workspace
//fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
},
markdown: { isTrusted: true },
};
// Options to control the language client
const clientOptions: LanguageClientOptions = {
// Register the server for plain text documents
documentSelector: [{ scheme: "file", language: "pretext" }],
synchronize: {
// Notify the server about file changes to '.clientrc files contained in the workspace
//fileEvents: workspace.createFileSystemWatcher('**/.clientrc')
},
markdown: { isTrusted: true },
};

// Create the language client and start the client.
client = new LanguageClient(
"pretextLanguageServer",
"PreTeXt Language Server",
serverOptions,
clientOptions
);
// Create the language client and start the client.
client = new LanguageClient(
"pretextLanguageServer",
"PreTeXt Language Server",
serverOptions,
clientOptions
);

//context.subscriptions.push(
// vscode.commands.registerCommand("myExtension.sayHello", () => {
// vscode.window.showWarningMessage("Hello!");
// })
//);
//context.subscriptions.push(
// vscode.commands.registerCommand("myExtension.sayHello", () => {
// vscode.window.showWarningMessage("Hello!");
// })
//);

// Start the client. This will also launch the server
client.start();
console.log("PreTeXt LSP Launched");
// Start the client. This will also launch the server
client.start();
console.log("PreTeXt LSP Launched");
}

export function deactivate(): Thenable<void> | undefined {
if (!client) {
return undefined;
}
return client.stop();
if (!client) {
return undefined;
}
return client.stop();
}
Loading

0 comments on commit 268574b

Please sign in to comment.