This project is a set of functions for obtaining smart yaml
code completion inside Emacs, using the Redhat YAML LSP Server.
The implementation leverages eglot (and its transient dependency project.el for project management).
Smart code completion is enabled by selecting a schema from a pre-defined catalog:
- The default schema catalog URI is https://www.schemastore.org/api/json/catalog.json
- The default schema catalog URI is configurable via the variable
eglot-yaml-schema-store-uri
Function | Description |
---|---|
eglot-yaml-schema-for-buffer | Select a JSON schema for the current YAML buffer |
- The only Emacs package dependencies are eglot and yaml-mode (or
yaml-ts-mode
). - The following is assumed:
- You’re using the Redhat YAML LSP Server for
yaml
files- The installation needs Node.js (its
npm
command) - You can install the LSP server via the command:
npm i -g yaml-language-server
- The installation needs Node.js (its
- You’ve enabled
eglot
foryaml
files (yaml-mode
oryaml-ts-mode
)
- You’re using the Redhat YAML LSP Server for
Copy the contents of eglot-yaml.el to a new Emacs buffer and run the command:
M-x package-install-from-buffer
You can configure few settings to reflect your preferences via M-x customize-group
(eglot-yaml).
- Associate
eglot
toyaml
buffers:(add-hook 'yaml-mode-hook (lambda () (eglot-ensure)))
- Once
eglot
is up and running for a givenyaml
buffer, invokeM-x eglot-yaml-schema-for-buffer
- You’ll be prompted to select a schema for
yaml
auto-completion - You can then use the completion mechanism of your choice (
company-mode
, etc.)
- You’ll be prompted to select a schema for