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