vscode-zoterolens/src/extension.ts

48 lines
1.7 KiB
TypeScript

import { commands, ExtensionContext, languages, HoverProvider, TextDocument, CancellationToken, Hover, MarkdownString, Position, ProviderResult, Uri, DecorationOptions, OverviewRulerLane, Range, window, workspace, WorkspaceConfiguration } from "vscode";
import { ZoteroCodeLensProvider } from "./zoteroCodeLensProvider";
import { openZoteroPDF, showInZotero } from "./commands";
import { activateDecorations } from "./decorations";
export function activate(context: ExtensionContext) {
// Register the command
let commandDisposable2 = commands.registerCommand(
"zoterolens.showInZotero",
showInZotero
);
let commandDisposable3 = commands.registerCommand(
"zoterolens.openZoteroPDF",
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"
};
const workspaceConfig: WorkspaceConfiguration = workspace.getConfiguration('zoterolens');
const enabledLens: any = workspaceConfig.get('lens.enabled');
const enabledDecoration: any = workspaceConfig.get('decoration.enabled');
// Register our CodeLens provider
if (enabledLens) {
let codeLensProviderDisposable = languages.registerCodeLensProvider(
docSelector,
new ZoteroCodeLensProvider()
);
// 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);
}
}
export function deactivate() { }