Skip to content

Commit

Permalink
MDX support (#4141)
Browse files Browse the repository at this point in the history
* Base settings for mdx support

* chore: add new client to changelog and docs
  • Loading branch information
themkat authored Sep 14, 2023
1 parent 266945b commit 1f5afbd
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
* Drop support for emacs 26.3
* Add [https://github.com/rubocop/rubocop][RuboCop built-in language server]] for linting and formatting Ruby code.
* Add Move language server support.
* Add mdx support using [[https://github.com/mdx-js/mdx-analyzer/tree/main/packages/language-server][mdx-language-server]]
** Release 8.0.0
* Add ~lsp-clients-angular-node-get-prefix-command~ to get the Angular server from another location which is still has ~/lib/node_modules~ in it.
* Set ~lsp-clients-angular-language-server-command~ after the first connection to speed up subsequent connections.
Expand Down
66 changes: 66 additions & 0 deletions clients/lsp-mdx.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
;;; lsp-mdx.el --- lsp-mode mdx integration -*- lexical-binding: t; -*-

;; Copyright (C) 2023 lsp-mode maintainers

;; Author: lsp-mode maintainers
;; Keywords: languages

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; LSP client for mdx-analyzer language-server

;;; Code:

(require 'lsp-mode)

(defgroup lsp-mdx nil
"Settings for the mdx language server client."
:group 'lsp-mode
:link '(url-link "https://github.com/mdx-js/mdx-analyzer/tree/main/packages/language-server")
:package-version '(lsp-mode . "8.0.0"))

(defcustom lsp-mdx-server-command "mdx-language-server"
"The binary (or full path to binary) which executes the server."
:type 'string
:group 'lsp-mdx
:package-version '(lsp-mode . "8.0.0"))

(defcustom lsp-mdx-server-command-args '("--stdio")
"Command-line arguments for the mdx lsp server."
:type '(repeat 'string)
:group 'lsp-mdx
:package-version '(lsp-mode . "8.0.0"))

(lsp-dependency 'mdx-language-server
'(:system "mdx-language-server")
'(:npm :package "@mdx-js/language-server"
:path "mdx-language-server"))

(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection
(lambda ()
(cons (or (executable-find lsp-mdx-server-command)
(lsp-package-path 'mdx-language-server))
lsp-mdx-server-command-args)))
:activation-fn (lambda (&rest _args)
(string-match-p "\\.mdx\\'" (buffer-file-name)))
:priority -2
:server-id 'mdx-analyzer
:download-server-fn (lambda (_client callback error-callback _update?)
(lsp-package-ensure 'mdx-language-server callback error-callback))))

(provide 'lsp-mdx)
;;; lsp-mdx.el ends here
8 changes: 8 additions & 0 deletions docs/lsp-clients.json
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,14 @@
"installation-url": "https://github.com/move-language/move/tree/main/language/move-analyzer",
"debugger": "Not available"
},
{
"name": "mdx",
"full-name": "mdx",
"server-name": "mdx-analyzer",
"server-url": "https://github.com/mdx-js/mdx-analyzer/tree/main/packages/language-server",
"installation": "npm install -g @mdx-js/language-server",
"debugger": "Not available"
},
{
"name": "nginx",
"full-name": "Nginx",
Expand Down
3 changes: 2 additions & 1 deletion lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ As defined by the Language Server Protocol 3.16."
lsp-erlang lsp-eslint lsp-fortran lsp-fsharp lsp-gdscript lsp-go lsp-gleam
lsp-glsl lsp-graphql lsp-hack lsp-grammarly lsp-groovy lsp-haskell lsp-haxe
lsp-idris lsp-java lsp-javascript lsp-json lsp-kotlin lsp-latex lsp-ltex
lsp-lua lsp-markdown lsp-marksman lsp-mint lsp-move lsp-nginx lsp-nim lsp-nix lsp-magik
lsp-lua lsp-markdown lsp-marksman lsp-mdx lsp-mint lsp-move lsp-nginx lsp-nim lsp-nix lsp-magik
lsp-metals lsp-mssql lsp-ocaml lsp-openscad lsp-pascal lsp-perl lsp-perlnavigator
lsp-pls lsp-php lsp-pwsh lsp-pyls lsp-pylsp lsp-pyright lsp-python-ms lsp-purescript
lsp-r lsp-racket lsp-remark lsp-ruff-lsp lsp-rf lsp-rubocop lsp-rust lsp-semgrep lsp-shader
Expand Down Expand Up @@ -771,6 +771,7 @@ Changes take effect only when a new session is started."
("\\.jsonc$" . "jsonc")
("\\.jsx$" . "javascriptreact")
("\\.lua$" . "lua")
("\\.mdx\\'" . "mdx")
("\\.php$" . "php")
("\\.rs\\'" . "rust")
("\\.sql$" . "sql")
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ nav:
- Markdown: page/lsp-markdown.md
- Marksman: page/lsp-marksman.md
- Move: page/lsp-move.md
- MDX: page/lsp-mdx.md
- MSSQL: https://emacs-lsp.github.io/lsp-mssql
- Nginx: page/lsp-nginx.md
- Nim: page/lsp-nim.md
Expand Down

0 comments on commit 1f5afbd

Please sign in to comment.