@markdownkit/lsp
v4.0.0
Published
Language Server Protocol implementation for Markdownkit - lint and format markdown with remark
Maintainers
Readme
Markdownkit Language Server
A Language Server Protocol (LSP) implementation for markdown files using remark.
Features
- Linting - remark-lint diagnostics on open/save (optionally as you type)
- Document formatting - Format on save or demand
- Code actions - Quick fixes for common issues
- MDD validation - Real-time frontmatter, directive, and document-type diagnostics for
.mddfiles - MDD preview - Generate professional HTML from
.mddcontent - Custom commands - Autoformat, draft transform, MDD preview, MDD validate
- Configuration - Uses
.remarkrcfiles - Multi-format support -
.md,.mdx,.mdc,.mdd
Installation
npm install -g @markdownkit/lspUsage
With stdio (recommended for editors)
markdownkit-lsp --stdioProgrammatic usage
import { createMarkdownkitServer } from "@markdownkit/lsp";
createMarkdownkitServer();MDD preview
import { generateMddHtml } from "@markdownkit/lsp/mdd-preview";
const html = await generateMddHtml(mddContent);Custom LSP Commands
| Command | Arguments | Description |
| -------------------------- | ------------------------------------------------------ | ----------------------------------------------------------------- |
| markdownkit.formatText | [text, { filePath, cwd, semanticBreaks, wrapWidth }] | Format markdown text with the shared markdownkit formatter |
| markdownkit.autoformat | [text, options] | Transform plain text → markdown |
| markdownkit.draft | [text, options] | NLP-enhanced rough text transformation |
| markdownkit.polish | [text, options] | Typography-only polish of existing markdown (nuclear-mode step 1) |
| markdownkit.mddPreview | [content, { filePath }] | Generate HTML preview from MDD content |
| markdownkit.mddValidate | [content, { strict }] | Validate MDD document, return result object |
| markdownkit.validateText | [text, { filePath }] | Diagnostics for arbitrary text using the file's rule set |
| markdownkit.lintDocument | [uri] | Re-validate an open document now; returns { errors, warnings } |
| markdownkit.oxlintFix | [filePath] | Run oxlint-mdx --fix on a saved file |
Diagnostics
.md/.mdx/.mdc: remark-lint via the project's.remarkrc*(or the markdownkit presets when none is found), plus oxlint-mdx for embedded code (on save, when@markdownkit/oxlint-mdxis installed in the project or alongside the server)..mdd: the canonical MDD validator (@markdownkit/remark-mdd/validator), exactly asmarkdownkit lintandmdd-validatereport, plus remark-lint through markdownkit's MDD-safe processor (no MDX/MDC parsing;[Placeholder]text is not reported as an undefined reference).
Diagnostics are published on open and on save; set markdownkit.lint.onType to also lint while typing (markdownkit.lint.delay debounces it).
Editor Integration
VS Code
Install the Markdownkit extension which uses this server.
Neovim
require('lspconfig').markdownkit_lsp.setup {
cmd = { 'markdownkit-lsp', '--stdio' },
filetypes = { 'markdown', 'mdx', 'mdc', 'mdd' },
}Emacs (lsp-mode)
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection '("markdownkit-lsp" "--stdio"))
:major-modes '(markdown-mode)
:server-id 'markdownkit-lsp))Configuration
Create a .remarkrc.js in your project:
export default {
settings: {
bullet: "-",
emphasis: "_",
strong: "*",
},
plugins: [
"remark-gfm",
"remark-frontmatter",
"remark-preset-lint-recommended",
],
};License
MIT
