Skip to content

Add setting to disable automatic schema detection for matching YAML files#1251

Merged
datho7561 merged 2 commits into
redhat-developer:mainfrom
shin19991207:schemaDetectionDisableFor
May 13, 2026
Merged

Add setting to disable automatic schema detection for matching YAML files#1251
datho7561 merged 2 commits into
redhat-developer:mainfrom
shin19991207:schemaDetectionDisableFor

Conversation

@shin19991207
Copy link
Copy Markdown
Member

@shin19991207 shin19991207 commented May 12, 2026

What does this PR do?

Adds the yaml.schemaDetectionDisableFor setting for disabling automatically detected schemas for specific YAML files by glob pattern. The expected value is a glob pattern or list of glob patterns.

This is intended for cases where schemas from Schema Store or schema association notifications are incorrectly applied to files with generic names. Explicit schemas still take precedence, so users can continue to opt into validation with the yaml.schemas setting or a modeline.

Also update https://github.com/redhat-developer/yaml-language-server/pull/1251/changes#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R116 because absolute paths in yaml.schemas does work fine.

What issues does this PR fix or reference?

Fixes redhat-developer/vscode-yaml#245

Is it tested? How?

  • New automated tests
  • Manual testing. Tried with the setting:
    "yaml.schemaDetectionDisableFor": ["*sam*"],
    or
    "yaml.schemaDetectionDisableFor": "*sam*",
    and a file named some.sam.yml with following content:
    name: example
    version: 1
    enabled: true
    items:
      - one
      - two

Signed-off-by: Morgan Chang <shin19991207@gmail.com>
Copy link
Copy Markdown
Contributor

@datho7561 datho7561 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the name of the setting could be better.

Maybe disableSchemaDetection?

Comment thread README.md Outdated
…ionand change schema priority

Signed-off-by: Morgan Chang <shin19991207@gmail.com>
@shin19991207 shin19991207 requested a review from datho7561 May 13, 2026 18:47
Copy link
Copy Markdown
Contributor

@datho7561 datho7561 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and works well. Thanks, Morgan!

We might need to comb through the issue list to find similar bugs and close them, I know this was a pain point for a bunch of users.

@datho7561 datho7561 merged commit c9ce086 into redhat-developer:main May 13, 2026
4 checks passed
@thernstig
Copy link
Copy Markdown

@shin19991207 @datho7561 would it not make sense to auto-disable it for common schemas in some way?

E.g. if the "Docker DX" extension is installed, it does not care about:

      "compose*y*ml",
      "docker-compose*y*ml",

I know other extensions does similar things for this, and it is a good practice because then thousand developers do not need to manually update their settings for common files and extensions.

The new solution is good, but I do definitely think it can be more DX friendly.

@datho7561
Copy link
Copy Markdown
Contributor

That sounds like a good idea.

We'd need some mechanism to detect that the docker extension is installed. We'd probably also want GitHub Actions. I can't think of any others off the top of my head. We'd probably need to do this on the VS Code side, then, which means the mechanism wouldn't work for eg. neovim, helix, zed etc.. but I still think it's worth doing it.

@thernstig
Copy link
Copy Markdown

@datho7561 I do know that https://github.com/hverlin/mise-vscode does discover if other extensions are installed, I have not investigated how or if what they do is idiomatic though.

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.

Disable schema detection for certain files

3 participants