AvaloniaVSCode
AvaloniaVSCode copied to clipboard
[Feature] Allow formatting with redhat.vscode-xml
Note: redhat.vscode-xml's default settings are...not great for XAML and AXAML. Additionally, it lacks many of the rules (e.g. attribute grouping) present in https://github.com/Xavalon/XamlStyler (which was suggested in #44)
Is your feature request related to a problem? Please describe.
It's annoying to switch from AXAML to XML just to format the current document.
Describe the solution you'd like
Luckily, redhat's xml extension allows for a simple solution. The only requirement is that other VSCode extensions which add xml-based languages must add a new property to their to their contributes.
It's not identical to formatting XAML in Visual Studio, but it's getting there. Next, it needs the ability to selectively not split attributes
Yes. It's that easy.
https://github.com/AvaloniaUI/AvaloniaVSCode/assets/7243190/f89b6057-b2aa-491b-a8a7-3bc98a28b90b
Describe alternatives you've considered
No response
Additional context
No response
I learned that the formatter "will not work" if the redhat's extension hasn't been activated yet. We'll need to call its activate() function so users don't need to manually start the xml language.
faulty
context.subscriptions.push(
registerAvaloniaCommands(commandManager, context),
vscode.extensions.onDidChange(() => {
const xml = vscode.extensions.getExtension("redhat.vscode-xml");
if (xml && !xml.isActive) {
xml.activate();
}
}));
EDIT: See https://github.com/BinToss/AvaloniaUI.AvaloniaVSCode/commit/b565d5fbd0c92437be24654acf1609f6a8d3a430 for a replacement
https://github.com/BinToss/AvaloniaUI.AvaloniaVSCode/commit/d21ce1ce726ec3b524bc138a828ad654bec57668 and https://github.com/BinToss/AvaloniaUI.AvaloniaVSCode/commit/2fa9389b4e63e369eb78ad5c1545e0e377eefaae fulfill this feature request. redhat.vscode-xml is not automatically installed.
VSCode does not allow extensions to recommend other extensions (that could get annoying). "Optional" extension dependencies can be forced upon the user via the Extension Pack feature.
Option A
Redhat publishes a Node package that allows extensions to recommend other extensions
Option B (recommended)
Publish an extension pack separately. It should include avaloniaui.vscode-avalonia and any other extensions we recommend or soft-depend on (i.e. activate only if already installed and enabled).