-
Notifications
You must be signed in to change notification settings - Fork 161
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
How to add shell command with pipe? #44
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
@chrisgrieser can you take a look at #49 and see if it works for you? You can run the command in a shell by returning args as a string instead of a list. e.g. args = "--format=diff $FILENAME | git apply" |
thx, indeed the change works as it should, that is the using a string as Only problem is, the related shell command does not play nice with temp files, it seems? 🤔 shellcheck foobar.sh --format=diff --- a/foobar.sh
+++ b/foobar.sh
@@ -1,1 +1,1 @@
-echo $SHELL
+echo "$SHELL" Reading via stdin does not work here, since the diff is missing the filenames for --- a/-
+++ b/- Reading the file directly apparently has the issue that the temp files apparently cause some issue, too. Here the error message from
for reference, here is the config I am using: shellcheck = {
command = "shellcheck",
args = "shellcheck $FILENAME --shell=bash --format=diff | git apply",
stdin = false,
}, In case this is not directly solvable, an alternative approach for this particular case might be for conform.nvim to use the diff resulting from |
In the linked issue they mention using |
hmm, using
|
Try this definition: formatters = {
shellcheck = {
command = "shellcheck",
args = "$FILENAME --shell=bash --format=diff | patch -p1 $FILENAME",
stdin = false,
},
}, |
nice, that one works! Thx for the support. 🥳 Guess that one can also be directly be added to the conform.nvim, I guess? (when #49 is merged) |
The way conform.nvim is set up, it seems slightly more complicated commands do not work.
For example,
shellcheck
can be used to auto-fix some issues using this, effectively replacingshellharden
:shellcheck --format=diff my_file.sh | git apply
This works fine in the terminal, but the following config does not work:
I assume this is because in the background, conform.nvim uses
fn.system
with a list of strings, where pipes do not work. However, usingfn.system
with a single string does work fine, but passing a string toargs
results in an error.Is there a way to make this work?
The text was updated successfully, but these errors were encountered: