config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

lsp-mdx.el (2561B)


      1 ;;; lsp-mdx.el --- lsp-mode mdx integration -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2023 lsp-mode maintainers
      4 
      5 ;; Author: lsp-mode maintainers
      6 ;; Keywords: languages
      7 
      8 ;; This program is free software; you can redistribute it and/or modify
      9 ;; it under the terms of the GNU General Public License as published by
     10 ;; the Free Software Foundation, either version 3 of the License, or
     11 ;; (at your option) any later version.
     12 
     13 ;; This program is distributed in the hope that it will be useful,
     14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 ;; GNU General Public License for more details.
     17 
     18 ;; You should have received a copy of the GNU General Public License
     19 ;; along with this program.  If not, see <https://www.gnu.org/licenses/>.
     20 
     21 ;;; Commentary:
     22 
     23 ;;  LSP client for mdx-analyzer language-server
     24 
     25 ;;; Code:
     26 
     27 (require 'lsp-mode)
     28 
     29 (defgroup lsp-mdx nil
     30   "Settings for the mdx language server client."
     31   :group 'lsp-mode
     32   :link '(url-link "https://github.com/mdx-js/mdx-analyzer/tree/main/packages/language-server")
     33   :package-version '(lsp-mode . "8.0.0"))
     34 
     35 (defcustom lsp-mdx-server-command "mdx-language-server"
     36   "The binary (or full path to binary) which executes the server."
     37   :type 'string
     38   :group 'lsp-mdx
     39   :package-version '(lsp-mode . "8.0.0"))
     40 
     41 (defcustom lsp-mdx-server-command-args '("--stdio")
     42   "Command-line arguments for the mdx lsp server."
     43   :type '(repeat 'string)
     44   :group 'lsp-mdx
     45   :package-version '(lsp-mode . "8.0.0"))
     46 
     47 (lsp-dependency 'mdx-language-server
     48                 '(:system "mdx-language-server")
     49                 '(:npm :package "@mdx-js/language-server"
     50                        :path "mdx-language-server"))
     51 
     52 (lsp-register-client
     53  (make-lsp-client :new-connection (lsp-stdio-connection
     54                                    (lambda ()
     55                                      (cons (or (executable-find lsp-mdx-server-command)
     56                                                (lsp-package-path 'mdx-language-server))
     57                                            lsp-mdx-server-command-args)))
     58                   :activation-fn (lambda (&rest _args)
     59                                    (string-match-p "\\.mdx\\'" (buffer-file-name)))
     60                   :priority -2
     61                   :server-id 'mdx-analyzer
     62                   :download-server-fn (lambda (_client callback error-callback _update?)
     63                                         (lsp-package-ensure 'mdx-language-server callback error-callback))))
     64 
     65 (provide 'lsp-mdx)
     66 ;;; lsp-mdx.el ends here