Skip to content
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

use intermediate / temporary file #258

Open
davidosomething opened this issue Aug 26, 2023 · 5 comments
Open

use intermediate / temporary file #258

davidosomething opened this issue Aug 26, 2023 · 5 comments

Comments

@davidosomething
Copy link

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
Copy link
Author

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

@chrisgrieser
Copy link

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)

@creativenull
Copy link

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
Copy link

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.

@mattn
Copy link
Owner

mattn commented Mar 18, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants