z0mbix / vim-shfmt

Vim plugin for shfmt (https://github.com/mvdan/sh)
MIT License
135 stars 11 forks source link

vim-shfmt hides errors returned from shfmt #11

Open r10r opened 2 years ago

r10r commented 2 years ago

Hi @z0mbix ,

thanks for your work on vim-shfmt.

Currently it's a bit difficult to work with vim-shfmt when shfmt returns an error.

Consider the follwing script named test.sh

#!/bin/sh

foo="${$bar}"    

when using vim-shfmt on save I'll get the following error output:

Error detected while processing BufWrite Autocommands for "*.sh"..function shfmt#shfmt:
line   11:
Shfmt returned an error (often due to wrong syntax). Undoing changes.
2 more lines; before #4  0 seconds ago
Shfmt returned an error (often due to wrong syntax). Undoing changes.
"test.sh" 3L, 25B written
Press ENTER or type command to continue

when using shfmt from the cmdline I'll get:

shfmt test.sh 
test.sh: test.sh:3:9: $ cannot be followed by a word

shfmt correctly shows the line where the first first error appeared. vim-shfmt should show the error returned by shfmt. Automatically jumping to this line would be nice too.