RepoMicrosoftMicrosoftpublished May 1, 2024seen 1w

microsoft/vscode-markdown-languageserver

TypeScript

Open original ↗

Captured source

source ↗

microsoft/vscode-markdown-languageserver

Language: TypeScript

License: MIT

Stars: 40

Forks: 7

Open issues: 4

Created: 2024-05-01T21:37:14Z

Pushed: 2026-06-13T01:21:40Z

Default branch: main

Fork: no

Archived: no

README:

Markdown Language Server

> ❗ Import This is still in development. While the language server is being used by VS Code, it has not yet been tested with other clients.

The Markdown language server powers VS Code's built-in markdown support, providing tools for writing and browsing Markdown files. It runs as a separate executable and implements the language server protocol.

This server uses the Markdown Language Service to implement almost all of the language features. You can use that library if you need a library for working with Markdown instead of a full language server.

Server capabilities

  • Folding of Markdown regions, block elements, and header sections.
  • Rename of headers and links across all Markdown files in the workspace.
  • Find all references to a file. Uses a custom markdown/getReferencesToFileInWorkspace message.
  • Organize link definitions source action.
  • Extract link to definition refactoring.
  • Updating links when a file is moved / renamed. Uses a custom markdown/getEditForFileRenames message.

Client requirements

Initialization options

The client can send the following initialization options to the server:

  • markdownFileExtensions Array file extensions that should be considered as Markdown. These should not include the leading .. For example: ['md', 'mdown', 'markdown'].

Settings

Clients may send a workspace/didChangeConfiguration notification to notify the server of settings changes. The server supports the following settings:

  • markdown
  • suggest
  • paths
  • enabled — Enable/disable path suggestions.
  • occurrencesHighlight
  • enabled — Enable/disable highlighting of link occurrences.
  • validate
  • enabled — Enable/disable all validation.
  • referenceLinks
  • enabled — Enable/disable validation of reference links: [text][ref]
  • fragmentLinks
  • enabled — Enable/disable validation of links to fragments in the current files: [text](#head)
  • fileLinks
  • enabled — Enable/disable validation of links to file in the workspace.
  • markdownFragmentLinks — Enable/disable validation of links to headers in other Markdown files. Use inherit to inherit the fragmentLinks setting.
  • ignoredLinks — Array of glob patterns for files that should not be validated.
  • unusedLinkDefinitions
  • enabled — Enable/disable validation of unused link definitions.
  • duplicateLinkDefinitions
  • enabled — Enable/disable validation of duplicated link definitions.

Custom requests

To support all of the features of the language server, the client needs to implement a few custom request types. The definitions of these request types can be found in [protocol.ts](./src/protocol.ts)

markdown/parse

Get the tokens for a Markdown file. Clients are expected to use Markdown-it for this.

We require that clients bring their own version of Markdown-it so that they can customize/extend Markdown-it.

markdown/fs/readFile

Read the contents of a file in the workspace.

markdown/fs/readDirectory

Read the contents of a directory in the workspace.

markdown/fs/stat

Check if a given file/directory exists in the workspace.

markdown/fs/watcher/create

Create a file watcher. This is needed for diagnostics support.

markdown/fs/watcher/delete

Delete a previously created file watcher.

markdown/findMarkdownFilesInWorkspace

Get a list of all markdown files in the workspace.

Contribute

The source code of the Markdown language server can be found in the VSCode repository at extensions/markdown-language-features/server.

File issues and pull requests in the VSCode GitHub Issues. See the document How to Contribute on how to build and run from source.

Most of the functionality of the server is located in libraries:

Excerpt shown — open the source for the full document.

Notability

notability 3.0/10

Routine tooling repo with low community traction.