-
Notifications
You must be signed in to change notification settings - Fork 217
bug: Injected formatter weirdness #194
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
Comments
I'm not able to get this to reproduce. For some reason nvim 0.9 doesn't even find the yaml format range, but nightly does. However, the issue still doesn't reproduce even with nightly (
|
I can help debug this more next week. All of my reproducing was done with the minimal configuration both with nightly and 0.9. |
Just did a few quick tests and I must not have tested in 0.9. I can confirm in 0.9 I am also not getting the YAML language detection. When installing Neovim nightly I do get the behavior using the minimal
Here is a full recording of me doing the process with neovim nightly ( https://asciinema.org/a/M1zXukyBon9Enqk4H5KJPJZNQ |
Oh and here are the logs from me changing the debug level to
|
Oh also, this directory is clean (freshly created) and I have no prettier configuration files anywhere on my machine |
Could I get just a little be more context from that log file? I can see from the |
Ah, sorry about that!
Aha! I see the issue now, I can reproduce this actually at the command line now (thank you so much for this incredible log format) The issue is coming form cat test_just_yaml.md | prettier --stdin-filepath test_just_yaml.md then it will format this as if it were markdown and not yaml cat test_just_yaml.md | prettier --stdin-filepath some_random_string.yml results in the correct formatting (the filepath string can be a random string since the For reference, the
|
Can you try out #199 and see if it works for you? |
@stevearc yup that seems to work! Thanks so much! |
Uh oh!
There was an error while loading. Please reload this page.
Neovim version (nvim -v)
0.10.0-dev-3d8f0cb
Operating system/version
Arch Linux
Add the debug logs
log_level = vim.log.levels.DEBUG
and pasted the log contents below.Log file
Describe the bug
I am getting some weirdness when I am using the
injected
formatter. In this case it is usingprettierd
but I can replicate it withprettier
as well.It seems to be formatting the code incorrectly in some very simple cases.
Here is a simple Markdown file:
When I run Conform with the settings:
I get the following result:
Thank injected formatting of the YAML is wrong.
I was thinking maybe the full formatting was messing up the YAML block before it got to the injected formatter, but the strange thing is if I format the entire file with
prettierd
orprettier
from the commandline it actually outputs the correct result (runningprettier test.md
). So it leads me to think that it is something to do with the ranged formatting of the YAML block.If I copy and paste the metadata header into a
YAML
file such as:prettier
also formats this YAML file correct as does Conform.It seems that the issue is coming directly from the
injected
formatter.Steps To Reproduce
nvim -u repro.lua test_file.md
require("conform").format()
Expected Behavior
Correct formatting, or at least non-destructive formatting
Minimal example file
Minimal init.lua
Additional context
I have tried testing this every which way to try and figure out how to reproduce the final result with just running formatting commands from the command line and I can't seem to. Let me know if have any ideas!
The text was updated successfully, but these errors were encountered: