aboutsummaryrefslogtreecommitdiffstats
path: root/elpa/lsp-mode-20220505.630/lsp-markdown.el
blob: 08f1b2079b80c823dd95e9dd179542461ca033a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
;;; lsp-markdown.el --- lsp-mode markdown integration -*- lexical-binding: t; -*-

;; Copyright (C) 2021 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 unified-language-server

;;; Code:

(require 'lsp-mode)

;;; Markdown
(defgroup lsp-markdown nil
  "Settings for the markdown language server client."
  :group 'lsp-mode
  :link '(url-link "https://github.com/unifiedjs/unified-language-server")
  :package-version '(lsp-mode . "8.0.0"))

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

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

(defcustom lsp-markdown-remark-plugins [["#remark-preset-lint-markdown-style-guide"]]
  "The JSON configuration object for plugins.

For a complete list of plugins, check:
 https://github.com/unifiedjs/unified-language-server/blob/main/CONFIGURATION.md#re-using-settings"
  :type 'lsp-string-vector
  :group 'lsp-markdown
  :package-version '(lsp-mode . "8.0.0"))

(defcustom lsp-markdown-remark-check-text-with-setting "retext-english"
  "Configure `checkTextWith' subproperty.

For a complete list of plugins, check:
 https://github.com/unifiedjs/unified-language-server/blob/main/CONFIGURATION.md#re-using-settings"
  :type '(choice (
                  (const "retext-english")
                  (const "remark-parse")))
  :group 'lsp-markdown
  :package-version '(lsp-mode . "8.0.0"))

(defcustom lsp-markdown-remark-check-text-with-mutator ["#remark-retext" "#parse-latin"]
  "Vector of additional mutators.

For a complete list of plugins, check:
 https://github.com/unifiedjs/unified-language-server/blob/main/CONFIGURATION.md#re-using-settings"
  :type 'lsp-string-vector
  :group 'lsp-markdown
  :package-version '(lsp-mode . "8.0.0"))

(lsp-dependency 'unified-language-server
                '(:system "unified-language-server")
                '(:npm :package "unified-language-server"
                       :path "unified-language-server"))

(lsp-register-custom-settings
 `(("unified-language-server.remark-parse.plugins" lsp-markdown-remark-plugins)
   ("unified-language-server.remark-parse.checkTextWith.setting" lsp-markdown-remark-check-text-with-setting)
   ("unified-language-server.remark-parse.checkTextWith.mutator" lsp-markdown-remark-check-text-with-mutator)))

(lsp-register-client
 (make-lsp-client :new-connection (lsp-stdio-connection
                                   (lambda ()
                                     (cons (or (executable-find lsp-markdown-server-command)
                                               (lsp-package-path 'unified-language-server))
                                           lsp-markdown-server-command-args)))
                  :activation-fn (lsp-activate-on "markdown")
                  :initialized-fn (lambda (workspace)
                                    (with-lsp-workspace workspace
                                      (lsp--set-configuration (lsp-configuration-section "unified-language-server"))))
                  :priority -1
                  :server-id 'unified))

(lsp-consistency-check lsp-markdown)

(provide 'lsp-markdown)
;;; lsp-markdown.el ends here