# Language Server Protocol (LSP) Support for Markdown

**URL:** <https://talk.commonmark.org/t/language-server-protocol-lsp-support-for-markdown/3072>\
**Category:** Implementation\
**Created:** [February 6, 2019, 7:11pm UTC](https://talk.commonmark.org/t/language-server-protocol-lsp-support-for-markdown/3072 "2019-02-06T19:11:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![codytwinton](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/codytwinton/32/1496_2.png) [@codytwinton](https://talk.commonmark.org/u/codytwinton)\
**Post date:** [February 6, 2019, 7:11pm UTC](https://talk.commonmark.org/t/language-server-protocol-lsp-support-for-markdown/3072/1 "2019-02-06T19:11:42Z")

</div>

I was taking a look at the [LSP Spec](https://microsoft.github.io/language-server-protocol/specification) and I noticed [here](https://langserver.org) that CommonMark currently doesn’t support this protocol.

Is there anyone currently working on support for this?

---

<div class="post-metadata">

**Author:** ![ctietze](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/ctietze/32/1216_2.png) [@ctietze](https://talk.commonmark.org/u/ctietze)\
**Post date:** [February 11, 2020, 6:59am UTC](https://talk.commonmark.org/t/language-server-protocol-lsp-support-for-markdown/3072/2 "2020-02-11T06:59:10Z")

</div>

Here’s a couple of pointers.

I do know of one editor, [the Xi Editor project,](https://github.com/xi-editor/xi-editor/) that supports a client/server architecture.

In the “server” code, LSP is mentioned: [xi-editor/rust at master · xi-editor/xi-editor · GitHub](https://github.com/xi-editor/xi-editor/tree/master/rust)

And I know from testing that this editor does support Markdown. That happens through its component called “syntect”, where [Sublime Text/TextMate highlighting is used](https://github.com/xi-editor/syntect-resources/tree/0bd5ea9b49e9cfad89cc0d52a6a787f0a01dfddb/Packages/Markdown).

I’m not fluent in Rust, the programming language of the Xi Editor – but I do think that one could replace this Markdown parser with a CommonMark implementation. In fact, the Xi Editor does support syntax highlighting for Rust itself [via another extension in its core sans TextMate highlighting](https://github.com/xi-editor/xi-editor/tree/3169c041b8befff3384dc1cc8878128a9a837240/rust/experimental/lang), so there’s hope.

So if one combined [a Rust CommonMark implementation](https://github.com/commonmark/commonmark-spec/wiki/List-of-CommonMark-Implementations#rust) with this editor, you might end up with an LSP server for Markdown already 🤔

---

<div class="post-metadata">

**Author:** ![vas](https://cdn.commonmark.org/user_avatar/talk.commonmark.org/vas/32/1267_2.png) [@vas](https://talk.commonmark.org/u/vas)\
**Post date:** [February 15, 2020, 3:22am UTC](https://talk.commonmark.org/t/language-server-protocol-lsp-support-for-markdown/3072/3 "2020-02-15T03:22:35Z")

</div>

LSP is designed for programming languages, something Markdown/CommonMark is not\*. Markdown doesn’t have reserved words, identifiers or symbols\*\* needing auto-completion, method signatures for which help info can be displayed, etc. Okay, maybe LSP could still be useful to highlight syntax errors? Nope. In Markdown, _there is no such thing as a syntax error_. Every string of text is a valid Markdown document.

You’ll notice in the list of [implementations](https://microsoft.github.io/language-server-protocol/implementors/servers/) there is not one that isn’t a programming language.

* * *

\*though the complexity of the rules sometimes makes them feel like programming languages.

\*\*with the exception of Link Ref Definitions

---

<div class="post-metadata">

**Author:** ![rwols](https://cdn.commonmark.org/letter_avatar_proxy/v2/letter/r/919ad9/32.png) [@rwols](https://talk.commonmark.org/u/rwols)\
**Post date:** [August 21, 2020, 9:02am UTC](https://talk.commonmark.org/t/language-server-protocol-lsp-support-for-markdown/3072/4 "2020-08-21T09:02:53Z")

</div>

I disagree with @vas here and say that it makes sense to have a markdown server somewhere on github that editors can use.

1. Such a server can report syntax errors via `textDocument/publishDiagnostics`
2. Such a server can provide hover popup documentation via `textDocument/hover` about various markdown constructs
3. It can implement `textDocument/documentLink` to allow the user to click on a URL. This can be made smart by implementing it in such a way that even things like (foo)[1] work.
4. It can implement `textDocument/documentSymbol` to provide a sort of “table of contents” by collecting all the header titles.
