├── .editorconfig ├── .github └── workflows │ ├── bb.yml │ └── main.yml ├── .gitignore ├── .npmrc ├── .prettierignore ├── index.js ├── license ├── package.json ├── readme.md └── tsconfig.json /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /.github/workflows/bb.yml: -------------------------------------------------------------------------------- 1 | name: bb 2 | on: 3 | issues: 4 | types: [opened, reopened, edited, closed, labeled, unlabeled] 5 | pull_request_target: 6 | types: [opened, reopened, edited, closed, labeled, unlabeled] 7 | jobs: 8 | main: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: unifiedjs/beep-boop-beta@main 12 | with: 13 | repo-token: ${{secrets.GITHUB_TOKEN}} 14 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: main 2 | on: 3 | - pull_request 4 | - push 5 | jobs: 6 | main: 7 | name: ${{matrix.node}} 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v3 11 | - uses: actions/setup-node@v3 12 | with: 13 | node-version: ${{matrix.node}} 14 | - run: npm install 15 | - run: npm test 16 | strategy: 17 | matrix: 18 | node: 19 | - lts/gallium 20 | - node 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | *.tgz 3 | *.log 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /.npmrc: -------------------------------------------------------------------------------- 1 | package-lock=false 2 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | *.md 2 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import process from 'node:process' 3 | import {remark} from 'remark' 4 | import {createUnifiedLanguageServer} from 'unified-language-server' 5 | 6 | process.title = 'remark-language-server' 7 | 8 | createUnifiedLanguageServer({ 9 | configurationSection: 'remark', 10 | defaultProcessor: remark, 11 | ignoreName: '.remarkignore', 12 | packageField: 'remarkConfig', 13 | pluginPrefix: 'remark', 14 | processorName: 'remark', 15 | processorSpecifier: 'remark', 16 | rcName: '.remarkrc' 17 | }) 18 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2021 Remco Haszing 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "remark-language-server", 3 | "version": "3.0.0", 4 | "description": "Language server for markdown using remark", 5 | "license": "MIT", 6 | "keywords": [ 7 | "languageserver", 8 | "language server", 9 | "lsp", 10 | "cli", 11 | "markdown", 12 | "mdast", 13 | "remark", 14 | "unified" 15 | ], 16 | "repository": "remarkjs/remark-language-server", 17 | "bugs": "https://github.com/remarkjs/remark-language-serve/issues", 18 | "funding": { 19 | "type": "opencollective", 20 | "url": "https://opencollective.com/unified" 21 | }, 22 | "author": "Remco Haszing ", 23 | "contributors": [ 24 | "Titus Wormer (https://wooorm.com)" 25 | ], 26 | "type": "module", 27 | "bin": "index.js", 28 | "files": [ 29 | "index.js" 30 | ], 31 | "dependencies": { 32 | "remark": "^15.0.0", 33 | "unified-language-server": "^4.0.0" 34 | }, 35 | "devDependencies": { 36 | "prettier": "^3.0.0", 37 | "remark-cli": "^12.0.0", 38 | "remark-preset-wooorm": "^10.0.0", 39 | "type-coverage": "^2.0.0", 40 | "xo": "^0.58.0" 41 | }, 42 | "scripts": { 43 | "build": "tsc && type-coverage", 44 | "format": "remark . -qfo && prettier . -w --log-level warn && xo --fix", 45 | "test": "npm run build && npm run format" 46 | }, 47 | "prettier": { 48 | "tabWidth": 2, 49 | "useTabs": false, 50 | "singleQuote": true, 51 | "bracketSpacing": false, 52 | "semi": false, 53 | "trailingComma": "none" 54 | }, 55 | "xo": { 56 | "prettier": true 57 | }, 58 | "remarkConfig": { 59 | "plugins": [ 60 | "preset-wooorm" 61 | ] 62 | }, 63 | "typeCoverage": { 64 | "atLeast": 100, 65 | "detail": true, 66 | "strict": true, 67 | "ignoreCatch": true 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # remark-language-server 2 | 3 | [![Build][build-badge]][build] 4 | [![Downloads][downloads-badge]][downloads] 5 | [![Sponsors][sponsors-badge]][collective] 6 | [![Backers][backers-badge]][collective] 7 | [![Chat][chat-badge]][chat] 8 | 9 | A language server to lint and format markdown files with **[remark][]**. 10 | 11 | ## Contents 12 | 13 | * [What is this?](#what-is-this) 14 | * [When should I use this?](#when-should-i-use-this) 15 | * [Install](#install) 16 | * [Use](#use) 17 | * [Configuration file](#configuration-file) 18 | * [Settings](#settings) 19 | * [Examples](#examples) 20 | * [Emacs](#emacs) 21 | * [Neovim](#neovim) 22 | * [vim-lsp](#vim-lsp) 23 | * [Visual Studio Code](#visual-studio-code) 24 | * [Compatibility](#compatibility) 25 | * [Contribute](#contribute) 26 | * [License](#license) 27 | 28 | ## What is this? 29 | 30 | This package is a [language server][] which can lint and format markdown files 31 | using remark. 32 | 33 | ## When should I use this? 34 | 35 | You can use this package when you want to enhance your editor with linting and 36 | formatting of markdown files. 37 | Some editors can consume this package directly, others need a plugin in order to 38 | consume this package. 39 | 40 | ## Install 41 | 42 | This package is [ESM only][]. 43 | In Node.js (version 16.0+, or 18.0+), install with [npm][]: 44 | 45 | ```sh 46 | npm install remark-language-server 47 | ``` 48 | 49 | ## Use 50 | 51 | Usage of this package depends on your editor integration. 52 | Because this is based on 53 | [`unified-languageserver-node`][unified-languageserver-node], the same features 54 | are supported. 55 | 56 | ### Configuration file 57 | 58 | `remark-language-server` uses the same configuration files as 59 | [`remark-cli`][remark-cli]. 60 | These files are: 61 | 62 | * `.remarkrc` 63 | * `.remarkrc.cjs` 64 | * `.remarkrc.js` 65 | * `.remarkrc.json` 66 | * `.remarkrc.mjs` 67 | * `.remarkrc.yaml` 68 | * `.remarkrc.yml` 69 | * `package.json` 70 | 71 | Language clients should notify the language server if these files change. 72 | They are looked up starting at the folder where the checked markdown file 73 | exists. 74 | 75 | ### Settings 76 | 77 | This language server supports the following settings: 78 | 79 | * `remark.requireConfig` (`boolean`, default: `false`) — If true, only perform 80 | actions if a [configuration file][configuration-file] is found. 81 | 82 | ## Examples 83 | 84 | ### Emacs 85 | 86 | Use [`lsp-mode`][lsp-mode] to use the remark language server with Emacs. 87 | 88 | ### Neovim 89 | 90 | The remark language server is part of [`nvim-lspconfig`][nvim-lspconfig], a 91 | collection of common configurations for Neovim’s built-in language server 92 | client. 93 | This means you can add remark language server in one line: 94 | 95 | ```lua 96 | require'lspconfig'.remark_ls.setup { 97 | settings = { 98 | remark = { 99 | requireConfig = true 100 | } 101 | } 102 | } 103 | ``` 104 | 105 | `nvim-lspconfig` has 106 | [detailed installation instructions][nvim-lspconfig-instructions] such as 107 | configuration options. 108 | 109 | ### vim-lsp 110 | 111 | The remark language server can be used with [`vim-lsp`][vim-lsp]. 112 | You can configure it to be started when a markdown file is opened. 113 | 114 | ```viml 115 | if (executable('remark-language-server')) 116 | au User lsp_setup call lsp#register_server({ 117 | \ 'name': 'remark', 118 | \ 'cmd': {server_info->['remark-language-server', '--stdio']}, 119 | \ 'allowlist': ['markdown'], 120 | \ 'config': lsp_settings#get('remark-language-server', 'config', lsp_settings#server_config('remark-language-server')), 121 | \ 'workspace_config': lsp_settings#get('remark-language-server', 'workspace_config', { 122 | \ 'requireConfig': v:true, 123 | \ }), 124 | \ }) 125 | endif 126 | ``` 127 | 128 | Otherwise, if you use [`vim-lsp-settings`][vim-lsp-settings], you will be asked 129 | to use the remark language server automatically when a markdown file is opened. 130 | 131 | ### Visual Studio Code 132 | 133 | Use [`vscode-remark`][vscode-remark] to use the remark language server with 134 | Visual Studio Code. 135 | 136 | ## Compatibility 137 | 138 | Projects maintained by the unified collective are compatible with all maintained 139 | versions of Node.js. 140 | As of now, that is Node.js 16.0+, and 18.0+. 141 | Our projects sometimes work with older versions, but this is not guaranteed. 142 | 143 | ## Contribute 144 | 145 | See [`contributing.md`][contributing] in [`remarkjs/.github`][health] for ways 146 | to get started. 147 | See [`support.md`][support] for ways to get help. 148 | Join us in [Discussions][chat] to chat with the community and contributors. 149 | 150 | This project has a [code of conduct][coc]. 151 | By interacting with this repository, organization, or community you agree to 152 | abide by its terms. 153 | 154 | ## License 155 | 156 | [MIT][license] © [Remco Haszing][author] 157 | 158 | 159 | 160 | [build-badge]: https://github.com/remarkjs/remark-language-server/workflows/main/badge.svg 161 | 162 | [build]: https://github.com/remarkjs/remark-language-server/actions 163 | 164 | [configuration-file]: #configuration-file 165 | 166 | [downloads-badge]: https://img.shields.io/npm/dm/remark-language-server.svg 167 | 168 | [downloads]: https://www.npmjs.com/package/remark-language-server 169 | 170 | [esm only]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c 171 | 172 | [sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg 173 | 174 | [backers-badge]: https://opencollective.com/unified/backers/badge.svg 175 | 176 | [collective]: https://opencollective.com/unified 177 | 178 | [chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg 179 | 180 | [chat]: https://github.com/remarkjs/remark/discussions 181 | 182 | [health]: https://github.com/remarkjs/.github 183 | 184 | [contributing]: https://github.com/remarkjs/.github/blob/main/contributing.md 185 | 186 | [lsp-mode]: https://github.com/emacs-lsp/lsp-mode 187 | 188 | [support]: https://github.com/remarkjs/.github/blob/main/support.md 189 | 190 | [coc]: https://github.com/remarkjs/.github/blob/main/code-of-conduct.md 191 | 192 | [license]: https://github.com/remarkjs/remark-language-server/blob/main/license 193 | 194 | [author]: https://github.com/remcohaszing 195 | 196 | [npm]: https://docs.npmjs.com/cli/install 197 | 198 | [nvim-lspconfig]: https://github.com/neovim/nvim-lspconfig 199 | 200 | [nvim-lspconfig-instructions]: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#remark_ls 201 | 202 | [language server]: https://microsoft.github.io/language-server-protocol/ 203 | 204 | [remark]: https://github.com/remarkjs/remark 205 | 206 | [remark-cli]: https://github.com/remarkjs/remark/tree/main/packages/remark-cli 207 | 208 | [unified-languageserver-node]: https://github.com/unifiedjs/unified-language-server 209 | 210 | [vim-lsp]: https://github.com/prabirshrestha/vim-lsp 211 | 212 | [vim-lsp-settings]: https://github.com/mattn/vim-lsp-settings 213 | 214 | [vscode-remark]: https://github.com/remarkjs/vscode-remark 215 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": ["*.js"], 3 | "compilerOptions": { 4 | "allowJs": true, 5 | "allowSyntheticDefaultImports": true, 6 | "checkJs": true, 7 | "declaration": true, 8 | "lib": ["ES2020"], 9 | "module": "ES2020", 10 | "moduleResolution": "node", 11 | "noEmit": true, 12 | "skipLibCheck": true, 13 | "strict": true, 14 | "target": "ES2020" 15 | } 16 | } 17 | --------------------------------------------------------------------------------