Prettier for HTML options not applied #4924
-
I have these language sections in my language.toml:
and this .prettierrc.json in my project root:
While on the one hand fmt/format on javascript actually makes use of the .prettierrc.json settings on the other hand fmt/format on html files does not. E.g. I can't get fmt/format to apply singleAttributePerLine. There seems to be nothing wrong with the .prettierrc.json, because it works well with neovim. It also works well for the javascript settings, e.g. toggling single and double quotes via singleQuote property in .prettierrc.json. Invoking prettier on command line on this html:
properly generates
But helix doesn't apply singleAttributePerLine. Can anyone help me with this? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 3 replies
-
Maybe you are not reading the config file for HTML and it is using the LSP formatter? Providing your current working directory is the root of the project (and Linux/Mac
Based on https://prettier.io/docs/en/cli.html#--find-config-path-and---config , I have not tried it. |
Beta Was this translation helpful? Give feedback.
-
@David-Else Thanks for your reply. I've tried what you proposed it and it's still not applying the settings of .prettierrc.json. BTW the relative path would be "./.prettierrc.json" since it's a dot file. |
Beta Was this translation helpful? Give feedback.
-
It seems very mysterious, my suspicion is still with the config file not being loaded, how about using the absolute path just to be certain, and if that doesn't work then a broken path to see how it reacts? I have seen Helix need an absolute path on Windows as a bug in the past. |
Beta Was this translation helpful? Give feedback.
-
@David-Else I've tried the absolute path: didn't work either. I'm on a Mac. Running
produces
I'm not sure, if prettier should appear there. In any case, it doesn't. I've checked
and this is what I see there:
It looks like there's something not properly working with the language server access. |
Beta Was this translation helpful? Give feedback.
-
I don't think Prettier should appear there at this time, but it could be a good feature request. It looks like the I suggest you look at the original commit that added the external format using a binary: #2942 , and consider asking the author of the PR for help. |
Beta Was this translation helpful? Give feedback.
-
thanks again for your reply.
produces
I don't think there's anything wrong there. Invoking (in my project's root) prettier test.html works and formats the tag attributes properly. The conclusion I draw from this, is that "files": [ "*.html" ] is properly interpreted. I'll try to check again, I have screwed something up. Maybe then I'll contact #2942 's author. |
Beta Was this translation helpful? Give feedback.
I don't think Prettier should appear there at this time, but it could be a good feature request.
It looks like the
["--parser", "html"]
tells Helix it is HTML, but"files": [ "*.html"],
is not able to recognise the buffer's file extension for"overrides"
.I suggest you look at the original commit that added the external format using a binary: #2942 , and consider asking the author of the PR for help.