-
Notifications
You must be signed in to change notification settings - Fork 284
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
Format accepts input from stdin #1035
Comments
The reason we don't have a stdin input type is because there isn't an obvious answer for the default stdin input type in In most cases, With that said, we could add a flag that lets the user modify the stdin input type (kinda like the However, we'd probably want the default input to be a single file for So in general, I'm hesitant to introduce this feature just to ease this one use case, especially because it's not the common path we want to evangelize, but I think we need an exception for TL;DR - We'll design a solution for |
I agree! That actually makes sense for the lint case. I stumbled across it because of |
Just an FYI that the PR above (which has VS Code and IntelliJ plugins) is blocked on this feature. |
See this issue for info: bufbuild/buf#1035 For formatting, the fix is to write to and read from a temp file. Diagnostics require project context, which a temp file can't provide, so the diagnostics source now runs only on save.
@amckinney Just to add my two cents to this, I think being able to provide file content via STDIN for I understand that For example if a new Rubocop for example works this way, which means it fully acts as if the the source provided on STDIN is |
I'd like this feature for exactly the original use case, formatting buffers (not always files) in vim with |
As @jimeh suggested, this approach is similar to what Prettier has implemented:
https://prettier.io/docs/en/cli.html#--stdin-filepath I would love to see this feature added so that I can configure Zed to format files using buf. |
I am working a lot with buf and have it also setup to work from inside Neovim and it would make life a bit more convenient if both
buf lint
andbuf format
would accept input from stdin.It would allow to show diagnostics live and on unsaved buffers and have a better integration with the
vim.lsp.buf.formatting()
functions as used in null-ls.Currently, this means that all changes are "undone" when running the formatting command on unsaved buffers as they revert back to what's on disc. Which happens a lot for me since I usually setup formatting like this
which runs the formatting on the unsaved buffer before writing the buffer to disc every time I save a file.
Maybe by adding an option
--stdin
or detecting when something gets piped in would be an option?The text was updated successfully, but these errors were encountered: