Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Language Service Package (@lapis-notes/language-service)

@lapis-notes/language-service owns first-party browser language-service providers that are too heavy for @lapis-notes/api or editor plugins. The shared API package owns the contracts and CodeMirror adapters; this package supplies concrete worker-backed providers.

Source: packages/language-service/src/

Providers

  • createMarkdownLanguageServiceProvider() starts a markdownlint Web Worker and returns a LanguageServiceProvider for single-document Markdown diagnostics and fix actions. The worker statically imports markdownlint runtime entry points so browser/PWA builds bundle them instead of leaving bare module specifiers for runtime resolution.
  • @lapis-notes/language-service/markdown exports the markdown provider factories so the external Markdown Lint plugin can import only markdownlint support without bundling unrelated providers.
  • createNativeMarkdownLanguageServiceProvider() creates a bridge-backed Markdown diagnostics provider over the shared desktop_ls_* invoke surface so first-party plugins can own native markdownlint registration without importing Electron host code directly.
  • createTypeScriptLanguageServiceProvider() starts a TypeScript Web Worker backed by the TypeScript language-service APIs and @typescript/vfs file-system helpers. It serves TypeScript diagnostics, completions, hover, and definition lookups for virtual documents.

Markdownlint browser and native providers now share a host-neutral runtime helper under src/markdownlint/. That helper owns:

  • shared markdownlint options and the custom MD018 replacement alias set
  • markdownlint issue -> diagnostic mapping
  • markdownlint issue -> code-action generation, including ignore-next-line and ignore-for-file actions
  • inline markdownlint suppression alias normalization for MD018
  • applyFixes(...)-based edit generation so markdownlint fixes preserve YAML frontmatter and edit the actual violation line instead of rewriting from the top of the file

Providers communicate through the serializable worker protocol exported by @lapis-notes/api. Requests carry virtual document URI, language id, version, text, position/range payloads, and global declaration snapshots. Providers do not receive App, EditorView, DOM nodes, vault files, or plugin instances.

Runtime Boundary

The default runtime ships Web Worker implementations for browser/PWA hosts. Electron desktop still owns the native/process-backed sidecar and desktop_ls_* IPC surface, but first-party plugins now consume the same shared markdownlint runtime helper through bridge-backed provider factories in this package instead of duplicating markdownlint mapping logic in the host shell. The exported worker providers remain authoritative for parity testing in Chromium.

Consumers

  • The external official Markdown Lint plugin registers the markdownlint provider for MarkdownViewType consumers when installed and enabled.
  • The Notebook plugin registers the TypeScript provider and contributes minimal notebook global declarations for lapis, Inputs, html, svg, Generators, and Promises.
  • Workspace TypeScript text views and notebook cell editors consume the shared CodeMirror adapters through app.languageServices.