Skip to content

Commit 0038e09

Browse files
authored
lsp-html - update to new version of custom data and add new configuration options (#4399)
1 parent 335a687 commit 0038e09

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

CHANGELOG.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
* Changelog
22
** Unreleased 8.0.1
3+
* Add new configuration options for lsp-html. Now able to toggle documentation hovers. Custom data is no longer experimental, and is now a vector.
34
* Add support for RPM spec files
45
* Add support for installing lsp dependencies via Cargo.
56
* Fix tramp support issues (see [[https://github.com/emacs-lsp/lsp-mode/pull/4204][#4204]])

clients/lsp-html.el

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
:link '(url-link "https://github.com/microsoft/vscode/tree/main/extensions/html-language-features/server")
3131
:package-version '(lsp-mode . "6.1"))
3232

33-
(defcustom lsp-html-experimental-custom-data nil
33+
(defcustom lsp-html-custom-data []
3434
"A list of JSON file paths that define custom tags, properties and other HTML
35-
syntax constructs. Only workspace folder setting will be read."
36-
:type '(choice (const nil) string)
35+
syntax constructs. Only workspace folder setting will be read.
36+
All json file paths should be relative to your workspace folder."
37+
:type 'lsp-repeatable-vector
3738
:group 'lsp-html
38-
:package-version '(lsp-mode . "6.1"))
39+
:package-version '(lsp-mode . "8.0.1"))
3940

4041
(defcustom lsp-html-format-enable t
4142
"Enable/disable default HTML formatter."
@@ -137,6 +138,18 @@ styles."
137138
:group 'lsp-html
138139
:package-version '(lsp-mode . "6.1"))
139140

141+
(defcustom lsp-html-hover-documentation t
142+
"Whether to show documentation strings on hover or not."
143+
:type 'boolean
144+
:group 'lsp-html
145+
:package-version '(lsp-mode . "8.0.1"))
146+
147+
(defcustom lsp-html-hover-references t
148+
"Whether to show MDN references in documentation popups."
149+
:type 'boolean
150+
:group 'lsp-html
151+
:package-version '(lsp-mode . "8.0.1"))
152+
140153
(defcustom lsp-html-trace-server "off"
141154
"Traces the communication between VS Code and the HTML language server."
142155
:type '(choice
@@ -163,14 +176,24 @@ styles."
163176
("html.format.unformatted" lsp-html-format-unformatted)
164177
("html.format.wrapLineLength" lsp-html-format-wrap-line-length)
165178
("html.format.enable" lsp-html-format-enable t)
166-
("html.experimental.customData" lsp-html-experimental-custom-data)))
179+
("html.hover.documentation" lsp-html-hover-documentation t)
180+
("html.hover.references" lsp-html-hover-references t)
181+
("html.customData" lsp-html-custom-data)))
167182

168183
(defcustom lsp-html-server-command-args '("--stdio")
169184
"Command to start html-languageserver."
170185
:type '(repeat string)
171186
:group 'lsp-html
172187
:package-version '(lsp-mode . "6.3"))
173188

189+
;; Caveat: uri seems to be sent as a single length vector.
190+
(defun lsp-html--get-content (_workspace files callback)
191+
"Helper function for getting the content of a URI/filename."
192+
(let* ((filename (aref files 0))
193+
(uri (f-join (lsp-workspace-root) filename))
194+
(file-content (f-read-text uri)))
195+
(funcall callback file-content)))
196+
174197
(lsp-dependency 'html-language-server
175198
'(:system "vscode-html-language-server")
176199
'(:npm :package "vscode-langservers-extracted"
@@ -185,6 +208,9 @@ styles."
185208
:priority -4
186209
:completion-in-comments? t
187210
:server-id 'html-ls
211+
:initialization-options (lambda ()
212+
(list :dataPaths lsp-html-custom-data))
213+
:async-request-handlers (ht ("html/customDataContent" #'lsp-html--get-content))
188214
:initialized-fn (lambda (w)
189215
(with-lsp-workspace w
190216
(lsp--set-configuration

0 commit comments

Comments
 (0)