@mdx-js/language-server

0.4.2 • Public • Published

@mdx-js/language-server

Build Coverage Downloads Sponsors Backers Chat

A language server for MDX.

Contents

What is this?

This package provides a language server for MDX. The language server provides editor support based on Volar. This includes support for TypeScript as well as some MDX specific features.

When should I use this?

You can use this package if you want to enhance your editor for MDX files with features such as autocomplete and error diagnostics. Some editors can consume this package directly, others need a plugin in order to consume this package.

Install

In Node.js (version 16+), install with npm:

npm install @mdx-js/language-server

Use

How to use this package depends on your editor integration.

This package provides the mdx-language-server CLI. Because this is based on vscode-languageserver, the same transports are supported.

Language server features

This language server supports all features supported by volar-service-markdown and volar-service-typescript, plus some additional features specific to MDX.

Initialize Options

MDX language server supports the following LSP initialization options:

  • typescript.enabled (boolean, default: false) — If true, enable TypeScript.
  • typescript.tsdk (string, required) — The path from which to load TypeScript.
  • locale (string, optional) — The locale to use for TypeScript error messages.

Configuration

MDX language server supports the following LSP configuration options:

  • mdx.trace.server.verbosity ("off" | "messages" | "compact" | "verbose", default: "off") — Trace MDX language server requests in the output console.
  • mdx.trace.server.format ("text" | "json", default: "text") — How to format traced MDX language server requests.
  • mdx.validate.validateReferences ("ignore" | "hint" | "warning" | "error", default: "warning") — Diagnostic level for invalid reference links, e.g. [text][no-such-ref].
  • mdx.validate.validateFragmentLinks ("ignore" | "hint" | "warning" | "error", default: "warning") — Diagnostic level for fragments links to headers in the current file that don’t exist, e.g. [text](#no-such-header)
  • mdx.validate.validateFileLinks ("ignore" | "hint" | "warning" | "error", default: "warning") — Diagnostic level for links to local files that don’t exist, e.g. [text](./no-such-file.png).
  • mdx.validate.validateMarkdownFileLinkFragments ("ignore" | "hint" | "warning" | "error", default: "warning") — Diagnostic level for the fragment part of links to other local markdown files , e.g. [text](./no-such-file.png).
  • mdx.validate.validateUnusedLinkDefinitions ("ignore" | "hint" | "warning" | "error", default: "warning") — Diagnostic level for link definitions that aren’t used anywhere. [never-used]: http://example.com.
  • mdx.validate.validateDuplicateLinkDefinitions ("ignore" | "hint" | "warning" | "error", default: "warning") — Diagnostic level for duplicate link definitions.
  • mdx.validate.ignoreLinks (Array<string>, optional) — Glob of links that should not be validated.

TypeScript

This extension offers type safety for MDX files based on TypeScript’s types in JSDoc. For MDX specific details, see the TypeScript section of the repository readme.

Plugins

For information on plugin support, see the Plugins section of the repository readme.

Examples

MDX language server can be integrated with any server that supports language servers. Does your editor support MDX language server, but is it not in this list? Feel free to add it.

Visual Studio Code

Use unifiedjs.vscode-mdx to use the MDX language server with Visual Studio Code.

Compatibility

Projects maintained by the unified collective are compatible with all maintained versions of Node.js. As of now, that is Node.js and 16.0+. Our projects sometimes work with older versions, but this is not guaranteed.

This project uses vscode-languageserver 9, which implements language server protocol 3.17.4. It should work anywhere where LSP 3.6.0 or later is implemented.

Security

This package provides IntelliSense for MDX files. Some IntelliSense features modify your source code, for example suggestions and automatic refactors. It is recommended to keep your source code under version control.

Contribute

See § Contribute on our website for ways to get started. See § Support for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

Sponsor

See § Sponsor on our site for how to help financially.

Vercel

Motif

HashiCorp

GitBook

Gatsby

Netlify

Coinbase

ThemeIsle

Expo

Boost Note

Markdown Space

Holloway


You?

Changelog

Detailed changes for each release are documented in CHANGELOG.md.

License

MIT © Remco Haszing

Package Sidebar

Install

npm i @mdx-js/language-server

Homepage

mdxjs.com

Weekly Downloads

154

Version

0.4.2

License

MIT

Unpacked Size

17.9 kB

Total Files

4

Last publish

Collaborators

  • remcohaszing
  • johno
  • timneutkens
  • wooorm