rust-lang / rust-enhanced

The official Sublime Text 4 package for the Rust Programming Language
MIT License
780 stars 104 forks source link

Indentation should be forced to 4 spaces #448

Closed ISSOtm closed 3 years ago

ISSOtm commented 3 years ago

Sublime Text Version

Sublime Text 3 (Build 3211)

Rust Enhanced Version

v2.22.0

Operating system

Arch Linux

Expected behavior

Indentation is automatically overridden to 4 spaces in files using the Rust Enhanced syntax, like Makefiles.

Actual behavior

Indentation is kept as the user's default (in my case, 4-space hard tabs), making navigation harder in the file (backspace deletes the spaces one by one).

Steps to reproduce

  1. Set hard tabs in user settings ("translate_tabs_to_spaces": false)
  2. Create a Rust Enhanced syntax file
  3. rustfmt will correct the tabs to 4 spaces on save, but the indentation setting will still be hard tabs
dten commented 3 years ago

Hey, rustfmt has its own configuration files

https://github.com/rust-lang/rustfmt/blob/master/Configurations.md

You probably want hard_tabs set to true

Edit your usage of hard tabs makes me think you have this already?

ISSOtm commented 3 years ago

No, I'm intentionally using the defaults. My feature request would be for the extension to detect rustfmt's settings and override the editor's accordingly, if that's possible.

ehuss commented 3 years ago

Thanks for the report. I'm going to close this as a duplicate of #383.

We probably don't want to try to parse rustfmt config files or anything like that. If you open a file with spaces, Sublime should auto-detect the format. I believe it doesn't auto-detect if the file is already open and modified from a terminal. And of course new files will default to tabs.

I'm uncertain how wise it is to change the default. YAML is the only default language that changes it (because it is required), even languages like Python which are predominately space indented doesn't change the default. But I'd be fine changing it, since it is the most common form. I'm just uncertain why Sublime defaults the way it does. It may be disrupting for people who use tabs, but I suspect that number is very small.