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

[editor] Format the text on saved. #3338

Closed
lmcbout opened this issue Oct 30, 2018 · 6 comments
Closed

[editor] Format the text on saved. #3338

lmcbout opened this issue Oct 30, 2018 · 6 comments

Comments

@lmcbout
Copy link
Contributor

lmcbout commented Oct 30, 2018

When editing in any editors, on saved, the data inside the file should be formatted. The text should be aligned.

lmcbout added a commit that referenced this issue Nov 22, 2018
Seems to work when only reformat is selected if
there is some extra char at end of line and
re-format, then no.
Also, may need two save to reset the dirty flag,
seems the re-format occurs after and make the file dirty again.

Signed-off-by: Jacques Bouthillier <jacques.bouthillier@ericsson.com>
lmcbout added a commit that referenced this issue Nov 22, 2018
Seems to work when only reformat is selected if
there is some extra char at end of line and
re-format, then no.
Also, may need two save to reset the dirty flag,
seems the re-format occurs after and make the file dirty again.

Signed-off-by: Jacques Bouthillier <jacques.bouthillier@ericsson.com>
lmcbout added a commit that referenced this issue Nov 26, 2018
Format on Save is only available when the preference autoSave is "OFF"
and the preference 'editor.formatOnSave' is "true"

Signed-off-by: Jacques Bouthillier <jacques.bouthillier@ericsson.com>
lmcbout added a commit that referenced this issue Nov 26, 2018
Format on Save is only available when the preference autoSave is "OFF"
and the preference 'editor.formatOnSave' is "true"

Signed-off-by: Jacques Bouthillier <jacques.bouthillier@ericsson.com>
lmcbout added a commit that referenced this issue Nov 27, 2018
Format on Save is only available when the preference autoSave is "OFF"
and the preference 'editor.formatOnSave' is "true"

Signed-off-by: Jacques Bouthillier <jacques.bouthillier@ericsson.com>
lmcbout added a commit that referenced this issue Nov 27, 2018
Format on Save is only available when the preference autoSave is "OFF"
and the preference 'editor.formatOnSave' is "true"

Signed-off-by: Jacques Bouthillier <jacques.bouthillier@ericsson.com>
lmcbout added a commit that referenced this issue Dec 10, 2018
Format on Save is only available when the preference autoSave is "OFF"
and the preference 'editor.formatOnSave' is "true"

Signed-off-by: Jacques Bouthillier <jacques.bouthillier@ericsson.com>
lmcbout added a commit that referenced this issue Jan 10, 2019
Format on Save is only available when the preference autoSave is "OFF"
and the preference 'editor.formatOnSave' is "true"

Signed-off-by: Jacques Bouthillier <jacques.bouthillier@ericsson.com>
lmcbout added a commit that referenced this issue Jan 11, 2019
Format on manual Save when the preference 'editor.formatOnSave' is "true"

Signed-off-by: Jacques Bouthillier <jacques.bouthillier@ericsson.com>
@jankeromnes
Copy link
Member

Great suggestion! Having an option to do this would be nice.

This could be used for example to run Prettier on Save (but since this is opinionated, I think it should be a configuration option).

lmcbout added a commit that referenced this issue Jan 17, 2019
Format on manual Save when the preference 'editor.formatOnSave' is "true"

Signed-off-by: Jacques Bouthillier <jacques.bouthillier@ericsson.com>
@paulmelnikow
Copy link

Prettier is designed to be integrated into editors to format on save. It has many existing editor integrations.

Running it automatically on save would be a big help for Shields contributors (badges/shields#2783), and similarly for any other project using Prettier.

lmcbout added a commit that referenced this issue Jan 18, 2019
Format on manual Save when the preference 'editor.formatOnSave' is "true"

Signed-off-by: Jacques Bouthillier <jacques.bouthillier@ericsson.com>
@jankeromnes
Copy link
Member

jankeromnes commented Jan 21, 2019

Exciting! @paulmelnikow If I understand @lmcbout's pull request correctly, we "just" need to somehow hook the monaco.editor.action.formatDocument action up with Prettier for Shields, and set the editor.formatOnSave preference to true.

EDIT: I'll look into how this can be automated for Shields on Gitpod.

@jankeromnes
Copy link
Member

See also gitpod-io/gitpod#408

@sojohnnysaid
Copy link

sojohnnysaid commented Apr 3, 2020

is there a way to format with prettier on save now? Was trying:

"[javascript]": {
    "editor.formatOnSave": true
}

but not working

@jankeromnes
Copy link
Member

jankeromnes commented Apr 3, 2020

@sojohnnysaid I think you may also want to install https://github.com/prettier/prettier-vscode in Theia, e.g. by downloading a .vsix file, and by drag-and-dropping it into Theia's extension panel on the left.

EDIT: You could download it from https://open-vsx.org/extension/esbenp/prettier-vscode

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

4 participants