Skip to content

Add support for .yaml extension for config and match files (#2184) - #2519

Merged
AucaCoyan merged 6 commits into
espanso:devfrom
gcailly:fix-issue-385-yaml-extension-support
Oct 8, 2025
Merged

AucaCoyan merged 6 commits into
espanso:devfrom
gcailly:fix-issue-385-yaml-extension-support

Conversation

@gcailly

@gcailly gcailly commented Oct 7, 2025

Copy link
Copy Markdown
Contributor

This PR adds support for the .yaml extension for configuration and match files, while maintaining backwards compatibility with existing .yml files.

  • New config and match files are now created with the .yaml extension (the official YAML extension).
  • Both .yaml and .yml extensions are now detected and loaded.
  • The config loader tries .yaml first, then falls back to .yml for backwards compatibility.
  • Updated all CLI commands (espanso edit, espanso path) to use .yaml extension.
  • Updated help text and error messages to reflect both extensions.
  • Renamed resource files: base.yml → base.yaml, default.yml → default.yaml.

Existing users with .yml files will continue to work. The file watcher already supported both extensions, and the config loader now has a fallback mechanism.

Fixes #2184, #385.

…panso#2483)

When running commands like `espanso service --help` or `espanso package --help`,
the CLI was displaying the main application help instead of the specific
subcommand help.

This was caused by using `clap_instance.print_help()` which always prints
the root command help, instead of using `err.exit()` which properly handles
contextual help for subcommands.

Fix: Use `err.exit()` to let Clap handle contextual help display.

Fixes espanso#2483
HTML special characters in snippet labels and triggers were being
interpreted as HTML tags instead of displayed as text in the search bar.

- Add EscapeHtml() helper function to escape &, <, >, and "
- Escape label and trigger strings before inserting into HTML template
- Add comment referencing issue espanso#974

Example: A snippet with `<kbd>test</kbd>` now displays correctly
instead of rendering an actual <kbd> HTML element.
HTML special characters in match labels and triggers were being
interpreted by wxHtmlListBox, causing tags like <kbd> to render
as HTML instead of plain text.

Added EscapeHtml() helper function to escape HTML entities
(&, <, >, ") in both labels and triggers before display.

Fixes espanso#974
YAML files can now use both .yml and .yaml extensions. The .yaml extension
is now preferred as it is the official YAML file extension.

Changes:
- Added .yaml pattern to STANDARD_INCLUDES for match files
- Support default.yaml with fallback to default.yml for backwards compatibility
- Updated all file creation to use .yaml extension (default.yaml, base.yaml)
- Updated file path references in edit, path, and troubleshoot commands
- Renamed resource files from .yml to .yaml
- File watcher already supported both extensions

Fixes espanso#385
@gcailly
gcailly requested a review from AucaCoyan as a code owner October 7, 2025 08:17
Update 4 unit tests in espanso-config/src/config/resolve.rs to expect both
.yaml and .yml patterns in STANDARD_INCLUDES:
- aggregate_includes_empty_config
- aggregate_includes_custom_includes
- aggregate_includes_extra_includes
- aggregate_includes_includes_and_extra_includes

The tests were failing on Linux CI because they expected only .yml patterns,
but the code now includes both .yaml and .yml patterns. Tests on Windows and
macOS passed because unit tests are only executed on Linux in CI.
@AucaCoyan

Copy link
Copy Markdown
Collaborator

Thanks gcailly!
Hey @smeech this PR changes behaviour around the yaml extensions.

Currently we support .yml on the config only. It's a bug that we don't support .yaml extension. This is fixed with this PR here, but my question is if we should make the default, and first option to lookup YAML, or we stay with the current default YML. What do you think?

@AucaCoyan

Copy link
Copy Markdown
Collaborator

Well, I made up my mind again, 😆 .
Let's merge!

@AucaCoyan
AucaCoyan merged commit 501cfb5 into espanso:dev Oct 8, 2025
@AucaCoyan

Copy link
Copy Markdown
Collaborator

Smeech, please update the documentation, as this is important info for our users 🙏🏼 👍🏼

@smeech

smeech commented Oct 8, 2025 •

Copy link
Copy Markdown
Collaborator

Smeech, please update the documentation, as this is important info for our users 🙏🏼 👍🏼

I'll add it to the list, but it won't affect most users, and none at all until it makes it into a Release.

If we're making it the default, however, and changing the names of default.yml and config.yml etc, that's a major change throughout the docs. I would have set it as an option for that reason alone! There appear to be 130 occurrences of ".yml" in the docs. People on different versions reading the docs will need to be reminded this is from one particular version (that most are not using) onwards.

@smeech smeech mentioned this pull request Oct 8, 2025
53 of 56 tasks
@gcailly

gcailly commented Oct 8, 2025 •

Copy link
Copy Markdown
Contributor Author

@smeech, I didn't think this change would impact the documentation so significantly. I'll make a PR for the docs.

@smeech

smeech commented Oct 8, 2025 •

Copy link
Copy Markdown
Collaborator

As I provide a lot of the support for new users, I try to think of how the docs appear for them. At this stage, we'll have many using the versions before the change, as well as a handful on the new version. Bearing in mind we don't push updates, both need to understand what they're reading and how it affects their own configuration.

I don't want to have to have 130 instances of something like "if you're using v2.2.9 onwards, you can also use default.yaml" or whatever, and then have to remove them at a later date. I'm exaggerating a bit, but you get the point.

TBH, I would prefer to keep the existing defaults, but simply permit .yaml files. It can be mentioned in a few places early in the documentation, for new users. Once the new version is widely established, we can switch the default files over and update the documentation as a whole. By then, users of older versions won't really be affected because they'll no longer be referring to the introductory sections.

Alternatives are to revert to versioned docs, as we did while v0.7.5 was prevalent, or introduce a "What's new" section we expect everyone to read through.

Without having had much time to think this through, I'm open to other suggestions, however!

gcailly added a commit to gcailly/website that referenced this pull request Oct 8, 2025
- Replace all .yml references with .yaml throughout the documentation
- Add note explaining .yaml is the official extension while .yml remains supported
- Update glob patterns to show both extensions: ../match/**/[!_]*.yaml and ../match/**/[!_]*.yml

Related to espanso/espanso#2519
@gcailly

gcailly commented Oct 8, 2025 •

Copy link
Copy Markdown
Contributor Author

@smeech I understand your point.
I made a PR anyway, in case you need it later. 🙂

@AucaCoyan

AucaCoyan commented Oct 10, 2025 •

Copy link
Copy Markdown
Collaborator

Hey!
You brought a really good point. I forgot again we document just for the stable version, and this is yet unreleased 😆 . About the topic, I think I passes for similar states of what you thought Smeech,

  1. State: hey, this is great! should we merge?
    In this position it was tempting to merge, and asked myself the consequences.
  • It's a breaking change, but it has backwards compatibility
  • many people use espanso since a long time ago, and persons get used to the software works over time. (Especially if there are few or non releases for a long time).
  1. State: we should maintain the current functionality and priority order (first yml, then yaml):
    If we change this order, this would mean anyone is happy and more users are welcome from the point in time this gets released (probably today).
    But it kept bugging me: why do we use .yml in the first place? I thought at first that extensions need to have 3 letters, and it's just a convention. Well, it's not fully agreed, we have mpeg4, or .json or even longer extensions like .postman-collection. I read your comment here and guess "well, smeech has already agreed upon this".
    I browsed the web for responses and turns out that Windows didn't support 3 letter extensions waaaaaay back in the past (before windows 95!).
  2. State: merge and move forward
    At this point I thought that we aren't blocked by any substantial reason:
  • the yaml extension is default onwards, giving the users a recognizable and easy extension, (we all say yaml in chat and threads but you write yml?)
  • backwards users still get the compatibility if they are using .yml and upgrading to a newer version. You can mix and match even! This makes everyone happy.

I understand your pain to address possibly documenting multiple versions (and loads of work) and that not what we want ever again. Maintaining multiple versions of a documentation is a colossal burden to manage.
We have an application, not a library, we expect our users to update when a new version is released.
Whether the user doesn't know if there is a new version (1) or the user is unable to update because newer versions doesn't run in his/hers OS, or simply are broken are all cases for a different discussion.

Maybe we (the espanso org) need to express our expectations we have over the users, so it's a clear understanding about what we provide, and back our comments and decisions with a public contract.

What do you think?

My suggestion for the documentation is NOT to change .yml for .yaml everywhere, but to mention it in a couple of places that it is allowed (maybe once, or twice).
If any user complains, then we can answer to update the software.
Smeech will have the final decision here 💯

notes:
1- there is no notification of an update whatsoever. A self-update mechanism is a feature yet in the backlog

@smeech

smeech commented Oct 10, 2025

Copy link
Copy Markdown
Collaborator

My suggestion for the documentation is NOT to change .yml for .yaml everywhere, but to mention it in a couple of places that it is allowed (maybe once, or twice).

My thoughts exactly.

@AucaCoyan

Copy link
Copy Markdown
Collaborator

At the end I reverted the priority of yaml over yml, we had a chat with the team and decided that we should continue with the same priority.
In the future, we will pick yaml over yml! but we are not there yet 👍🏼

@smeech

smeech commented Oct 10, 2025 •

Copy link
Copy Markdown
Collaborator

Ideally we'd allow .yaml files in Espanso now.

  • Both .yaml and .yml extensions are now detected and loaded.

Priority doesn't really matter (except if users have duplicate base-named files with different extensions), but will probably cause fewer user issues if .yml loading is prioritised. Remember, Federico's preferences for quoted YAML values, and colon-prefixes, have been quite persistent!

  • The config loader tries .yaml first, then falls back to .yml for backwards compatibility.

No problem with:

  • Updated help text and error messages to reflect both extensions.

It's an excellent PR from @gcailly, it just goes a bit further than the Issues and what we need at the moment, I'm afraid 😁 .
Would it be possible to go ahead with these bits while they're fresh in our minds, and keep the rest for later?

@AucaCoyan

Copy link
Copy Markdown
Collaborator

Yes! I didn't revert the whole PR, just changed the priority order from

  1. yaml
  2. yml

to

  1. yml
  2. yaml

In the future it is as easy as reverting the #2523 (reverting the revert 😆 ) and it's done

sboldt1978 pushed a commit to sboldt1978/espanso that referenced this pull request Feb 11, 2026
) (espanso#2519)

* Add support for .yaml extension for config and match files (espanso#385)

YAML files can now use both .yml and .yaml extensions. The .yaml extension
is now preferred as it is the official YAML file extension.

Changes:
- Added .yaml pattern to STANDARD_INCLUDES for match files
- Support default.yaml with fallback to default.yml for backwards compatibility
- Updated all file creation to use .yaml extension (default.yaml, base.yaml)
- Updated file path references in edit, path, and troubleshoot commands
- Renamed resource files from .yml to .yaml
- File watcher already supported both extensions

Fixes espanso#385

* Fix unit tests for .yaml extension support

Update 4 unit tests in espanso-config/src/config/resolve.rs to expect both
.yaml and .yml patterns in STANDARD_INCLUDES:
- aggregate_includes_empty_config
- aggregate_includes_custom_includes
- aggregate_includes_extra_includes
- aggregate_includes_includes_and_extra_includes

The tests were failing on Linux CI because they expected only .yml patterns,
but the code now includes both .yaml and .yml patterns. Tests on Windows and
macOS passed because unit tests are only executed on Linux in CI.
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.

Use the officially recommended extension for files containing (a) YAML document(s)

3 participants