iamcco / coc-diagnostic

diagnostic-languageserver extension for coc.nvim
245 stars 22 forks source link

Prefer space indentation on shfmt #119

Closed mosheavni closed 2 years ago

lithammer commented 2 years ago

This seems like a very bad default and should be reverted imo. If your preference is 2-space indentation instead of the default (tabs), you can configure it via an EditorConfig. Or create an args override in your coc-settings.json.

In fact, adding this flag causes shfmt to ignore EditorConfig making this unusable on any project that uses one:

If any EditorConfig files are found, they will be used to apply formatting options. If any parser or printer flags are given to the tool, no EditorConfig files will be used.

There's even an example at the bottom of the manpage with an example on how to configure it.

https://github.com/mvdan/sh/blob/master/cmd/shfmt/shfmt.1.scd

mosheavni commented 2 years ago

This seems like a very bad default and should be reverted imo. If your preference is 2-space indentation instead of the default (tabs), you can configure it via an EditorConfig. Or create an args override in your coc-settings.json.

In fact, adding this flag causes shfmt to ignore EditorConfig making this unusable on any project that uses one:

If any EditorConfig files are found, they will be used to apply formatting options. If any parser or printer flags are given to the tool, no EditorConfig files will be used. A default like -i=0 can be used for this purpose.

There's even an example at the bottom of the manpage with an example on how to configure it.

https://github.com/mvdan/sh/blob/master/cmd/shfmt/shfmt.1.scd

I have a valid working editorconfig and shfmt didn't consider it, it just added a tab all of a sudden (probably upgraded shfmt where this was added)

lithammer commented 2 years ago

Maybe shfmt didn't find your .editorconfig for some reason? EditorConfig integration works fine for me using shfmt v3.4.2.

If you revert this change, are you still having issues with shfmt not using your EditorConfig?

lithammer commented 2 years ago

it just added a tab all of a sudden

I had a similar experience, but the other way around. And didn't understand why shfmt on the command-line did the right thing, but not coc-diagnostic.

mosheavni commented 2 years ago

Maybe shfmt didn't find your .editorconfig for some reason? EditorConfig integration works fine for me using shfmt v3.4.2.

If you revert this change, are you still having issues with shfmt not using your EditorConfig?

Tested now, looks like it does consider it this time.