Skip to content

Commit fa89327

Browse files
authored
feat: add lsp-yaml-schema-extensions (#4527)
* feat: add `lsp-yaml-schema-extensions` This commit replaces defconst `lsp-yaml--built-in-kubernetes-schema` with defcustom `lsp-yaml-schema-extensions` to enable users to extend the dropdown options provided by `lsp-yaml--get-supported-schemas`. This is helpful since users are no longer locked into the yaml-language-server's version of the Kubernetes schema. This also enables users to provide more schemas and multiple versions of schemas if need be i.e. multiple versions of the Kubernetes schema, if you work across multiple clusters. * fix: replace current Kubernetes schema with v1.30.3 The current schema provided `yaml-language-server` does not exist any longer so is causing a bug when loading the schema. * fix: docstring for `lsp-yaml-schema-extensions`
1 parent 168bf21 commit fa89327

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

clients/lsp-yaml.el

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,16 @@ Limited for performance reasons."
172172
(lsp-package-ensure 'yaml-language-server
173173
callback error-callback))))
174174

175-
(defconst lsp-yaml--built-in-kubernetes-schema
176-
'((name . "Kubernetes")
177-
(description . "Built-in kubernetes manifest schema definition")
178-
(url . "kubernetes")
179-
(fileMatch . ["*-k8s.yaml" "*-k8s.yml"])))
175+
(defcustom lsp-yaml-schema-extensions '(((name . "Kubernetes v1.30.3")
176+
(description . "Kubernetes v1.30.3 manifest schema definition")
177+
(url . "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.30.3-standalone-strict/all.json")
178+
(fileMatch . ["*-k8s.yaml" "*-k8s.yml"])))
179+
"User defined schemas that extend default schema store.
180+
Used in `lsp-yaml--get-supported-schemas' to supplement schemas provided by
181+
`lsp-yaml-schema-store-uri'."
182+
:type 'list
183+
:group 'lsp-yaml
184+
:package-version '(lsp-mode . "9.0.1"))
180185

181186
(defun lsp-yaml-download-schema-store-db (&optional force-downloading)
182187
"Download remote schema store at `lsp-yaml-schema-store-uri' into local cache.
@@ -194,7 +199,7 @@ Set FORCE-DOWNLOADING to non-nil to force re-download the database."
194199
(lsp-yaml-download-schema-store-db)
195200
(setq lsp-yaml--schema-store-schemas-alist
196201
(alist-get 'schemas (json-read-file lsp-yaml-schema-store-local-db))))
197-
(seq-concatenate 'list (list lsp-yaml--built-in-kubernetes-schema) lsp-yaml--schema-store-schemas-alist))
202+
(seq-concatenate 'list lsp-yaml-schema-extensions lsp-yaml--schema-store-schemas-alist))
198203

199204
(defun lsp-yaml-set-buffer-schema (uri-string)
200205
"Set yaml schema for the current buffer to URI-STRING."

0 commit comments

Comments
 (0)