-
Notifications
You must be signed in to change notification settings - Fork 184
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
Format on save #731
Format on save #731
Conversation
I have something to say about this, but I need a little more time, so please don't merge this yet. |
It might be related to this PR or might not but I think this will not work for eslint server. I believe (after a short look at its code) that the way eslint server formats code on saving, is that it expects to get Some references: |
@rchl good to know, eslint doesn't have a formattingProvider so |
94ae88f
to
948479b
Compare
@tomv564 I'm quite intimidated by this code base and didn't have time to properly learn it. So we'll see if I get the courage. :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried this locally and it works when there haven't been recent changes to the document. When the user types a bunch of characters and then hits CTRL+S the textDocument/didChange notification is sent out too late. Interesting to see the use of view.settings() directly. The while-loop is unncessarily busy on CPUs and we can do better with a simple condition variable.
- We should use a condition variable instead of a busy while loop,
- We should send textDocument/didChange just before doing the formatting.
Good reminder from @rwols that this is the first time we introduce a regular sublime setting (at the view level) instead of an LSP setting. I didn't think much about it beyond the necessity of turning this feature on granularly (per project/syntax) - is it the best way to solve this? |
@rchl I added the |
@tomv564 It does actually work (after I've adjusted my LSP-eslint to expose setting from a correct place). Very nice, thank you for your work. :) As for the workspace/configuration changes, I guess that will be discussed separately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think much about it beyond the necessity of turning this feature on granularly (per project/syntax) - is it the best way to solve this?
There should be a description in the user docs on how to enable this at least, right?
For issue #8
Adds support for sync request (blocking the editor for up to 1 second)
Default off, enable by setting
lsp_format_on_save
to true in preferences.