vscode-yaml-sort icon indicating copy to clipboard operation
vscode-yaml-sort copied to clipboard

Add possibility for custom sort keys per file

Open huxuan opened this issue 1 year ago • 3 comments

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.

huxuan avatar Jun 08 '23 11:06 huxuan

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 avatar Dec 05 '23 01:12 huxuan

@huxuan I committed a first draft to eb54197

I still got two problems here:

  1. As you can see in package.json, the filenames currently do not support wildcards.
  2. The contents of the map are not read correctly. Debugging at settings.ts line 36 shows me this content: Bildschirmfoto 2023-12-08 um 22 26 55

The next command results in the error map.get is not a function

pascalre avatar Dec 08 '23 21:12 pascalre

Thanks for the response, I will take a look and find out whether there is anything I can help.

huxuan avatar Dec 11 '23 01:12 huxuan