Skip to content

VSCode Integration

Integrate maplibre-yaml validation into your VSCode workflow for real-time error detection and quick fixes.

You can use maplibre-yaml with VSCode immediately using the built-in Tasks feature:

Create or update .vscode/tasks.json in your project:

{
"version": "2.0.0",
"tasks": [
{
"label": "maplibre-yaml: Validate Current File",
"type": "shell",
"command": "npx",
"args": [
"@maplibre-yaml/cli",
"validate",
"${file}",
"--format",
"vscode"
],
"problemMatcher": {
"owner": "maplibre-yaml",
"fileLocation": "absolute",
"pattern": {
"regexp": "^(.+):(\\d+):(\\d+): (error|warning): (.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
},
"presentation": {
"reveal": "silent",
"panel": "shared"
},
"group": "build"
}
]
}
  1. Open a .yaml file
  2. Press Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux)
  3. Type “Run Task”
  4. Select maplibre-yaml: Validate Current File

Errors appear in the Problems panel (Cmd+Shift+M / Ctrl+Shift+M) with:

  • ✅ Clickable file paths
  • ✅ Line and column numbers
  • ✅ Error messages with context
  • ✅ Quick navigation to error locations

Download the complete configuration with all tasks: tasks.json example

Includes:

  • Validate Current File: Validates the open file
  • Validate All Configs: Validates all YAML files
  • Watch and Validate: Continuous validation

Add to .vscode/settings.json for autocomplete:

{
"yaml.schemas": {
"https://raw.githubusercontent.com/design-practices/maplibre-yaml/main/schemas/map-block.json": [
"configs/**/*.yaml",
"*.map.yaml"
]
},
"files.associations": {
"*.map.yaml": "yaml",
"**/configs/**/*.yaml": "yaml"
}
}

Download complete settings.json

Set up a keyboard shortcut:

  1. Press Cmd+K Cmd+S (Mac) or Ctrl+K Ctrl+S (Windows/Linux)
  2. Search for “Run Task”
  3. Add keybinding (e.g., Cmd+Shift+V)
  4. Configure to run maplibre-yaml: Validate Current File

Run maplibre-yaml: Validate All Configs to validate all files in your project.

Output appears in the Problems panel grouped by file.

Run maplibre-yaml: Watch and Validate for continuous validation:

  • Runs in background
  • Updates Problems panel on file save
  • Shows real-time errors
  • Perfect for development workflow

The VSCode Problem Matcher parses CLI output in the format:

file:line:column: severity: [path] message

Example:

/Users/you/project/config.yaml:5:10: error: [config.center] Expected array, got string

This enables VSCode to:

  • Parse error locations
  • Underline errors in the editor
  • Display in Problems panel
  • Provide quick navigation

The --format vscode flag produces Problem Matcher-compatible output:

Terminal window
maplibre-yaml validate config.yaml --format vscode

Output:

/path/to/config.yaml:5:10: error: [config.center] Expected array
/path/to/config.yaml:12:3: warning: [layers[0]] Deprecated property

Recommended shortcuts:

ActionDefaultSuggested
Run TaskCmd+Shift+P > “Run Task”Cmd+Shift+V
Problems PanelCmd+Shift+M-
Next ErrorF8-
Previous ErrorShift+F8-

We’re planning a native VSCode extension with:

  • ✅ Real-time validation as you type
  • ✅ Autocomplete for map properties
  • ✅ Hover documentation
  • ✅ Inline map preview
  • ✅ Go to definition for layer references
  • ✅ Rename refactoring

Roadmap: Extension Architecture

Phase 1 (Available Now): CLI with Tasks Phase 2 (Q1 2025): Extension MVP Phase 3 (Q2 2025): Language Server Phase 4 (Q3 2025): Preview Webview

  1. Check that the task includes problemMatcher
  2. Verify --format vscode is in the args
  3. Ensure file paths are absolute
  4. Check Problems panel filter settings
  1. Ensure .vscode/tasks.json exists in project root
  2. Reload VSCode window
  3. Check JSON syntax is valid

On first run, VSCode may ask to allow task execution. Click “Allow” to proceed.