docs/internal/init-config-plan.md
Tracks the design in init-config-design.md. Plugin-side primitives (PTY, raw-ANSI virtual buffers, floating windows, treesitter, animation timers) are tracked in #1529.
~/.config/fresh/init.ts auto-loaded at startup via existing
load_plugin_from_source("init.ts", ...) pipeline.--safe (skip init.ts + plugins), --no-init (skip
init.ts only).~/.config/fresh/logs/init.crashes (3 failures /
300s rolling window → auto-skip on next launch).setSetting(path, value)Fire-and-forget into shared Config, matching Neovim/VS Code/Emacs/ Sublime (no editor tracks per-plugin setting writes). Patches Config via JSON round-trip with schema validation. Any plugin can call it; last write wins; writes persist until overwritten or editor restart.
editor.on(event, fn) closure overload via JS shim (alongside
the existing string-handler form).plugins_loaded (after all plugins + init.ts load)
and ready (after session restore, before event loop).exportPluginApi(name, api) / getPluginApi(name) backed by
Persistent<Object> shared across QuickJS contexts.Drop impl on QuickJsBackend clears persistents before runtime
teardown.editor.pluginName() accessor.init: Reload — re-runs init.ts via hot-reload; fires
plugins_loaded afterwards.fresh --cmd init check — oxc parse, line:col diagnostics,
non-zero exit on errors.FRESH_INTERACTIVE=1 set on process env for interactive launches.init: Edit init.ts — creates starter template if missing, opens
in buffer.init: Check init.ts — in-editor parse check via status bar.| Item | Notes |
|---|---|
Type scaffolding (copy fresh.d.ts + write tsconfig.json to ~/.config/fresh/types/) | Needed for IntelliSense in init.ts. High impact. |
types/fresh-config.d.ts generated from config-schema.json | Would type-check setSetting paths at compile time. |
Scope-discipline lints (unconditional-preference, unconditional-plugin-load) | Needs AST walker tracing data-flow from getEnv→setSetting. |
--strict mode for fresh --cmd init check (tsc --noEmit) | Small addition, gated on tsc availability. |
Per-plugin types (types/plugins/<name>.d.ts) auto-copied on install | Enables typed getPluginApi calls. |
init: Status palette command | Show what init.ts did (settings, hooks, commands). |
User docs (docs/configuration/init.md) | |
Plugin-author docs for exportPluginApi |
tests/e2e/plugins/init_script.rssrc/init_script.rs$TMUX detection; --no-init restores defaults)