Skip to content
This repository has been archived by the owner on May 28, 2020. It is now read-only.

feat: implement auto format on save #13

Merged
merged 5 commits into from
Apr 11, 2019

Conversation

axetroy
Copy link
Collaborator

@axetroy axetroy commented Mar 11, 2019

#10

What is the purpose of this pull request? (put an "X" next to item)

  • Documentation update
  • Bug fix (template)
  • New feature(template)
  • Add a config
  • Add a command
  • Add something to the plugin
  • Other, please explain:

**What changes did you make? **

@axetroy axetroy changed the title feat: auto format on save implemented [WIP] feat: auto format on save implemented Mar 11, 2019
@axetroy
Copy link
Collaborator Author

axetroy commented Mar 11, 2019

deno 的格式化也是使用 prettier 的

使用相应的包 https://github.com/denoland/deno_std/blob/master/prettier/prettier.ts

如果没有下载的话,在第一次格式化的时候下载编译,可能会花很长时间。

所以,这里就需要确定下: 要不要自动下载且编译 prettier

@axetroy axetroy changed the title [WIP] feat: auto format on save implemented [WIP] feat: implement auto format on save Mar 11, 2019
}
}
);

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahould we register languages.registerDocumentFormattingEditProvider and languages.registerDocumentRangeFormattingEditProvider instead of directly formatting it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. I will re-push soon

Copy link
Collaborator Author

@axetroy axetroy Apr 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

languages.registerDocumentFormattingEditProvider is only for formatter.

If we want to implement automatic formatting when saving.

There are 2 ways:

  1. listen on workspace.onDidSaveTextDocument and trigger format like this PR do above
  2. set build-in setting Format On Save to true and set deno formatter to default. The bad is Format On Save effect all language

@justjavac justjavac changed the title [WIP] feat: implement auto format on save feat: implement auto format on save Apr 10, 2019
@axetroy
Copy link
Collaborator Author

axetroy commented Apr 10, 2019

It's not yet for merge.

deno xxx.ts --fmt will not print the result to stdout.

Therefore, there are still some problems in integration.

waiting for this denoland/deno_std#332

@justjavac justjavac merged commit 6927e6a into justjavac:master Apr 11, 2019
justjavac added a commit that referenced this pull request Apr 11, 2019
justjavac added a commit that referenced this pull request Apr 11, 2019
@axetroy axetroy deleted the autoFmtOnSave branch January 24, 2020 15:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants