MCPcopy
hub / github.com/foambubble/foam / activate

Function activate

packages/foam-vscode/src/extension.ts:25–158  ·  view source on GitHub ↗
(context: ExtensionContext)

Source from the content-addressed store, hash-verified

23declare const __CORE_VERSION__: string;
24
25export async function activate(context: ExtensionContext) {
26 const logger = new VsCodeOutputLogger();
27 Logger.setDefaultLogger(logger);
28 exposeLogger(context, logger);
29
30 Config.setDefaultConfig(new VsCodeFoamConfig());
31 try {
32 const telemetry = initTelemetry({
33 foamVersion: __FOAM_VSCODE_VERSION__,
34 coreVersion: __CORE_VERSION__,
35 });
36 context.subscriptions.push(telemetry);
37 telemetry.trackSession();
38
39 Logger.info('Starting Foam');
40
41 if (workspace.workspaceFolders === undefined) {
42 Logger.info('No workspace open. Foam will not start');
43 return;
44 }
45
46 context.subscriptions.push(
47 window.onDidChangeActiveTextEditor((editor: TextEditor | undefined) => {
48 if (editor?.document.languageId === 'markdown') {
49 telemetry.trackNoteOpened();
50 }
51 })
52 );
53
54 // Prepare Foam
55 const includes = Config.getFilesInclude();
56 const excludes = Config.getFilesExclude();
57 const { matcher, dataStore, includePatterns, excludePatterns } =
58 await createMatcherAndDataStore(includes, excludes);
59
60 Logger.info('Loading from directories:');
61 for (const folder of workspace.workspaceFolders) {
62 Logger.info('- ' + folder.uri.fsPath);
63 Logger.info(' Include: ' + includePatterns.get(folder.name).join(','));
64 Logger.info(' Exclude: ' + excludePatterns.get(folder.name).join(','));
65 }
66
67 const watcher = new VsCodeWatcher(
68 workspace.createFileSystemWatcher('**/*'),
69 workspace.onDidSaveTextDocument
70 );
71 const parserCache = new VsCodeBasedParserCache(context);
72 const parser = createMarkdownParser([], parserCache);
73
74 const notesExtensions = Config.getNotesExtensions();
75 const defaultExtension = Config.getDefaultNoteExtension();
76
77 const workspaceRoots =
78 workspace.workspaceFolders?.map(folder => fromVsCodeUri(folder.uri)) ?? [];
79
80 const directoryMode = Config.getLinksDirectoryMode();
81 const markdownProvider = new MarkdownResourceProvider(
82 dataStore,

Callers

nothing calls this directly

Calls 15

clearMethod · 0.95
exposeLoggerFunction · 0.90
initTelemetryFunction · 0.90
createMarkdownParserFunction · 0.90
fromVsCodeUriFunction · 0.90
bootstrapFunction · 0.90
getDailyNoteTemplateUriFunction · 0.90
getTemplatesFunction · 0.90
setDefaultLoggerMethod · 0.80
setDefaultConfigMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected