config

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

lsp-markdown.el (4112B)


      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 (const "retext-english")
     63                  (const "remark-parse"))
     64   :group 'lsp-markdown
     65   :package-version '(lsp-mode . "8.0.0"))
     66 
     67 (defcustom lsp-markdown-remark-check-text-with-mutator ["#remark-retext" "#parse-latin"]
     68   "Vector of additional mutators.
     69 
     70 For a complete list of plugins, check:
     71  https://github.com/unifiedjs/unified-language-server/blob/main/CONFIGURATION.md#re-using-settings"
     72   :type 'lsp-string-vector
     73   :group 'lsp-markdown
     74   :package-version '(lsp-mode . "8.0.0"))
     75 
     76 (lsp-dependency 'unified-language-server
     77                 '(:system "unified-language-server")
     78                 '(:npm :package "unified-language-server"
     79                        :path "unified-language-server"))
     80 
     81 (lsp-register-custom-settings
     82  `(("unified-language-server.remark-parse.plugins" lsp-markdown-remark-plugins)
     83    ("unified-language-server.remark-parse.checkTextWith.setting" lsp-markdown-remark-check-text-with-setting)
     84    ("unified-language-server.remark-parse.checkTextWith.mutator" lsp-markdown-remark-check-text-with-mutator)))
     85 
     86 (lsp-register-client
     87  (make-lsp-client :new-connection (lsp-stdio-connection
     88                                    (lambda ()
     89                                      (cons (or (executable-find lsp-markdown-server-command)
     90                                                (lsp-package-path 'unified-language-server))
     91                                            lsp-markdown-server-command-args)))
     92                   :activation-fn (lsp-activate-on "markdown")
     93                   :initialized-fn (lambda (workspace)
     94                                     (with-lsp-workspace workspace
     95                                       (lsp--set-configuration (lsp-configuration-section "unified-language-server"))))
     96                   :priority -1
     97                   :server-id 'unified))
     98 
     99 (lsp-consistency-check lsp-markdown)
    100 
    101 (provide 'lsp-markdown)
    102 ;;; lsp-markdown.el ends here