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

Add Beautify on Save #5

Closed
jayrosen1576 opened this issue Mar 1, 2016 · 6 comments
Closed

Add Beautify on Save #5

jayrosen1576 opened this issue Mar 1, 2016 · 6 comments

Comments

@jayrosen1576
Copy link

I know VS Code does some beautification as text it entered into the editor but a beautify on save feature would be great for files that are opened but not changed. Can this be added to this extension or is it more suited as a feature in the main VSCode app? If it is something easy to add then it would be great to have it in your extension.

@HookyQR
Copy link
Owner

HookyQR commented Mar 2, 2016

Would you be happy with this as a mutable set of workspace setting:

//beautify all css, js, html on save/close
"beautify.beautifyOnClose": true 
// or
"beautify.beautifyOnClose":  [
  "directory/**/beautify",
  "!directory/**/not/beautify",
  "!**/*.min.js" ]
// or
"beautify.beautifyOnClose": {
  // all css
  "css": true,
  // matches 'directory/needed/to/beautify' but not 'directory/must/not/beautify'
  // and never beautifies .min.js files
  "js": [
    "directory/**/beautify",
    "!directory/**/not/beautify",
    "!**/*.min.js" ]
  // don't do html (simply leaving this out would do the same)
  "html": false
}

Using the .gitignore pattern matching (as the VS Code workspace search does). Especially the negation syntax would be useful.

I'm not so sure about beautifying on close vs on save. I would expect opening, then closing a file to have no side effect. Having a beautifyOnSave instead would simply require you to hit save, or just enter a space and let the saving (prompted, or auto) do the work.

Thoughts?

@jayrosen1576
Copy link
Author

I think just a simple beautifyOnSave for the currently focused document would suffice. this is how sublimetext/atom do it and it works well. I would have to be tied to the save function not close however, since I often want to keep the file open after it is formatted. Basically if you can invoke the "HookyQR.beautify" and then save the document when cmd+s / ctrl+s is pressed that would be excellent.

@HookyQR
Copy link
Owner

HookyQR commented Mar 13, 2016

Added functionality as requested.

Published as 0.1.0. Take a look at the readme for user settings.

It won't run if you close a dirty file from the working files list, or if you quit VS Code with a dirty file active. The required trigger function is not called during the save for these processes.

@jayrosen1576
Copy link
Author

I love it! Thanks for putting this in so quickly! Question: I use a gulp script for minify files into a public directory. The beautifyOnSave should not affect these correct? In other words, this feature is only activated when you save a file (cmd+s) within the editor window right?

@HookyQR
Copy link
Owner

HookyQR commented Mar 14, 2016

There is a beautify.onSaveIgnore setting where you can put your files/folders to be ignored. By default it will ignore all files ending in .min.*, _min.*, or -min.*. Have a look at the readme for details. If you need help setting up a glob path for you setup let me know.

@HookyQR
Copy link
Owner

HookyQR commented Mar 15, 2016

Implemented in 0.1.0

@HookyQR HookyQR closed this as completed Mar 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants