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

Use VS Code Language mode in addition to regex to filter files? #67

Open
ddahan opened this issue May 4, 2022 · 2 comments
Open

Use VS Code Language mode in addition to regex to filter files? #67

ddahan opened this issue May 4, 2022 · 2 comments

Comments

@ddahan
Copy link

ddahan commented May 4, 2022

I'm using Django templates which have a .html extension, exactly like other html files that are not django templates.
I want to use specific formatters for these two kinds of files:

  • Prettier for normal html files (VS Code Language mode: HTML)
  • Djhtml for django templates (VS Code Language mode: Django HTML)

I wrote a runonsave config:

        "emeraldwalk.runonsave": {
            "commands": [
                {
                    "match": "\\.html$",
                    "cmd": "djhtml -i ${file}"
                },
            ]
        },

Now, obviously, my normal html files are first auto formatted by Prettier, then by djhtml. This is not what I want.
I think a way to fix this would be runonsave allowing me to match files in a specific language mode, rather than just by a regex.

What do you think?

@ddahan ddahan changed the title Use VS Code Language mode rather than regex to filter files? Use VS Code Language mode in addition to regex to filter files? May 4, 2022
@ddahan
Copy link
Author

ddahan commented May 4, 2022

For now, my workaround is to use: "match": ".*/templates/.*\\.html$" to target specific Django html files. It's not a real solution but it does the job.

@bmingles
Copy link
Member

I like the idea of adding languageid support. One option that comes to mind is using vscode settings [languageid] settings to isolate. I'll definitely consider adding this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants