Open Stadly opened 11 months ago
Hi @Stadly sorry for the delayed reply.
According to what I know, there is no a programatic way to know which formatters are for which languages, to do so it will be necessary to create a map manually, but, to be honest, I don't think it deserves the time since you just need to configure the languages once for a project.
If you have a better way to do it I will ask you to try implementing it, the repo is open to receive any PR.
Hi @jota0222
Looking at https://github.com/Vehmloewff/custom-format it seems to allow you to set a language
to register your formatter for:
"custom-format.formatters": [
{
"language": "languageIdentifier",
"command": "commandContent"
}
]
Do you think it's possible to add a setting like multiFormatter.languages
which takes in an array of language identifiers?
It's not automatic like the initial issue asks, but it allows users to supply their own array of languages, replacing the need for a PR to supported-languages.ts
.
Reading the VSCode activation event docs we could use onLanguage
as the activationEvents
This could be a good improvement, I will try to add it but it can take a while since I do this in my free time, and I don't have much at this moment 😅
Correct me if I'm wrong, but wouldn't:
"activationEvents": [
"onLanguage"
]
...combined with...
languages.registerDocumentRangeFormattingEditProvider('*', {
async provideDocumentRangeFormattingEdits(document) {...}
});
... make this work automatically for all languages? And it would remove the need to define supported languages or submit PRs for them.
Just tested the above solution. It works.
@jota0222 I can submit a PR for this if you'd like. I've been testing it out. VScode already has an error message for when the language isn't supported by the formatter.
@a-laughlin I tried to do that when I created the first version of the extensión, however, for an unknown reason it only worked for me if I add a limited list of languages. If it works for you now, you can indeed create the PR so I can test it again
Would it be possible to automatically check the supported languages of the listed formatters and use those as the languages supported by this extension?