redhat-developer / yaml-language-server

Language Server for YAML Files
MIT License
1.09k stars 264 forks source link

A way to disable schema loading for a specific file using modeline #446

Open Mange opened 3 years ago

Mange commented 3 years ago

Sometimes I want to be able to create a YAML file without a schema, for example to hold generic config. In some cases the naming of this file would match some generic pattern, and yaml-language-server will then try to validate this file against that schema. My editor is then filled with validation errors and bogus autocomplete suggestions.

I wish I could use the modeline to declare that this file is without a schema.

# Some ideas:
# yaml-language-server: $schema=none
# yaml-language-server: disable
# yaml-language-server: schemaless

I already tried the following, none of which worked:

# yaml-language-server: $schema=/dev/null
# yaml-language-server: $schema=null
# yaml-language-server: $schema=undefined
# yaml-language-server: $schema=
evidolob commented 3 years ago

One possible solution is to disable schema store yaml.schemaStore.enable in vscode settings for vscode-yaml.

Mange commented 3 years ago

Maybe. It won't help me as I'm not using VS Code. And from the description it sounds like it's a global setting, which wouldn't help if this was just an exceptional case in a sea of files where everything works like expected. :-)

Great that you can give people with VS Code a workaround to get back to work at least! 👍

evidolob commented 3 years ago

@Mange it is setting for yaml language server, not sure what IDE/Editor you are using, but it should support passing preferences for language servers.

calexandre commented 3 years ago

I use VSCode, but it would be nice to be able to disable the schema validation inline...

twelvelabs commented 2 years ago

I'd love to be able to disable validation inline as well - ideally line by line. I just ran into an issue where the schema on schemastore.org was incorrect, and the VS Code extension was flagging an error. I'd like to use a # yaml-language-server: disable-line comment to remove the error until my schemastore.org PR is accepted.

chrisgrieser commented 1 year ago

I also wanted to pitch in that a way to disable schemas just for a certain file would be much desired.

A rather convoluted bug results in ansible schemas being applied to unrelated pandoc files., and there is no way of turning the resulting spurious errors off other than disabling schemas globally.

ionous commented 4 months ago

sounds like #796 ( Option to turn off schema enforcement for a single document via modeline ) is asking for a similar thing. being able to disable it per document section would also be a simple way to support the closed request #710 ( Support markdown frontmatter )