XamlStyler icon indicating copy to clipboard operation
XamlStyler copied to clipboard

create a vscode extension for formatting xaml/axaml

Open heartacker opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe. that is great if we can format xaml file in vscode

Describe the solution you'd like execute the xstyle with args -f ${file}

Describe alternatives you've considered

Additional context now, I just create a task name xamlstyler

        {
            "label": "XamlStyler",
            "type": "shell",
            "command": "xstyler",
            "args": [
                "-f",
                "${file}"
            ],
            "problemMatcher": []
        }

and set the keybinding

    {
        "key": "shift+alt+f",
        "command": "workbench.action.tasks.runTask",
        "args": "XamlStyler",
        "when": "resourceExtname == '.xaml'"
    },
> Executing task in folder atcgui: xstyler -f f:\ATCProjectFiles\AutoTool_SVN\atcgui\ATC.TPMS.GUI\AC5111\WinClock.xaml <

Processing: f:\ATCProjectFiles\AutoTool_SVN\atcgui\ATC.TPMS.GUI\AC5111\WinClock.xaml

Processed 1 of 1 files.

终端将被任务重用,按任意键关闭。
```

heartacker avatar Sep 23 '21 12:09 heartacker

Captured workaround in our wiki: Xavalon/XamlStyler/wiki/VSCode

grochocki avatar Sep 02 '22 04:09 grochocki

thanks, and I think we should add "when": "resourceExtname == '.xaml'" to that wiki, Just like I do

heartacker avatar Sep 02 '22 04:09 heartacker

Good catch, thanks! Updated.

grochocki avatar Sep 02 '22 04:09 grochocki

I've been pushing for XAML/AXAML formatting in https://github.com/redhat-developer/vscode-xml, but Xaml Styler has already implemented most–if not all–of ReSharper's XML-formatting rules.

Development of XamlStyler's VSCode extension could go in one of two directions:

  • Implement independently and exclusively (i.e. no awareness or integration with other formatting extensions).
    • If multiple formatters are available for the current file's language ID and the user explicitly1 invokes the editor's Format Document command (Format On Save doesn't count), the user will be prompted to select2 a default formatter for the given language ID.
    • A thin wrapper around xamlstyler's console app.
  • Integrate with redhat.vscode-xml via its Custom XML Extensions (written in Java). This would require compiling a JAR file to be imported by redhat.vscode-xml's https://github.com/eclipse/lemminx language server. Could XamlStyler's existing Rider extension be dissected for this?

1 VSCode's Format On Save feature does not trigger the "Configure Default Formatter" prompt. 2 The default formatter is saved per language ID in the user's settings (it can be copied to or manually set in the workspace settings i.e. ./.vscode/settings.json or WorkspaceName.code-workspace).

// redhat.vscode-xml set as the default formatter for AXAML, the language ID provided by avaloniateam.vscode-avalonia.
"[AXAML]": {
    "editor.defaultFormatter": "redhat.vscode-xml"
	}

P.S. What would the extension ID be? xavalon.xamlstyler?

BinToss avatar Feb 10 '24 09:02 BinToss