forked from emacs-lsp/lsp-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlsp-elm.el
104 lines (83 loc) · 3.64 KB
/
lsp-elm.el
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
104
;;; lsp-elm.el --- Elm Client settings -*- lexical-binding: t; -*-
;; Copyright (C) 2019 Daniel V
;; Author: Daniel V
;; Keywords: elm lsp
;; 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-elm client
;;; Code:
(require 'lsp-mode)
(defgroup lsp-elm nil
"LSP support for the Elm programming language, using the server from https://github.com/elm-tooling/elm-language-server"
:group 'lsp-mode
:link '(url-link "https://github.com/elm-tooling/elm-language-server"))
(defcustom lsp-elm-elm-language-server-path
"elm-language-server"
"Path for elm-language-server.
Can be installed globally with: npm i -g @elm-tooling/elm-language-server,
or manually by cloning the repo and following the installing instructions."
:group 'lsp-elm
:risky t
:type 'file)
(defcustom lsp-elm-trace-server
nil
"Enable/disable trace logging of client and server communication."
:type 'boolean
:group 'lsp-elm)
(defcustom lsp-elm-elm-path
""
"The path to your elm executable. Should be empty by default, in that case it will assume the name and try to first get it from a local npm installation or a global one. If you set it manually it will not try to load from the npm folder."
:type 'file
:group 'lsp-elm)
(defcustom lsp-elm-elm-format-path
""
"The path to your elm-format executable. Should be empty by default, in that case it will assume the name and try to first get it from a local npm installation or a global one. If you set it manually it will not try to load from the npm folder."
:type 'file
:group 'lsp-elm)
(defcustom lsp-elm-elm-test-path
""
"The path to your elm-test executable. Should be empty by default, in that case it will assume the name and try to first get it from a local npm installation or a global one. If you set it manually it will not try to load from the npm folder."
:type 'file
:group 'lsp-elm)
(defcustom lsp-elm-elm-analyse-trigger
"change"
"Elm-analyse executed on 'change', 'save' or 'never' (default: 'change')."
:type '(choice (const "change")
(const "save")
(const "never"))
:group 'lsp-elm)
(defcustom lsp-elm-server-args
'("--stdio")
"Arguments to pass to the server."
:type '(repeat string)
:group 'lsp-elm)
(defun lsp-elm--elm-language-server-command ()
"Generate LSP startup command for the Elm Language Server."
(cons
lsp-elm-elm-language-server-path
lsp-elm-server-args))
(defun lsp-clients-elm--make-init-options ()
"Init options for elm-language-server."
`(
:elmPath ,lsp-elm-elm-path
:elmFormatPath ,lsp-elm-elm-format-path
:elmTestPath ,lsp-elm-elm-test-path
:elmAnalyseTrigger ,lsp-elm-elm-analyse-trigger
:trace.server ,(lsp-json-bool lsp-elm-trace-server)))
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection #'lsp-elm--elm-language-server-command)
:major-modes '(elm-mode)
:priority -1
:initialization-options #'lsp-clients-elm--make-init-options
:server-id 'elm-ls))
(provide 'lsp-elm)
;;; lsp-elm.el ends here