nova-prettier icon indicating copy to clipboard operation
nova-prettier copied to clipboard

Infer tab width based on the current document tab configuration?

Open guillaumealgis opened this issue 3 years ago • 5 comments

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 ?

guillaumealgis avatar Jan 31 '22 15:01 guillaumealgis

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!

GwynethLlewelyn avatar Feb 09 '22 21:02 GwynethLlewelyn

@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.

guillaumealgis avatar Feb 09 '22 23:02 guillaumealgis

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

GwynethLlewelyn avatar Feb 18 '22 00:02 GwynethLlewelyn

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

  • There's defaults in the extension and/or project settings — it seems strange to override these and / or only have indentation settings defined differently.
  • People might actually want to change/fix the indentation to their standard?

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

alexanderweiss avatar Feb 20 '22 12:02 alexanderweiss

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?

MadeByDouglas avatar Apr 06 '23 15:04 MadeByDouglas