config

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

lsp-markdown.el (4135B)


      1 ;;; lsp-markdown.el --- lsp-mode markdown integration -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2021 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 unified-language-server
     24 
     25 ;;; Code:
     26 
     27 (require 'lsp-mode)
     28 
     29 ;;; Markdown
     30 (defgroup lsp-markdown nil
     31   "Settings for the markdown language server client."
     32   :group 'lsp-mode
     33   :link '(url-link "https://github.com/unifiedjs/unified-language-server")
     34   :package-version '(lsp-mode . "8.0.0"))
     35 
     36 (defcustom lsp-markdown-server-command "unified-language-server"
     37   "The binary (or full path to binary) which executes the server."
     38   :type 'string
     39   :group 'lsp-markdown
     40   :package-version '(lsp-mode . "8.0.0"))
     41 
     42 (defcustom lsp-markdown-server-command-args '("--parser=remark-parse" "--stdio")
     43   "Command-line arguments for the markdown lsp server."
     44   :type '(repeat 'string)
     45   :group 'lsp-markdown
     46   :package-version '(lsp-mode . "8.0.0"))
     47 
     48 (defcustom lsp-markdown-remark-plugins [["#remark-preset-lint-markdown-style-guide"]]
     49   "The JSON configuration object for plugins.
     50 
     51 For a complete list of plugins, check:
     52  https://github.com/unifiedjs/unified-language-server/blob/main/CONFIGURATION.md#re-using-settings"
     53   :type 'lsp-string-vector
     54   :group 'lsp-markdown
     55   :package-version '(lsp-mode . "8.0.0"))
     56 
     57 (defcustom lsp-markdown-remark-check-text-with-setting "retext-english"
     58   "Configure `checkTextWith' subproperty.
     59 
     60 For a complete list of plugins, check:
     61  https://github.com/unifiedjs/unified-language-server/blob/main/CONFIGURATION.md#re-using-settings"
     62   :type '(choice (
     63                   (const "retext-english")
     64                   (const "remark-parse")))
     65   :group 'lsp-markdown
     66   :package-version '(lsp-mode . "8.0.0"))
     67 
     68 (defcustom lsp-markdown-remark-check-text-with-mutator ["#remark-retext" "#parse-latin"]
     69   "Vector of additional mutators.
     70 
     71 For a complete list of plugins, check:
     72  https://github.com/unifiedjs/unified-language-server/blob/main/CONFIGURATION.md#re-using-settings"
     73   :type 'lsp-string-vector
     74   :group 'lsp-markdown
     75   :package-version '(lsp-mode . "8.0.0"))
     76 
     77 (lsp-dependency 'unified-language-server
     78                 '(:system "unified-language-server")
     79                 '(:npm :package "unified-language-server"
     80                        :path "unified-language-server"))
     81 
     82 (lsp-register-custom-settings
     83  `(("unified-language-server.remark-parse.plugins" lsp-markdown-remark-plugins)
     84    ("unified-language-server.remark-parse.checkTextWith.setting" lsp-markdown-remark-check-text-with-setting)
     85    ("unified-language-server.remark-parse.checkTextWith.mutator" lsp-markdown-remark-check-text-with-mutator)))
     86 
     87 (lsp-register-client
     88  (make-lsp-client :new-connection (lsp-stdio-connection
     89                                    (lambda ()
     90                                      (cons (or (executable-find lsp-markdown-server-command)
     91                                                (lsp-package-path 'unified-language-server))
     92                                            lsp-markdown-server-command-args)))
     93                   :activation-fn (lsp-activate-on "markdown")
     94                   :initialized-fn (lambda (workspace)
     95                                     (with-lsp-workspace workspace
     96                                       (lsp--set-configuration (lsp-configuration-section "unified-language-server"))))
     97                   :priority -1
     98                   :server-id 'unified))
     99 
    100 (lsp-consistency-check lsp-markdown)
    101 
    102 (provide 'lsp-markdown)
    103 ;;; lsp-markdown.el ends here