Skip to content

Add initial syntax - #1

Merged
deathaxe merged 18 commits into
mainfrom
feat/init
Jan 10, 2026
Merged

Add initial syntax#1
deathaxe merged 18 commits into
mainfrom
feat/init

Conversation

@rchl

@rchl rchl commented Jan 8, 2026

Copy link
Copy Markdown
Member

Add syntax for ESPHome configuration files.

This syntax extends YAML syntax to add support for lambda key/tag that can embed c++ code blocks.

Something to consider:

I've chosen a source.yaml-esphome main scope instead of source.yaml.esphome mainly due to how LSP works but also to match the vscode syntax.

The advantage of source.yaml-esphome in context of LSP is that the YAML language server will NOT automatically run for this syntax and we don't want that since it doesn't understand extensions of this syntax. Alternatively we could use source.yaml.esphome and edit LSP-yaml's configuration to exclude it.

One disadvantage of source.yaml-esphome that I've noticed is that built-in color schemes (f.ex. Mariana) include a rule to color unquoted strings white and that won't automatically work with source.yaml-esphome scope. There are perhaps also other YAML packages/plugins that would not automatically work with that scope.

@rchl
rchl force-pushed the feat/init branch 2 times, most recently from a8d7b96 to dc60556 Compare January 8, 2026 17:04
Comment thread YAML (esphome) - Comments.tmPreferences Outdated
Comment thread YAML (esphome).sublime-syntax Outdated
Comment thread YAML (esphome).sublime-syntax Outdated
Comment thread YAML (esphome).sublime-syntax Outdated
Comment thread YAML (esphome).sublime-syntax Outdated
Comment thread YAML (esphome).sublime-syntax Outdated
Comment thread YAML (esphome).sublime-syntax Outdated
Comment thread YAML (esphome).sublime-syntax Outdated
Comment thread YAML (esphome).sublime-syntax Outdated
rchl and others added 6 commits January 8, 2026 19:04
Co-authored-by: deathaxe <16542113+deathaxe@users.noreply.github.com>
Co-authored-by: deathaxe <16542113+deathaxe@users.noreply.github.com>
Co-authored-by: deathaxe <16542113+deathaxe@users.noreply.github.com>
Co-authored-by: deathaxe <16542113+deathaxe@users.noreply.github.com>
Co-authored-by: deathaxe <16542113+deathaxe@users.noreply.github.com>
@rchl

rchl commented Jan 8, 2026

Copy link
Copy Markdown
Member Author

Thanks for awesome suggestions.

Comment thread YAML (esphome).sublime-syntax Outdated
Comment thread .gitattributes Outdated
Co-authored-by: deathaxe <16542113+deathaxe@users.noreply.github.com>
@rchl

rchl commented Jan 8, 2026

Copy link
Copy Markdown
Member Author

Also noticed that return here is not colored for example:

Screenshot 2026-01-08 at 19 45 07

but that is probably an issue in the c++ syntax since it's reproducible also in c++ syntax with leading spaces:

Screenshot 2026-01-08 at 19 46 22

rchl and others added 2 commits January 8, 2026 19:48
Co-authored-by: deathaxe <16542113+deathaxe@users.noreply.github.com>
@deathaxe

deathaxe commented Jan 8, 2026

Copy link
Copy Markdown
Member

This is somehow related with how, c++ syntax handles global scopes.

If - as it seems - normal statements are required, only, it may be viable to include source.c++#statements context only, which would fix this kind of issues.

@rchl

rchl commented Jan 8, 2026

Copy link
Copy Markdown
Member Author

This seems to produce better highlighting all around so I will go with that. Thanks!

@deathaxe
deathaxe merged commit 9c58554 into main Jan 10, 2026
4 checks passed
@deathaxe
deathaxe deleted the feat/init branch January 10, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants