yaml-language-server icon indicating copy to clipboard operation
yaml-language-server copied to clipboard

Do not apply schema to child directories

Open JoBrad opened this issue 4 years ago • 1 comments

Is your enhancement related to a problem? Please describe.

I have a directory that has the following structure:

  • parent
    • child_folder
      • client1_folder
        • theme.yaml
      • client2_folder
        • theme.yaml
    • client1.yaml
    • client2.yaml

I have defined 2 schema files: the first should be applied to all yaml files directly in the parent directory (there is not a naming convention for the files), while the second should be applied to all files in parent's child directories, that are named theme.yaml. However the way the glob string is applied to the document paths, there doesn't seem to be a way to avoid application of a schema recursively.

Describe the solution you would like

I would like the server to either:

  • Only apply schemas recursively in a directory if a double * is used (e.g. foo/**/*.yaml or foo/**.yaml)
  • Be able to set a flag to disable recursive application of schemas for a directory

The first option is preferred, since it is more in line with the way glob strings are generally used.

Describe alternatives you have considered

I know I could use the inline schema technique to specify which schema to use for the file. In my case, I have many files in the parent folder, so this is not ideal.

JoBrad avatar Nov 09 '20 19:11 JoBrad

Can't this be supported by optionally allowing schemas to be associated with proper regular expressions like it was implemented in d4a05e jsonSchemaService.ts? Unless I'm overlooking something that seems like a safe one line change: this.patternRegExp = Strings.convertSimple2RegExp(pattern);

maxullman avatar Nov 09 '20 23:11 maxullman