Use editorconfig presets
It would be very useful if neoformat took into consideration any EditorConfig settings and applied them when executing.
For example, jsbeautify defaults to spaces for indent and an indent width of 2, yet my .editorconfig file defines the indent style as tabs and indent width of 4 spaces. When executing :Neoformat in a JavaScript file, it preserves the desired tab style and width of the document defined in the .editorconfig file rather than overwrite them with the jsbeautify defaults.
Neoformat currently uses shiftwidth() for js-beautify, and checking whether or not to use tabs should be similar.
https://github.com/sbdchd/neoformat/blob/255239e217ae124b1438c35967597b63db328820/autoload/neoformat/formatters/javascript.vim#L8
That's good to know. However, as a contractor I may switch from client project to another client project with different coding style guidelines (thus EditorConfig). Not having to go to my Vim config file between switches would be nice. Just a thought. Great plugin!
I think if you install editorconfig-vim, it will read the .editorconfig and change your shiftwidth and other options, and then Neoformat will take them into account. Give it a try 🙂
I think this comes down to a per-tool config, though writing a basic API to make configuring this easier would be nice.
e.g. let g:neoformat_editorconfig = {'yapf', 'autoflake8', etc}
I was wrong when I suggested that editorconfig-vim plugin is always needed, in some cases the external tools (like prettier) are themselves responsible for discovering and honoring .editorconfig.
However, in case of prettier it is not doing so when using --stdin flag, it's a bug that needs to be fixed on their side.
Reported as https://github.com/prettier/prettier/issues/4351.
If I understand the state of the current issue: with the way neoformat plugin works, it doesn't account for shiftwidth config for vim except for some formater like prettier for JavaScript. So the issue is not with editorconfig because if you have the plugin to load .editorconfig installed it set the shiftwidth accordingly. The issue is with neoformat not taking in account the vim settings?