Skip to content

Commit 164097b

Browse files
committed
feat(vscode): add excludeFilePattern setting for file-level exclusion
Hide Obsidian files (.md, .base, .canvas) at partially-mounted vault levels via regex-driven files.exclude glob patterns scoped to the vault folder. Files matching the configurable excludeFilePattern regex are grouped by extension into {prefix}/*{ext} globs, keeping Explorer and Quick Open clean without affecting same-named files in other workspace folders. Non-matching files remain visible. Invalid regex degrades gracefully to no file exclusion. Assisted-by: Claude
1 parent ca13e3f commit 164097b

9 files changed

Lines changed: 332 additions & 59 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Style, file layout, patterns: [CONTRIBUTING.md#conventions](CONTRIBUTING.md#conv
3333
- **Single `file://` workspace folder at the vault root** for Quick Open (`Cmd+P`) and `Ctrl+Shift+F` search. VSCode's file discovery and ripgrep indexer only operate on `file://` workspace folders — `obs://` workspace folders provide zero discoverability (confirmed by spike, 2026-05-15).
3434
- **`files.exclude` patterns** hide non-autoMount vault content to match the Explorer tree view's visibility. Two-tier split: dotfiles + `blocked``ConfigurationTarget.WorkspaceFolder` (`<vault>/.vscode/settings.json`); non-autoMount dirs → `ConfigurationTarget.Workspace`. Tracked in `context.workspaceState`, cleaned up on change or disable.
3535
- **Sub-path exclusion** — when `autoMount` contains nested paths (e.g., `["20-areas/idea"]`), `files.exclude` patterns hide sibling directories (`20-areas/career`, `20-areas/otaviof`) to match tree view visibility. Computed via mount tree (`packages/core/src/mount-tree.ts`).
36+
- **File-level exclusion**`obsidianVFS.excludeFilePattern` provides a regex tested against file basenames at partially-mounted levels. Matching files generate `{prefix}/*{ext}` glob patterns in the folder-scoped `files.exclude` tier, hiding Obsidian files (`.md`, `.base`, `.canvas`) from Explorer and Quick Open without affecting same-named files in other workspace folders. Default: `\\.(md|base|canvas)$`.
3637
- **`obs://` FileSystemProvider** remains registered for the Explorer tree view sidebar, wikilinks, drag-and-drop, and watch events — it does not back a workspace folder.
3738
- **`FileSearchProvider`/`TextSearchProvider` are proposed (unstable) APIs** as of `@types/vscode@1.118.0`. When stabilized, the extension can switch to a single `obs://` workspace folder with native search, eliminating the `files.exclude` workaround. Check `@types/vscode` for stable availability — do not use while proposed.
3839

packages/vscode/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Configure via **Settings UI** or `settings.json`:
4949
| `obsidianVFS.explorer` | `boolean` | `true` | Show the Obsidian VFS tree view in the Explorer sidebar |
5050
| `obsidianVFS.statusBar` | `boolean` | `true` | Show vault name and mode in the status bar |
5151
| `obsidianVFS.workspace` | `boolean` | `true` | Add the vault as a workspace folder for Quick Open and Search (see below) |
52+
| `obsidianVFS.excludeFilePattern` | `string` | `\.(md\|base\|canvas)$` | Regex pattern tested against file basenames at partially-mounted vault levels. Matching files are hidden from Explorer via `files.exclude` glob patterns scoped to the vault folder. Covers Obsidian's three core formats by default. Set to empty string to disable. Examples: `\.(md\|base\|canvas\|pdf)$`, `^README`. |
5253
| `obsidianVFS.workspaceFile` | `boolean` | `false` | Generate a `.code-workspace` file named after the project folder. Eliminates the "Untitled (Workspace)" label. The file contains a `file://` vault folder entry; `files.exclude` patterns are written to its `settings` section. Opening the file triggers a one-time window reload. |
5354

5455
All three toggle settings (`explorer`, `statusBar`, `workspace`) take effect immediately — no reload required.

packages/vscode/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "obsidian-vfs",
33
"displayName": "Obsidian VFS",
44
"description": "Browse, search, and edit your Obsidian vault directly in VSCode via a virtual file system (obs://)",
5-
"version": "0.3.4",
5+
"version": "0.3.5",
66
"private": true,
77
"publisher": "otaviof",
88
"engines": {
@@ -131,6 +131,11 @@
131131
"default": true,
132132
"description": "Show vault name and mode in the status bar"
133133
},
134+
"obsidianVFS.excludeFilePattern": {
135+
"type": "string",
136+
"default": "\\.(md|base|canvas)$",
137+
"markdownDescription": "Regex pattern tested against file basenames (not including parent directories) at partially-mounted vault levels. Matching files are hidden from Explorer via `files.exclude` glob patterns scoped to the vault folder. Set to empty string to disable. Examples: `\\.(md|base|canvas|pdf)$` (with attachments), `\\.base$` (single extension), `^README` (by name prefix)."
138+
},
134139
"obsidianVFS.workspace": {
135140
"type": "boolean",
136141
"default": true,

packages/vscode/src/bootstrap.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as vscode from "vscode";
22
import { DEFAULT_TIMEOUT_MS, bootstrapTracker, resolveCliPath } from "@obsidian-vfs/core";
33
import type { BootstrapResult, VFSResult } from "@obsidian-vfs/core";
44

5-
import { CONFIG_SECTION } from "./types.js";
5+
import { CONFIG_SECTION, DEFAULT_EXCLUDE_FILE_PATTERN } from "./types.js";
66
import type { ExtensionConfig } from "./types.js";
77

88
/** Read extension configuration from VSCode settings. */
@@ -12,6 +12,7 @@ export function readConfig(): ExtensionConfig {
1212
cliPath: resolveCliPath({ userPath: cfg.get<string>("cliPath", "") }),
1313
timeoutMs: cfg.get<number>("timeoutMs", DEFAULT_TIMEOUT_MS),
1414
autoMount: cfg.get<string[]>("autoMount", []),
15+
excludeFilePattern: cfg.get<string>("excludeFilePattern", DEFAULT_EXCLUDE_FILE_PATTERN),
1516
explorer: cfg.get<boolean>("explorer", true),
1617
statusBar: cfg.get<boolean>("statusBar", true),
1718
workspace: cfg.get<boolean>("workspace", true),

0 commit comments

Comments
 (0)