YAML SQL Navigator
A VS Code extension that enhances YAML files containing SQL file references with navigation, preview, and autocomplete features.
Features
🔗 Click-to-Navigate
- Cmd+Click (Mac) or Ctrl+Click (Windows/Linux) on SQL file paths in YAML to open them directly
- Works with patterns like
sql_file: support_tables/statist/leave_max_action.sql
🔍 Hover Preview
- Hover over SQL file paths to see a preview of the SQL content
- Shows file information (path, line count)
- Displays first 500 characters with syntax highlighting
- Lists all SQL variables found in the file
✨ Autocomplete
- IntelliSense for SQL file paths when typing after
sql_file: or SQL_SCRIPT_FILE_NAME:
- Automatically scans
dags/social_dataset/sql_scripts_dlh/ directory
- Shows all available .sql files with relative paths
🎨 Syntax Highlighting
- Enhanced syntax highlighting for SQL file paths in YAML
- Special highlighting for
sql_file and SQL_SCRIPT_FILE_NAME keys
🚨 NEW: SQL-YAML Variable Linting
- Real-time validation of variables between SQL files and YAML configs
- Red error markers for missing variables in YAML
- Dual error reporting: Shows errors on both task name and
sql_file: lines
- Global variable support: Includes top-level YAML variables
- YAML anchor resolution: Validates that anchor references exist
- Trino SQL support: Works specifically with
type: 'dlh' tasks
Supported Patterns
The extension recognizes these YAML patterns:
# SQL file references
sql_file: support_tables/statist/leave_max_action.sql
SQL_SCRIPT_FILE_NAME: check_src_tables.sql
# Quoted paths
sql_file: "support_tables/statist/prepare_logs.sql"
sql_file: 'support_tables/statist/select_logs.sql'
# Embedded SQL (basic highlighting)
query: |
SELECT * FROM users
WHERE active = true
Installation
Method 1: Install from .vsix file (Recommended for development)
- Open VS Code or Cursor
- Press
Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows/Linux)
- Type "Extensions: Install from VSIX..."
- Select the
yaml-sql-navigator-0.0.1.vsix file from this directory
- Reload VS Code when prompted
Method 2: Development Installation
- Clone or copy this extension directory
- Open terminal in the extension directory
- Run:
npm install
- Run:
npm run compile
- Press
F5 to launch Extension Development Host
- Open your YAML files in the new window
Usage
- Open any YAML file in your workspace
- Navigate to lines containing
sql_file: or SQL_SCRIPT_FILE_NAME:
- Hover over the file path to see preview
- Cmd+Click on the file path to open the SQL file
- Start typing after
sql_file: to get autocomplete suggestions
Requirements
- VS Code 1.74.0 or higher
- Workspace should contain
dags/social_dataset/sql_scripts_dlh/ directory structure
Extension Settings
This extension doesn't add any VS Code settings currently. All features work automatically on YAML files.
Known Issues
- File paths are resolved relative to
dags/social_dataset/sql_scripts_dlh/ - this is hardcoded for your specific project structure
- Only
.sql files are recognized for autocomplete and navigation
Development
To modify this extension:
- Edit files in
src/ directory
- Run
npm run compile to build
- Run
npm run package to create new .vsix file
- Reinstall the updated extension
Release Notes
0.0.1
Initial release with:
- Click-to-navigate SQL file references
- Hover preview of SQL content
- Autocomplete for SQL file paths
- Enhanced syntax highlighting
| |