Home > Enterprise >  How to add a new match/mapping for an existing language?
How to add a new match/mapping for an existing language?

Time:11-17

Thanks to an extension (Caddyfile Syntax, Caddyfile Support) I have highlighting for Caddyfile. Installing the extensions also mapped Caddyfile files with the relevant syntax highlighting rules.

I now would like to also have the same mapping for caddy.conf files.

According to the documentation, I should add an alias for caddy.conf so that it is handled the same way as Caddyfile.

The problem is that I do not know where to add this information in settings.json.

I had a look for anything "caddy" in defaultSettings.json but I do not see any structure that would match th eone in the documentation. Namely, I only see

    // Configure settings to be overridden for the caddyfile language.
    "[caddyfile]":  {
        "editor.insertSpaces": false,
        "editor.formatOnSave": true
    },

What I am looking for should more look like (according to the documentation above)

 "languages": [{
        "id": "java",
        "extensions": [ ".java", ".jav" ],
        "aliases": [ "Java", "java" ]
    }]

So in practical terms - where in setting.json should I add the alias (or possibly a new mapping)?

CodePudding user response:

Try adding this to your settings.json:

"files.associations": {
  "*.conf": "caddyfile"
}

Alternatively, you can invoke the workbench.action.editor.changeLanguageMode command (Ctrl K M by default, also works by clicking the language label in the status bar) and select the language you want. This is probably preferable if you might have files with the same extension, but different syntax.

  • Related