vscode-zoterolens/src/extension.ts

48 lines
1.7 KiB
TypeScript
Raw Normal View History

2022-09-27 14:06:30 +02:00
import { commands, ExtensionContext, languages, HoverProvider, TextDocument, CancellationToken, Hover, MarkdownString, Position, ProviderResult, Uri, DecorationOptions, OverviewRulerLane, Range, window, workspace, WorkspaceConfiguration } from "vscode";
2022-02-14 21:37:52 +01:00
import { ZoteroCodeLensProvider } from "./zoteroCodeLensProvider";
2022-02-04 12:03:05 +01:00
import { openZoteroPDF, showInZotero } from "./commands";
2022-09-27 14:06:30 +02:00
import { activateDecorations } from "./decorations";
2022-02-04 12:03:05 +01:00
export function activate(context: ExtensionContext) {
// Register the command
let commandDisposable2 = commands.registerCommand(
2022-02-14 21:37:52 +01:00
"zoterolens.showInZotero",
2022-02-04 12:03:05 +01:00
showInZotero
);
let commandDisposable3 = commands.registerCommand(
2022-02-14 21:37:52 +01:00
"zoterolens.openZoteroPDF",
2022-02-04 12:03:05 +01:00
openZoteroPDF
);
// Get a document selector for the CodeLens provider
// This one is any file that has the language of javascript
let docSelector = {
language: "markdown",
scheme: "file"
};
2022-09-27 14:06:30 +02:00
const workspaceConfig: WorkspaceConfiguration = workspace.getConfiguration('zoterolens');
const enabledLens: any = workspaceConfig.get('lens.enabled');
const enabledDecoration: any = workspaceConfig.get('decoration.enabled');
2022-02-04 12:03:05 +01:00
// Register our CodeLens provider
2022-09-27 14:06:30 +02:00
if (enabledLens) {
let codeLensProviderDisposable = languages.registerCodeLensProvider(
docSelector,
new ZoteroCodeLensProvider()
);
2022-02-04 12:03:05 +01:00
2022-09-27 14:06:30 +02:00
// Push the command and CodeLens provider to the context so it can be disposed of later
context.subscriptions.push(commandDisposable2);
context.subscriptions.push(commandDisposable3);
context.subscriptions.push(codeLensProviderDisposable);
}
if (enabledDecoration) {
activateDecorations(context);
}
2022-02-14 21:37:52 +01:00
2022-02-04 12:03:05 +01:00
}
2022-09-27 14:06:30 +02:00
export function deactivate() { }