efm-langserver icon indicating copy to clipboard operation
efm-langserver copied to clipboard

use intermediate / temporary file

Open davidosomething opened this issue 1 year ago • 6 comments

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

davidosomething avatar Aug 26 '23 08:08 davidosomething

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

davidosomething avatar Aug 30 '23 07:08 davidosomething

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)

chrisgrieser avatar Aug 30 '23 09:08 chrisgrieser

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.

creativenull avatar Aug 30 '23 15:08 creativenull

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.

creativenull avatar Aug 30 '23 15:08 creativenull

Some linter/formatter command looks current directory, file name, file extension, or configuration files. So temporary file might not fix something.

mattn avatar Mar 18 '24 14:03 mattn