A starter template for LazyVim. Refer to the documentation to get started.
This config includes a local Neovim bridge that streams unsaved Markdown buffer content to a preview server.
Contract source of truth in this repo: preview_bridge_contract_v1.md.
- Loader spec:
lua/plugins/preview-bridge.lua - Runtime module:
lua/preview_bridge.lua - Logic helpers:
lua/preview_bridge/logic.lua
:PreviewBridgeStatusshows enabled state, session id, workspace root, and tracked buffers.:PreviewBridgeDebugshows last skip reason, transport status, warning, and last payload details.:PreviewBridgeReconnectforces websocket reconnect (WS transport mode).:PreviewBridgeResubscribeforces websocket resubscribe (when enabled).:PreviewBridgeOpenroutes current markdown file to existing preview tab, or provides fallback URL.:PreviewBridgePushforces an immediate upsert for the current buffer.:PreviewBridgeCloseforces a close action for the current buffer.:PreviewBridgeEnableenables the bridge.:PreviewBridgeDisabledisables the bridge and closes tracked live buffers.
- If the browser updates only on save and live endpoint returns
item: null, run:PreviewBridgeStatusand:PreviewBridgeDebug. - If
tracked_buffers=0, verify the file resolves to a workspace-relative.mdpath that matches your configuredfile_filter. - If
last_transport_erroris set, verifycurlis available and the preview app is running onserver_url. - For monorepos or unusual workspace layouts, set
workspace_rootinlua/plugins/preview-bridge.lua.
- Set
transport = "ws"to enable websocket connection awareness. - WS write path is primary for
upsertandclosein WS mode. - HTTP fallback remains available for resilience when WS writes fail.
websocatmust be installed and available onPATHfor WS mode.- Browser owns preview subscriptions by default; plugin WS subscription signaling is optional.
- Plugin WS subscription signaling is disabled by default in WS mode.
- Set
ws_subscribe_enabled = trueto enable plugin subscribe/unsubscribe signaling. - Set
ws_write_enabled = falseto force HTTP writes even in WS transport mode. - Set
ws_write_http_fallback = falseto disable HTTP fallback for failed WS writes. :PreviewBridgeOpenusesPOST /api/preview/openand defaults to remote-safenotify_copyfallback.- Local payload guard mirrors server limits via
max_payload_bytes(default1000000).
transportmaps to contract transport mode (httpcanonical writes,wswebsocket lifecycle).server_urlmaps to HTTP endpoints under/api/preview/live,/api/preview/state, and/api/preview/live.ws_urlmaps to websocket endpoint (derived fromserver_urlto/preview-bridgewhen unset).ws_subscribe_enabledmaps to optional plugin-sidesubscribeandunsubscribesignaling.ws_write_enabledmaps to websocketupsertandclosewrites in WS mode.ws_write_http_fallbackmaps to optional HTTP fallback when WS write dispatch fails.browser_base_urlmaps to browser-visible URL base for open fallback links.open_fallback_modemaps to fallback strategy (notify_copy,system_open,custom_command).open_custom_commandmaps to shell command used whenopen_fallback_mode = "custom_command"and should include%URL%placeholder.max_payload_bytesmaps to client-side payload guard before WS/HTTP write dispatch.debounce_msmaps to typing update cadence forTextChangedandTextChangedIupserts.file_filterand path normalization map to your server's allowed markdown path policy (for examplecontent/**/*.mdorsagamd/notes/**/*.md).workspace_rootmaps to workspace-relative path resolution beforefilePathemission.
PreviewBridgeStatus and PreviewBridgeDebug include write counters (ws_writes_sent,
http_fallback_writes, ws_write_failures, payload_too_large_skips) for integration triage.