-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Add :pipe-all command that pipes entire document and ignores shell output #12298
base: master
Are you sure you want to change the base?
Conversation
how is it different from selecting entire buffer (%) and then |
Oops, forgot to explain that part. The use case would be chaining this command with other commands inside a key mapping. Suppose we wanted to build an AI tool for refactoring the current selection. The tool would be informed about the buffer content using something like |
Fair point, seems more convincing now. |
An entirely different approach to my use case would be to implement a language server. As far as I can see, we do not currently support binding keys to custom language server commands though, right? |
LSP code actions are implemented, so you could attach the custom LSP to all files (or the desired ones) and press |
Yep, code actions are no acceptable solution for me. I am however considering building a language server that additionally listens on some socket, such that it can be remote controlled with normal |
Cool idea. Another approach would be to use the filename command expansion to get your command to read the file contents from disk. |
That would be a viable yet hacky workaround in combination with saving the file before every command execution. That would not usually be what the user expects though. It also wouldn't work with buffers that are not yet associated with a file on disk. |
Ah, true! I agree it would be strange to write the file first. |
I wonder if there should be a |
That was my initial idea as well. With larger files this would hit the operating systems maximum argument length though I think. |
With the addition of the hopefully soon to be merged command expansion, we can call shell commands, passing them the current file name, line, and column numbers. In combination with the amazing shell piping commands this would allow building tools like GitHub Copilot and Copilot Chat, that can insert, replace, or describe code based on the entire file context.
I did not find a way to make the current content of the unsaved buffer available to such a program though, which kind of defeats the purpose of passing line and column numbers to shell commands.
My suggestion is this:
Add a :pipe-all command that acts like the :pipe-to command but pipes the entire buffer contents to the shell command.