VS Code extension doesn't register CSharpier as a formatter for XAML files
Environments
- IDE Version: 1.105.1
- Extension Version: 2.1.0
- CSharpier Version: 1.2.1 will NOT be the same as the extension version
- Operating System: Windows 11 Pro
- .csharpierrc Settings: N/A
- .editorconfig Settings: N/A
Log Output N/A
Steps to reproduce
- Open a XAML file, hit Ctrl+Alt+P and search for "Format Document With..."
- Notice that CSharpier is not an option for formatting XAML files
Expected behavior Since CSharpier can format XAML files, I would have hoped it would appear as an option so I could use it instead of the C# formatter that comes as part of the C# extension.
Actual behavior Only the C# formatter is available for XAML files, not CSharpier.
When I open a new xaml file it isn't associated with a language - see languages
For csharpier to format it, it would need to be associated with xml. If I select xml as the language for the file (seems to be available when the file has no content and with a keyboard shortcut) then I can format it.
You can also associate extensions with a given language - which is the better way to go.
"files.associations": {
"*.xaml": "xml"
}
Chatgpt seems to think I can do this at the extension level, but I haven't found any other documentation confirming that. Are you using any xaml extensions? I'll take a look at trying to add this association at the extension level.
Thanks heaps for the reply. So it seems the Microsoft C# VS Code extension actually registers a XAML language in the editor.
I can confirm that the XAML language dissappears when the C# extension is disabled.
For the moment, your suggested configuration does solve the problem, but it may be ideal if the extension registered itself as a formatter for the XAML language installed by the C# extension too, if that's possible. 😄
Cheers Fotis