Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024-02-06 - vscode で GitHub.vscode-github-actions を使っていると workflow YAML の言語が github-actions-workflow として認識されるようになるから 既存のYAML formatter 拡張でフックできなくなる #257

Closed
kachick opened this issue Feb 6, 2024 · 1 comment

Comments

@kachick
Copy link
Owner

kachick commented Feb 6, 2024

TL;DR

  • YAML に対してこれ動かせみたいな繊細なのではなく丸投げ系なら動くっぽいので、多分 prettier なら動いてるんだと思う。自分は dprint (YAMLは実質 prettier plugin 任せ) のときは動いてたけど yamlfmt 使おうとしたときにハマった。それならそれで https://github.com/dprint/dprint-plugin-exec に任せれば多分動く

何についてか / About

github/vscode-github-actions#195

経緯 / History

google/yamlfmt#129 で yamlfmt を workflow の fmt に使おうとしたら走らなかった。しばらくはまってたけど、vscode右下の言語設定見ると yaml ではない。これは他に入れてある拡張の https://github.com/github/vscode-github-actionshttps://github.com/github/vscode-github-actions/blob/02a4f12047a38409abce525e45650235499db371/package.json#L33-L41 でYAMLじゃないよという扱いをするように差し替えてて、https://github.com/bluebrown/vscode-extension-yamlfmt/blob/1c97b2d383f29defc2cc05e8e56c590dbb7ba7ec/package.json#L25-L27 の activationEvents に引っかからなくなっているようだった。vscode右下から言語解釈をYAMLに切り替えると案の定動く。
ここで厄介なのが、いかにも動きそうな次の設定が動かない点だった。

"[yaml]": {
    "editor.defaultFormatter": "bluebrown.yamlfmt"
},
"[github-actions-workflow]": {
    "editor.defaultFormatter": "bluebrown.yamlfmt"
},

且つてデファクトだった redhat 側はどうなんだと見に行くと同じような感じ https://github.com/redhat-developer/vscode-yaml/blob/e5a67a112a9a52eb8d8c991bf444fb309b2eb913/package.json#L41-L44 なので多分走らない。というのが冒頭の issue っぽい。あの issue には早い段階であたってたけど、なんでこういう問題になるのかというのを理解するのに時間がかかった。他の拡張側で activationEvents に onLanguage:github-actions-workflow と追加してやれば動きそうなんだけど、拡張から他の拡張に依存した何かは書きたくないだろうし、これはたしかに github/vscode-github-actions 側で解決してほしい話だなーという気はする

という、思うとか多分とかばっかしの話だった。メモ

@kachick
Copy link
Owner Author

kachick commented May 13, 2024

Nix をパッケージマネージャだけじゃなくディストリビューションとしても NixOS 本格的に使おうかなーと思った kachick/dotfiles#576 んだけど、自前でビルドしてないバイナリの類を走らせるのに何工夫か必要なので dprint の process plugin と相性が悪かった。 kachick/anylang-template#92

こうなると機能面では不足してても yamlfmt ぐらいしか現状選択肢が無いので、vscode 拡張を fork して使うようにした。 https://github.com/kachick/vscode-extension-yamlfmt

一応上流にもPRを取り込んでは貰えた bluebrown/vscode-extension-yamlfmt@e67d7e2 のだけれど、当面自分のほうが触る頻度高そう&希望要件に差がありそうなのでフォーク後ぼちぼち育てている

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant