Allow shfmt
fixer to use .editorconfig
#4244
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[Fix #4233]
Motivation
As discussed in #4233,
shfmt
has some peculiarities that prevent it from working seamlessly standalone and from within ALE.Currently, the
shfmt
fixer tries to derive the CLI arguments to pass to the executable fromexpandtab
,shiftwidth
andtabstop
.While it seems like a good default at first sight,
shfmt
docs state:This means that the current fixer is currently preventing
shfmt
from being customized on a more granular level with an.editorconfig
. The worst part is that it's currently impossible to have project-level configuration forshfmt
without resorting to things like local.vimrc
s.I have reached out to the author of
shfmt
(see issue #889) and came to the conclusion that the best approach is to use the-filename
option to pass the original file path.I would also like to highlight this specific comment made by the author:
Given that this an implementation detail, I think the best approach is to treat it as a black-box. For that reason, I didn't try to add test cases covering the behavior of
shfmt
when a.editorconfig
is present, just stuck to its default behavior by default.Users are still free to configure their own CLI arguments through
g:ale_sh_shfmt_option
, which will still disable.editorconfig
support, but that is an opt-in behavior (maybe this should be documented somewhere).Commit List