vscode-yaml-sort
vscode-yaml-sort copied to clipboard
Add possibility for custom sort keys per file
Cases that we have many yaml files in a project. Use a global custom sort keys will lead to some kind of conflicts. It would be great if we can have that customization per file. Either a comment at the beginning of the file or a key-value settings for yaml sort extension with filename as key will both be OK for me.
Hi @pascalre, any clues on implmenting this? For my user cases, I have several configuration files in yaml:
- GitHub Action Workflows
- GitHub Dependabot Configuration
- GitLab CI/CD
- Copier configuration
- Copier answers
- ReadTheDocs configuration
- Pre-commit configuration
Generally, they all belong to some well-known tools that have some kind of convention for ordering. But with only one custom sort keys it tends to have conflicts and could be hard to maintain. One possible solution could be having the custome sort keys based on file name match in glob pattern for example. I would appreciate if there is anything I can do to help.
@huxuan I committed a first draft to eb54197
I still got two problems here:
- As you can see in package.json, the filenames currently do not support wildcards.
- The contents of the map are not read correctly. Debugging at settings.ts line 36 shows me this content:
The next command results in the error map.get is not a function
Thanks for the response, I will take a look and find out whether there is anything I can help.