Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ignore root folder setting #1065

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/foam-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,13 @@
],
"description": "Specifies the list of globs that will be ignored by Foam (e.g. they will not be considered when creating the graph). To ignore the all the content of a given folder, use `<folderName>/**/*`"
},
"foam.rootFolders.ignore": {
"type": [
"array"
],
"default": [],
"description": "Specifies the list of folders that will be ignored by Foam (e.g. they will not be considered when creating the graph). This is useful in multi-root workspaces."
},
"foam.logging.level": {
"type": "string",
"default": "info",
Expand Down
10 changes: 8 additions & 2 deletions packages/foam-vscode/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { Logger } from './core/utils/log';

import { features } from './features';
import { VsCodeOutputLogger, exposeLogger } from './services/logging';
import { getIgnoredFilesSetting } from './settings';
import {
getIgnoredFilesSetting,
getIgnoredRootFoldersSetting,
} from './settings';
import { fromVsCodeUri, toVsCodeUri } from './utils/vsc-utils';
import { AttachmentResourceProvider } from './core/services/attachment-provider';
import { VsCodeWatcher } from './services/watcher';
Expand All @@ -26,8 +29,11 @@ export async function activate(context: ExtensionContext) {
const readFile = async (uri: URI) =>
(await workspace.fs.readFile(toVsCodeUri(uri))).toString();
const dataStore = new FileDataStore(readFile);
const ignoredRoots = getIgnoredRootFoldersSetting();
const matcher = new Matcher(
workspace.workspaceFolders.map(dir => fromVsCodeUri(dir.uri)),
workspace.workspaceFolders
.filter(dir => !ignoredRoots.includes(dir.name))
.map(dir => fromVsCodeUri(dir.uri)),
['**/*'],
getIgnoredFilesSetting().map(g => g.toString())
);
Expand Down
5 changes: 5 additions & 0 deletions packages/foam-vscode/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export function getIgnoredFilesSetting(): GlobPattern[] {
];
}

/** Retrieve the list of root folders to ignore. */
export function getIgnoredRootFoldersSetting(): string[] {
return [...workspace.getConfiguration().get('foam.rootFolders.ignore', [])];
}

/** Retrieves the maximum length for a Graph node title. */
export function getTitleMaxLength(): number {
return workspace.getConfiguration('foam.graph').get('titleMaxLength');
Expand Down