alexanderweiss / nova-prettier

Prettier extension for Nova
MIT License
35 stars 6 forks source link

Infer tab width based on the current document tab configuration? #84

Open guillaumealgis opened 2 years ago

guillaumealgis commented 2 years ago

I think it would be nice if the extension could configure Prettier dynamically based on the current document tab width (the thing in the bottom right corner of the editor) :

Capture d’écran 2022-01-31 à 16 55 17

It would be easier when working with projects mixing e.g. 2-spaces and 4-spaces wide tabs. Currently the only solution that I know of is changing the width manually in the extension preferences before saving each file ?

GwynethLlewelyn commented 2 years ago

Hm! It seems to respect .editorconfig, though; I use that to set the tab width in Nova, and, implicitly, the same happens to the plugin as well. I've tested now on two different projects, each having different tab settings on .editorconfig — Prettier most certainly uses them!

guillaumealgis commented 2 years ago

@GwynethLlewelyn sure, but let's say I have a project where the main language is unrelated (unsupported) by Prettier, and am still using a few .yml files here and there for configuration. It seems overkill to have an .editorconfig file in the project just for these few files.

Plus, if I'm not mistaken Prettier does not support a global configuration, so I can't go that way either.

I'd argue that in cases where there is no .editorconfig found for the file being reformatted, defaulting to the current document tab width set by Nova is reasonable.

GwynethLlewelyn commented 2 years ago

Aye, I totally get your point, it's definitely the most reasonable approach....

alexanderweiss commented 2 years ago

This sounds kind of nice to have, but there's two things I'm not quite sure about:

Maybe this should be an option though — not setting default indentation?

MadeByDouglas commented 1 year ago

So this would be great, but even basic settings would be better. As far as I can tell, neither the Nova global settings (in the extension manager) or project settings work for adjusting the indentation size. No matter what I do, upon save it adjusts things to the default of 2 spaces. Seems this should work without an .editorconfig right? Or am I doing something wrong?