How iosonntag/obsidian-plugin-treefocus works
TreeFocus is an Obsidian plugin that assigns each file-explorer item a focus mode, then applies a selected visual preset. The main workflow starts with Obsidian lifecycle and file events, continues through refresh and mode evaluation, and ends by tagging explorer elements for styling. Users configure rules and presets in settings or set per-item overrides from the context menu. The README documents these capabilities; unsampled implementation details are represented only where the tree supports a path, and edges are limited to shown calls or documented behavior.
Main entry points: tree-focus.ts Refresh coordinator · settings-view.ts Settings editor · mode-evaluation-service.ts Mode evaluation · plugin-settings.ts Plugin settings
Components 18
Plugin entry
- Plugin events
main.ts
Focus workflow
- Refresh coordinator
src/core/tree-focus.ts - Explorer traversal
src/util/file-explorer-helper.ts - Mode evaluation
src/services/mode-evaluation-service.ts - Element styling
src/util/css-tool.ts
Settings and rules
- Settings editor
src/views/settings-view.ts - Settings tab UI
src/enhanced-obsidian-components/obsidian-settings-tab.ts - Plugin settings
src/core/plugin-settings.ts - Settings persistence
src/services/plugin-data-store.ts - Default settings
src/_config/initial-settings.ts - Rule matching
src/util/rules-helper.ts - Rule definitions
src/types/matching-rules.ts - Focus modes
src/types/general.ts
Shared utilities
- Logging
src/util/logger.ts - Plugin errors
src/util/error-helper.ts - Error details
src/core/plugin-strings.ts - Plugin metadata
src/core/plugin-info.ts
Other components
- Obsidian
Connections 24
- Obsidian → Plugin events: fires lifecycle events
main.ts - Plugin events → Refresh coordinator: initializes and dispatches
main.ts - Plugin events → Settings editor: registers settings tab
main.ts - Refresh coordinator → Settings persistence: initializes with defaults
src/core/tree-focus.ts - Refresh coordinator → Default settings: supplies defaults
src/core/tree-focus.ts - Refresh coordinator → Settings editor: creates settings view
src/core/tree-focus.ts - Refresh coordinator → Explorer traversal: traverses items
src/core/tree-focus.ts - Refresh coordinator → Mode evaluation: evaluates each item
src/core/tree-focus.ts - Refresh coordinator → Element styling: applies mode attributes
src/core/tree-focus.ts - Refresh coordinator → Plugin settings: reads overrides and preset
src/core/tree-focus.ts - Settings editor → Settings tab UI: extends settings UI
src/views/settings-view.ts - Settings editor → Plugin settings: updates rules and presets
src/views/settings-view.ts - Refresh coordinator → Plugin settings: writes item overrides
src/core/tree-focus.ts - Mode evaluation → Plugin settings: reads overrides and rules
src/services/mode-evaluation-service.ts - Mode evaluation → Rule matching: validates and matches
src/services/mode-evaluation-service.ts - Rule matching → Rule definitions: uses rule shape
- Mode evaluation → Focus modes: returns focus mode
src/services/mode-evaluation-service.ts - Settings editor → Rule definitions: edits matching rules
src/views/settings-view.ts - Settings editor → Focus modes: edits focus modes
src/views/settings-view.ts - Refresh coordinator → Logging: logs refresh activity
src/core/tree-focus.ts - Plugin errors → Error details: appends bug details
src/util/error-helper.ts - Plugin errors → Logging: logs appendix failure
src/util/error-helper.ts - Error details → Plugin metadata: reads plugin metadata
src/core/plugin-strings.ts - Plugin metadata → Plugin errors: uses error helper
src/core/plugin-info.ts