Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic or Configurable language support #9

Open
Stadly opened this issue Oct 2, 2023 · 7 comments
Open

Automatic or Configurable language support #9

Stadly opened this issue Oct 2, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@Stadly
Copy link

Stadly commented Oct 2, 2023

Would it be possible to automatically check the supported languages of the listed formatters and use those as the languages supported by this extension?

@jota0222
Copy link
Owner

jota0222 commented Dec 6, 2023

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.

@Indy-rbo
Copy link
Contributor

Indy-rbo commented Feb 8, 2024

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

@jota0222 jota0222 added the enhancement New feature or request label Mar 6, 2024
@jota0222 jota0222 changed the title Automatic language support Automatic or Configurable language support Mar 6, 2024
@jota0222
Copy link
Owner

jota0222 commented Mar 6, 2024

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 😅

@a-laughlin
Copy link
Contributor

a-laughlin commented Mar 11, 2024

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.

@a-laughlin
Copy link
Contributor

Just tested the above solution. It works.

@a-laughlin
Copy link
Contributor

@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.

@jota0222
Copy link
Owner

jota0222 commented Jul 1, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants