npm package: @markdownkit/lsp
Description: Language Server Protocol implementation for Markdownkit - lint and format markdown with remark
Author: markdownkit
Latest version: 2.1.0

# Markdownkit Language Server

A Language Server Protocol (LSP) implementation for markdown files using [remark](https://github.com/remarkjs/remark).

## Features

- **Real-time linting** — Diagnostics from remark lint presets 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 `.mdd` files
- **MDD preview** — Generate professional HTML from `.mdd` content
- **Custom commands** — Autoformat, draft transform, MDD preview, MDD validate
- **Configuration** — Uses `.remarkrc` files
- **Multi-format support** — `.md`, `.mdx`, `.mdc`, `.mdd`

## Installation

```bash
npm install -g @markdownkit/lsp
```

## Usage

### With stdio (recommended for editors)

```bash
markdownkit-lsp --stdio
```

### Programmatic usage

```javascript
import { createMarkdownkitServer } from "@markdownkit/lsp";

createMarkdownkitServer();
```

### Processor access

```javascript
import { createDefaultProcessor } from "@markdownkit/lsp/processor";

const processor = createDefaultProcessor();
const result = await processor.process("# Hello World");
```

### MDD preview

```javascript
import { generateMddHtml } from "@markdownkit/lsp/mdd-preview";

const html = await generateMddHtml(mddContent);
```

## Custom LSP Commands

| Command                   | Arguments         | Description                                 |
| ------------------------- | ----------------- | ------------------------------------------- |
| `markdownkit.autoformat`  | `[text, options]` | Transform plain text → markdown             |
| `markdownkit.draft`       | `[text, options]` | NLP-enhanced rough text transformation      |
| `markdownkit.mddPreview`  | `[content]`       | Generate HTML preview from MDD content      |
| `markdownkit.mddValidate` | `[content]`       | Validate MDD document, return result object |

## Included Plugins

The default processor includes:

- `remark-gfm` — GitHub Flavored Markdown
- `remark-frontmatter` — YAML metadata
- `remark-mdc` — Markdown Components (Nuxt Content)
- `remark-mdd-document-structure` — MDD directive processing
- `remark-mdd-text-formatting` — MDD professional typography
- `remark-preset-lint-recommended` — Recommended lint rules
- `remark-preset-lint-consistent` — Consistency rules
- `remark-preset-lint-markdown-style-guide` — Style guide rules

## Editor Integration

### VS Code

Install the [Markdownkit extension](https://marketplace.visualstudio.com/items?itemName=markdownkit.mdk-vscode) which uses this server.

### Neovim

```lua
require('lspconfig').markdownkit_lsp.setup {
  cmd = { 'markdownkit-lsp', '--stdio' },
  filetypes = { 'markdown', 'mdx', 'mdc', 'mdd' },
}
```

### Emacs (lsp-mode)

```elisp
(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:

```javascript
export default {
  settings: {
    bullet: "-",
    emphasis: "_",
    strong: "*",
  },
  plugins: [
    "remark-gfm",
    "remark-frontmatter",
    "remark-preset-lint-recommended",
  ],
};
```

## License

MIT