Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

beautifying should follow Atom's indentation preferences #400

Closed
phish108 opened this issue Jun 15, 2015 · 22 comments
Closed

beautifying should follow Atom's indentation preferences #400

phish108 opened this issue Jun 15, 2015 · 22 comments
Assignees
Milestone

Comments

@phish108
Copy link

Despite having set the indent tab length to 4 in the preferences, atom-beautify will "beautify" the indentation only to 2 spaces.

@Glavin001
Copy link
Owner

Good question!

From #341 (comment):

Like CSS, Atom Beautify's options are prioritized by specificity: the options set closer to the file itself, or for that specific language, take precedence.

For instance, you could have Atom Beautify package settings setup for your personal configuration, however when working on a project with others your settings may be different. The .jsbeautifyrc file takes precedence over the package settings and Atom editor settings, etc. Furthermore, you could have multiple .jsbeautifyrc files, potentially in the same directory as your current file and all the way up to root directory. All of these would be applied, with priority going to the closest file to your currently beautified file.

Given that Atom's editor preferences are global, not language specific, and therefore lowest priority for Atom Beautify, this makes sense why you are experiencing this. You should create either .editorconfig or .jsbeautifyrc file in your project's directory, or edit Atom Beautify's package settings on a per-language basis for personal / user specific settings. See https://github.com/Glavin001/atom-beautify#configuration for more details. List of available options here: https://github.com/Glavin001/atom-beautify/blob/master/docs/options.md

@Glavin001 Glavin001 added this to the v0.29.0 milestone Jun 15, 2015
@Glavin001 Glavin001 self-assigned this Jun 15, 2015
@10SexyApples
Copy link

I am experiencing this same issue after setting per language basis personal / user specific settings in Beautify's package settings. No matter what I set, it beautifies with two spaces ... which is really difficult reading for heavily nested scss ... am I missing something?

@10SexyApples
Copy link

Solved by turning off soft tab options in Atom main prefs~

@Glavin001
Copy link
Owner

This is the recent related issue: #894
There has been a change in v0.29.x. See #894 (comment)
For someone interested in fixing the current behaviour see #894 (comment)
Thanks.

@calidion
Copy link

@Glavin001 thanks. Maybe because of the mixing of one configuration with another. I think the configuration panel should be designed more friendly if possible. One tab for one language only.

@Glavin001
Copy link
Owner

@calidion please feel free to create an issue outlining what you recommend the configuration should look like. With v0.29.x there were a lot of configuration UI improvements, however there is always room for improvement. I am open to Pull Requests as well. If you don't like something, please work with us to change it and make it better 😄 .

@calidion
Copy link

@Glavin001 Thanks. I will when I am ready:)

@zamicol
Copy link

zamicol commented Mar 6, 2017

What is the easiest way to globally set my indent character to tab and 1 indent size?

@rogaha
Copy link

rogaha commented Mar 30, 2017

happening with me as well.

@rogaha
Copy link

rogaha commented Mar 30, 2017

screen shot 2017-03-30 at 9 06 10 am

Why the the python files are being saved with 2 spaces instead of 4?

@prettydiff
Copy link
Collaborator

The easiest way to set universal settings is to modify the src/.jsbeautifyrc file.

@rogaha
Copy link

rogaha commented Mar 31, 2017

I don't want to modify it universally, I want it only for python and I would like to understand why it doesn't work.

@prettydiff prettydiff reopened this Mar 31, 2017
@rogaha
Copy link

rogaha commented Mar 31, 2017

@prettydiff I've also opened an issue with more details here: #1574

@prashanthvg
Copy link

Ok my issue is exactly the opposite of what the question is, I have set everywhere as 2 but atom-beautify does 4 spaces. I have also checked .jsbeautifyrc , that also has 2 only. Does anybody have solution? This is frustrating.

@rogaha
Copy link

rogaha commented Apr 6, 2017

@emailprashanthvg I ended up using python-ident instead, it's much faster and it works!

@DLiblik
Copy link

DLiblik commented Apr 7, 2017

This has been an issue for a long time. Between two projects on the same machine I get different outcomes, and all settings are the same. There's definitely something wrong here. I'd provide my configs, etc., but they are the same on both projects so I can't imagine how it would help.

@Glavin001
Copy link
Owner

@DLiblik if you could provide both debug.md files we could investigate. It does not make sense they would perform differently if there is no difference in configuration, however often the issue is some configuration which you did not think of which causes unexpected behaviours. For example, if I recall correctly there have been a few users who had a .editorconfig file or similar in their user home directory and it was causing conflicts. Once we have your debugging info we can narrow it down.

For this main issue, I will be investigating ways to improve configuration of Atom-Beautify over the next couple weeks. Thank you for your interest and patience!

@zamicol
Copy link

zamicol commented Apr 9, 2017

I do want to universally use tabs unless the language absolutely requires it, and would like to be able to do this programmatically via script. (See https://github.com/zamicol/dotfiles/blob/master/install.sh)

This is where I am with accomplishing it. (See https://gist.github.com/zamicol/c5c926500ddde49006122f9e4e52e48f)

In Edit -> Preferences -> "editor" tab

  1. Uncheck "Soft Tabs".
  2. Change "Tab Length" to 2.
  3. "Tab Type" to hard.

Put the following at $atom/config.cson

"atom-beautify":
	general:
		_default:
			indent_char: "\t"
			indent_size: 1
			indent_with_tabs: true
		indent_char: "\t"
		indent_size: 1
		indent_with_tabs: true
		css:
			indent_char: "\t"
			indent_size: 1
		html:
			indent_char: "\t"
			indent_size: 1
		js:
			indent_char: "\t"
			indent_size: 1
		json:
			indent_char: "\t"
			indent_size: 1
		xml:
			indent_char: "\t"
			indent_size: 1

Put this at $ATOMPATH/packages/atom-beautify/.jsbeautifyrc AND $ATOMPATH/packages/atom-beautify/src/.jsbeautifyrc.

{
	"indent_char": "	", //Tab here. Make sure editor doesn't change it. 
	"indent_size": 1,
	"indent_with_tabs": true
}

@Glavin001
Copy link
Owner

@zamicol why do you need to edit $ATOMPATH/packages/atom-beautify/.jsbeautifyrc and $ATOMPATH/packages/atom-beautify/src/.jsbeautifyrc?

See https://github.com/Glavin001/atom-beautify#configuration for configuration details.

Configure options for all languages

An example .jsbeautifyrc file using _default key meaning "apply to all languages":

{
  "_default": {
    "indent_char": "\t",
    "indent_size": 1,
    "indent_with_tabs": true
  }
}

Then languages can be specifically configured on top of this on a per-project basis.

Configure options for all projects

Place the .jsbeautifyrc file in your user's home directory.

💥 Profit! 🎆

Does that not work for you? If not, then please provide a link to a Gist with your debugging information. See https://github.com/Glavin001/atom-beautify/blob/master/docs/troubleshooting.md for details. Once we have your complete debugging information we can resolve the other issues in your way.

@Glavin001
Copy link
Owner

I've merged #1598 which should resolve these issues.

Published to v0.29.21.

@dcoferraz
Copy link

Thanks @Glavin001 !

solved my problem

@josem234
Copy link

josem234 commented Jul 3, 2020

@Glavin001 You are a fuckin master!!

I am doing a Angular App and I tried everything to indent my html files to 4 instead of 2 spaces.

The solution was to change .editorconfig file where it says "indentation" and then restart my atom editor.

Thanks!! By the way you have to work on your explaining.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests