Open davidosomething opened 1 year ago
e.g. how null-ls creates a temporary buffer: https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/lua/null-ls/formatting.lua
yes please 🙏
There are a bunch of formatters/linters with auto-fix which do not work with stdin. Of the top of my head:
codespell
markdownlint
shellcheck
(with the git apply
workaround)There is some confusion here. formatStdin
dictates how the input will be sent to the cli tool. Will it be from stdin
? Or will it be handled externally (like pass in the filename/filepath)? This works as expected.
I think what you are referring to is to somehow control stdout
that is passed back to the LSP client.
I think what is needed is something similar to lintIgnoreExitCode
like formatIgnoreStdout
if the cli tool does not support outputting the changes to stdout then just ignore them.
However I don't see the LSP server like efm provide a way to channel these changes from a temp file to stdout.
I think it's the LSP client's responsibility to make sure the changes are shown if done externally just like it was done from stdout.
For vim/neovim we have :edit!
to reload the buffer if the file changed outside of neovim but is kinda hacky but is the only way I know to see these changes.
Some linter/formatter command looks current directory, file name, file extension, or configuration files. So temporary file might not fix something.
found a workaround. Feels a bit whack, but simply cat
ing the resulting again to get the content into stdout does work.
format-command: "markdownlint --fix '${INPUT}' ; cat '${INPUT}'"
for markdownlint-cli it can only fix files in place (no stdin) so needs to copy current file to a temp file, apply fix, and then copy contents back