Skip to content

A language server to lint and format markdown files with remark

License

Notifications You must be signed in to change notification settings

remarkjs/remark-language-server

Repository files navigation

remark-language-server

Build Downloads Sponsors Backers Chat

A language server to lint and format markdown files with remark.

Contents

What is this?

This package is a language server which can lint and format markdown files using remark.

When should I use this?

You can use this package when you want to enhance your editor with linting and formatting of markdown files. Some editors can consume this package directly, others need a plugin in order to consume this package.

Install

This package is ESM only. In Node.js (version 16.0+, or 18.0+), install with npm:

npm install remark-language-server

Use

Usage of this package depends on your editor integration. Because this is based on unified-languageserver-node, the same features are supported.

Configuration file

remark-language-server uses the same configuration files as remark-cli. These files are:

  • .remarkrc
  • .remarkrc.cjs
  • .remarkrc.js
  • .remarkrc.json
  • .remarkrc.mjs
  • .remarkrc.yaml
  • .remarkrc.yml
  • package.json

Language clients should notify the language server if these files change. They are looked up starting at the folder where the checked markdown file exists.

Settings

This language server supports the following settings:

  • remark.requireConfig (boolean, default: false) — If true, only perform actions if a configuration file is found.

Examples

Emacs

Use lsp-mode to use the remark language server with Emacs.

Neovim

The remark language server is part of nvim-lspconfig, a collection of common configurations for Neovim’s built-in language server client. This means you can add remark language server in one line:

require'lspconfig'.remark_ls.setup {
  settings = {
    remark = {
      requireConfig = true
    }
  }
}

nvim-lspconfig has detailed installation instructions such as configuration options.

vim-lsp

The remark language server can be used with vim-lsp. You can configure it to be started when a markdown file is opened.

if (executable('remark-language-server'))
  au User lsp_setup call lsp#register_server({
  \ 'name': 'remark',
  \ 'cmd': {server_info->['remark-language-server', '--stdio']},
  \ 'allowlist': ['markdown'],
  \ 'config': lsp_settings#get('remark-language-server', 'config', lsp_settings#server_config('remark-language-server')),
  \ 'workspace_config': lsp_settings#get('remark-language-server', 'workspace_config', {
  \   'requireConfig': v:true,
  \ }),
  \ })
endif

Otherwise, if you use vim-lsp-settings, you will be asked to use the remark language server automatically when a markdown file is opened.

Visual Studio Code

Use vscode-remark to use the remark 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 16.0+, and 18.0+. Our projects sometimes work with older versions, but this is not guaranteed.

Contribute

See contributing.md in remarkjs/.github for ways to get started. See support.md for ways to get help. Join us in Discussions to chat with the community and contributors.

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

License

MIT © Remco Haszing