Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Settings
✓ import { Settings } from 'yaml-language-server';
Interface defining the configuration settings for the YAML language server, often used by clients to manage server behavior. Direct imports are primarily for type definitions when building custom tools or extensions that interact deeply with its internal settings structure.
YAML_SCHEMA_ASSOCIATIONS
✓ import { YAML_SCHEMA_ASSOCIATIONS } from 'yaml-language-server';
A constant or type definition related to how YAML files are associated with specific schemas. Useful for advanced configurations or client-side schema management within an LSP integration.
ISchemaAssociations
✓ import { ISchemaAssociations } from 'yaml-language-server';
An interface representing the structure for defining schema associations, enabling custom mappings between YAML file patterns and their corresponding JSON Schemas. Intended for programmatic setup of schema handling.
This quickstart demonstrates how to programmatically start and interact with the YAML Language Server as a child process using Node.js, establishing an LSP connection over standard I/O, sending an 'initialize' request, and notifying the server about a new document opening.
import { spawn } from 'child_process';
import { createConnection, MessageConnection, InitializeParams, TextDocumentItem, DidOpenTextDocumentParams } from 'vscode-languageserver/node';
import { TextDocuments } from 'vscode-languageserver-textdocument';
const serverPath = require.resolve('yaml-language-server/bin/yaml-language-server');
async function startYamlLanguageServer() {
console.log(`Starting YAML Language Server from: ${serverPath}`);
const serverProcess = spawn('node', [serverPath, '--stdio']);
serverProcess.stdout.pipe(process.stdout);
serverProcess.stderr.pipe(process.stderr);
process.stdin.pipe(serverProcess.stdin);
const connection: MessageConnection = createConnection(
serverProcess.stdin,
serverProcess.stdout
);
connection.listen();
connection.onInitialize(async (params: InitializeParams) => {
console.log('LSP Client: Initializing...');
return {
capabilities: {
textDocumentSync: 1, // Full
completionProvider: { resolveProvider: false, triggerCharacters: ['-', ':'] },
hoverProvider: true,
documentFormattingProvider: true,
documentRangeFormattingProvider: true,
documentSymbolProvider: true,
workspace: { workspaceFolders: { supported: true } }
},
serverInfo: { name: 'yaml-language-client', version: '1.0' }
};
});
// Send initialize request after connection is established
connection.sendRequest('initialize', {
processId: process.pid,
rootUri: null,
capabilities: {},
workspaceFolders: null
} as InitializeParams).then(async () => {
console.log('LSP Client: Initialized. Sending didOpen notification...');
// Example: Open a dummy YAML document
const dummyYamlContent = `---
apiVersion: v1
kind: Pod
metadata:
name: my-pod
spec:
containers:
- name: my-container
image: busybox
command: ['sh', '-c', 'echo Hello Kubernetes! && sleep 3600']
`;
const textDocument: TextDocumentItem = {
uri: 'file:///tmp/test.yaml',
languageId: 'yaml',
version: 1,
text: dummyYamlContent
};
connection.sendNotification('textDocument/didOpen', { textDocument } as DidOpenTextDocumentParams);
console.log('LSP Client: Sent didOpen for test.yaml. Check server logs for activity.');
}).catch(error => {
console.error('LSP Client: Initialization failed:', error);
});
process.on('exit', () => {
serverProcess.kill();
});
}
startYamlLanguageServer().catch(console.error);
yaml-language-server --version
Errors
Common errors & fixes
No errors are appearing in the LSP log... not seeing syntax highlighting, autocomplete, or suggestions in YAML files
The language server is not being correctly started, or the LSP client is failing to establish communication or send necessary requests (e.g., 'initialize', 'textDocument/didOpen').
fixVerify that the `yaml-language-server` executable path is correct in your LSP client's configuration (e.g., Neovim's `lspconfig`, VSCode extension settings). Check client/server logs for any connection errors. Ensure Node.js is installed and accessible in the environment where the server runs.
mapping values are not allowed in this context at line X column Y
This error typically indicates an indentation issue, a missing colon (`:`), or an attempt to use a non-scalar value (like a map or sequence) where a scalar is expected, violating YAML syntax rules.
fixCarefully review the specified line and column for incorrect indentation, missing key-value separators, or misplaced complex structures. Online YAML validators (e.g., YAML Lint) can help pinpoint syntax errors.
Incorrectly flagging 'Missing property "$ref"' for OpenAPI 3.0.X
The language server's schema validation might incorrectly interpret OpenAPI 3.0.X schemas, particularly regarding the `$ref` keyword, leading to false-positive validation errors.
fixCheck for updates to the `yaml-language-server` and `vscode-yaml` extensions, as this was a known issue that might have been resolved in newer versions. Ensure your OpenAPI schema is valid and accessible, and potentially simplify `$ref` usage if possible.
Audit
Dependencies
noderequiredRuntime environment for the language server. Requires Node.js v12.0.0 or higher.