求助:VS Code中GitHub Actions workflow文件无法格式化
我的开发环境中无法格式化GitHub Actions workflow文件
每当我尝试格式化这类文件时,都会收到如下错误提示:

点击"Install Formatter"没有任何反应,我也找不到合适的扩展或设置来解决该问题。
我已安装了GitHub官方的VS Code Actions扩展,尝试配置YAML格式化工具来处理这类文件,但似乎不起作用。此外,我在settings.json中添加了以下配置,但也无效:
settings.json
{ "security.workspace.trust.untrustedFiles": "open", "[python]": { "editor.defaultFormatter": "ms-python.black-formatter" }, "terminal.integrated.enableMultiLinePasteWarning": false, "python.terminal.activateEnvInCurrentTerminal": true, "[github-actions-workflow]": { "editor.defaultFormatter": "redhat.vscode-yaml" }, "yaml.schemas": { "https://json.schemastore.org/github-workflow.json": [ "*.github/workflows/*.yaml", "*.github/workflows/*.yml", ], "https://json.schemastore.org/github-action.json": [ "action.yaml", "action.yml", ] }, "explorer.confirmDelete": false, "git.autofetch": true }
VS Code version
Version: 1.80.2 Commit: 2ccd690cbff1569e4a83d7c43d45101f817401dc Date: 2023-07-27T20:57:59.134Z Electron: 22.3.14 ElectronBuildId: 22695494 Chromium: 108.0.5359.215 Node.js: 16.17.1 V8: 10.8.168.25-electron.0 OS: Darwin arm64 22.6.0

还有其他解决思路吗?
期望行为
我希望能使用文件格式化快捷键(CMD + OPT + L),在粘贴文档内容后快速调整文件格式。由于yaml很容易因空格对齐错误而失效,这一步非常重要。其他yml文件使用redhat.vscode-yaml格式化工具可以正常格式化,希望workflow yaml文件也能正常使用该工具格式化。
当前临时解决方案
我目前唯一的临时方案是将文件关联从github actions workflow切换为yaml,格式化后再切换回去,这非常繁琐。我认为可以通过settings.json配置解决,但不知道缺少什么设置。
内容的提问来源于stack exchange,提问作者VeRo
相关产品推荐
相关产品推荐

