The Problem
Obsidian’s native vault view cannot open, edit, or embed raw source files. Users who keep code alongside notes must switch to external editors, losing context and navigation features.
What This Does
The plugin supplies a full‑stack code workspace inside Obsidian.
src/dashboard_view.tsrenders the management space – a grid dashboard that lists vault code files and offers rename, move, delete, and external‑open actions.src/code_view.tsimplements the editing space with a CodeMirror 6 editor, syntax highlighting, outline navigation, and a search‑replace panel.src/code_embed.tsandsrc/outline_view.tsprovide the embedding space, exposing the![[file#L20-L40]]syntax and a clickable outline for jump‑to definitions.src/external_mount.tscreates mount space by linking external directories into the vault via OS symlinks.
All UI components are wired through the plugin entry point src/main.ts. The onload method registers commands, builds the dashboard, and injects the editor view. Settings are handled by src/settings.ts, while locale strings live under src/lang/locale/.
How It Is Wired
Obsidian loads the plugin and calls onload in src/main.ts (line 111). This routine:
- Calls
display(the most‑invoked function, 28 × fromdisplay -> t). displaybuilds the dashboard viabuildPanelContent, which creates UI elements (createOptionButton,createNavButton) and registers callbacks.- User actions (e.g., “Open file”) invoke
t– the translation helper fromsrc/lang/helpers.ts– which is imported by seven modules, making it the central utility.
src/code_view.ts (1064 LOC) houses the editor lifecycle: constructor → initCodeMirror → render → onChange. Each of these ultimately calls t for UI text and interacts with the filesystem through helpers in src/external_mount.ts (getFs, getPath).
The import graph shows six circular dependencies, the largest cycle linking src/main.ts, src/code_view.ts, and src/settings.ts. Because each module both imports and exports types used by the others, a change in any of them forces recompilation of the whole cycle and risks hidden runtime errors.
Responsibility snapshot (by call traffic):
| File | Core duties | External effect |
|---|---|---|
src/code_view.ts | editor UI, file read/write, outline generation | Reads/writes files (6 functions) |
src/external_mount.ts | OS‑level symlink creation, path resolution | Reads/writes files |
src/dashboard_view.ts | file list UI, bulk actions | Reads files |
src/dropdown.ts | generic dropdown component used by several views | UI only |
src/main.ts | plugin bootstrap, command registration | UI only |
src/settings.ts | settings panel, persistence | UI only |
How To Use It
# Clone the exact repo
git clone https://github.com/moses-y/Obsidian-CodeSpace
cd Obsidian-CodeSpace
# Install dependencies
npm ci
# Build the plugin (esbuild config present)
npm run build # assumes a "build" script in package.json
Copy the generated main.js (or the dist folder, per the build script) into an Obsidian vault’s <vault>/.obsidian/plugins/obsidian-codespace/. Enable the plugin in Obsidian’s community‑plugins settings. The plugin reads manifest.json for metadata and styles.css for UI styling; no additional environment variables are required.
Real‑World Use
A software‑engineer keeps a personal “dev‑notes” vault. With the plugin installed, they open a Python module directly from the dashboard, edit it with line numbers and auto‑indent, and embed a snippet in a markdown note using ![[utils.py#L10-L20]]. The embedded view updates automatically when the source file changes on disk.
Code Health & Issues
- High – Import cycles –
src/main.ts,src/code_view.ts,src/settings.tsform circular dependencies. - High – Deep nesting – Max indentation depth 7 in the same three files, making logic hard to follow.
- High – Duplicated blocks – Repeated 6‑line snippets across four files (
code_embed.ts,code_view.ts,dashboard_view.ts,main.ts). - Medium – Oversized file –
src/code_view.tsexceeds 1000 LOC, increasing change impact. - Medium – Branching density –
src/code_embed.tsandsrc/code_parser.tshave 182 branch points in 583 lines.
Additional SDLC findings (from the health audit):
- High – No test suite – 15 source files, zero test files.
- High – No CI pipeline – No
.github/workflowsor similar. - Medium – Dependabot missing – No automated dependency update config.
Four dependencies lag behind current major releases (@types/node, globals, typescript, @eslint/js).
The Bottom Line
The repository delivers a functional Obsidian plugin that brings IDE‑like code handling into the note‑taking workflow, with clear separation of dashboard, editor, and embed features. However, the codebase suffers from import cycles, deep nesting, and a lack of automated testing or CI, which raise maintenance risk for production use. It is suitable for teams comfortable with refactoring and adding test/CI scaffolding before extending the plugin.