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 missing features in useLSP mode #295

Merged
merged 15 commits into from
Dec 19, 2018
Merged

Conversation

Mayank1791989
Copy link
Contributor

@Mayank1791989 Mayank1791989 commented Dec 8, 2018

Fix most of the issues listed in #243.

Changes

  • add TypeCoverage
  • add Server Status
  • add Rename
  • add stopFlowOnExit support
  • add runOnEdit partial support (only report syntax errors)
  • fix flow lint errors not showing up.
  • reimplement language-server using flow lsp (remove flow-language-server)
  • .flowconfig syntax highlighting

changes useLSP mode
- use `flow lsp` to implement language server (remove flow-language-server)
- add TypeCoverage
- add Status
- add Rename
- add `stopFlowOnExit` support
- add `runOnEdit` partial support (only report syntax errors)
@facebook-github-bot
Copy link
Contributor

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed.

If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks!

@facebook-github-bot
Copy link
Contributor

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@thymikee
Copy link
Contributor

thymikee commented Dec 8, 2018

I've tried to run this locally, but can't see flow status or an option to enable coverage (tried settings as well), also looks like the hover middleware is not kicking in, as I see text as plaintext when hovering. Is there any other special setup I need to make to test it properly?

EDIT: tested on Flow 0.81 and 0.87

@Mayank1791989
Copy link
Contributor Author

@thymikee did you compile the code?

@thymikee
Copy link
Contributor

thymikee commented Dec 8, 2018

yup, with cmd+b (got confirmation that everything was compiled by Babel)

@Mayank1791989
Copy link
Contributor Author

Remove your old build folder and run compile again. May be old flowLSP.js file present in build dir.

@thymikee
Copy link
Contributor

thymikee commented Dec 8, 2018

LOL, that worked 🤦‍♂️

@Mayank1791989
Copy link
Contributor Author

: ) We have to fix the compile script.

@Mayank1791989
Copy link
Contributor Author

Done

@thymikee
Copy link
Contributor

thymikee commented Dec 8, 2018

Works really well, thank you so much for taking that over! I could never find time to do it properly.

I guess that rename is still in early development? I got it crashed 2 times, once it worked but with a bug, and now I can't make it work (trying on latest Flow). EDIT: and now I can, welp.

cc @orta give it a spin

@Mayank1791989
Copy link
Contributor Author

Mayank1791989 commented Dec 8, 2018

Is there any error log in plugin console? For me rename works fine. Make sure you save files after renaming.

@thymikee
Copy link
Contributor

thymikee commented Dec 8, 2018

None in the extension console, but I get this output in the Panel's Output tab:

[Error - 1:31:00 PM] Request textDocument/rename failed.
  Message: Failure("Failure(\"unexpected args passed to instantiate_poly_t: AnnotT\")")
  Code: -32001 
[object Object]
[Error - 1:31:07 PM] Request textDocument/documentHighlight failed.
  Message: Failure("Failure(\"unexpected args passed to instantiate_poly_t: AnnotT\")")
  Code: -32001 
[object Object]
[Error - 1:31:11 PM] Request textDocument/completion failed.
  Message: Failure("Failure(\"unexpected args passed to instantiate_poly_t: AnnotT\")\nRaised at file \"pervasives.ml\", line 32, characters 17-33\nCalled from file \"src/typing/flow_js.ml\", line 12074, characters 21-51\nCalled from file \"src/typing/flow_js.ml\", line 12241, characters 12-34\nCalled from file \"src/typing/flow_js.ml\", line 12181, characters 25-58\nCalled from file \"src/typing/flow_js.ml\", line 12242, characters 4-24\nCalled from file \"src/server/command_handler/commandHandler.ml\", line 67, characters 21-93\nCalled from file \"src/core/lwt.ml\", line 2101, characters 16-20")
  Code: -32001 
[object Object]

Anyway, rename doesn't work for me in most cases and it's not really reproducible, seems to be happening randomly, regardless window being restarted etc.

@Mayank1791989
Copy link
Contributor Author

Which version of flow are you using? As this bug was fixed in flow 0.84 (see issue).

@thymikee
Copy link
Contributor

thymikee commented Dec 8, 2018

Oh yea, I forgot I switched to the other project with older Flow to test it as well. I got this bug on 0.81, and taking a look now, I couldn't see it in 0.87 so you're right about the fix. And rename seems to now work on 0.87 as expected now (I have no idea why it wasn't first time I tested it on this project).

@Mayank1791989
Copy link
Contributor Author

Mayank1791989 commented Dec 8, 2018

Currently the hover output doesnt look very good (using js-beautify). I will send a separate PR replacing it with prettier.

@thymikee
Copy link
Contributor

thymikee commented Dec 8, 2018

replacing it with prettier

I was about to suggest that.

@Mayank1791989
Copy link
Contributor Author

Locally I am using prettier only but not included in this PR to keep this PR small. If it's fine then I will push the commit.

@thymikee
Copy link
Contributor

thymikee commented Dec 8, 2018

How do you feel about removing the duplication in status bar? One label should be just enough

screenshot 2018-12-08 at 13 53 47

What I think makes sense is to put the coverage message the same as the status when restarting server, and make it e.g. Flow (86% coverage)

Locally I am using prettier only but not included in this PR to keep this PR small. If it's fine then I will push the commit.

Changes in yarn.lock don't really count :D

@orta
Copy link
Contributor

orta commented Dec 14, 2018

OK, cool, I'll give this a spin today 👍

@orta
Copy link
Contributor

orta commented Dec 14, 2018

This is feeling awesome! Let's get this in ASAP. IMO, feels good enough to warrant LSP being the default.

@orta
Copy link
Contributor

orta commented Dec 14, 2018

To get flow to pass, I think you'll need to add these bits of the vscode dts to the flow-typed definition in the repo, should remove most errors

changes
- add type defn for vscode-* packages
- fix flow errors
- update bundled flow to v0.75
  NOTE: this can be breaking change for users using plugin bundled flow (v0.68)
- update flow-typed defn
changes
- request coverage only if connected to server
- recompute coverage when server gets connected
  (will fix missing coverage for initial file)
@jbrown215
Copy link
Contributor

jbrown215 commented Dec 18, 2018

FWIW, flow officially recommended vscode + this plugin as the recommended way to use Flow: https://twitter.com/flowtype/status/1073258441723006981

It would be really awesome if LSP becomes the default configuration!

.flowconfig Outdated

[version]
^0.68.0
^0.75.0
Copy link
Contributor

Choose a reason for hiding this comment

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

The most recent flow version is 0.89.0. Is there a reason you don't want to use the most recent version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reason for updating to 0.75 is to avoid breaking changes to users relying on bundled flow 0.68. I was planning to use v0.89 in a separate commit. Anyways, we released v1.0 so it's fine.


dispose() {
this.statusBarItem.dispose();
this._clearTimeout();
this._command.dispose();
Copy link
Contributor

Choose a reason for hiding this comment

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

can we dispose StatusProvider as well, just not to forget about it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@thymikee Actually there is nothing in StatusProvider to dispose so I kept it this way.

Copy link
Contributor

Choose a reason for hiding this comment

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

I remember a comment about adding such in StatusProvider. Maybe worth removing it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I should remove the onStatus listener in dispose method. As provider and status component both disposes together it will not cause any issues but I will push a fix thanks.

@orta
Copy link
Contributor

orta commented Dec 19, 2018

OK, I've added a changelog entry, bumped this package to version 1.0 because this feels like the right time, and addressed the rest of the feedback in this PR

@orta
Copy link
Contributor

orta commented Dec 19, 2018

I'm gonna merge, ship and build this, and not announce for a day or two to see if any issues rain in.

It's been working fine for me in the Jest codebase, which has been a pretty good indicator for me in the past.

@orta orta merged commit bf28f0e into flow:master Dec 19, 2018
@orta
Copy link
Contributor

orta commented Dec 19, 2018

Congrats @Mayank1791989 and thanks!

@jbrown215
Copy link
Contributor

@orta and @Mayank1791989: Would one of you want to write a blog post about flow-for-vscode 1.0 and the features it supports? We could put it on the flow blog and tweet it out!

@orta
Copy link
Contributor

orta commented Dec 19, 2018

@jbrown215 that sounds like a good idea, @Mayank1791989 can you email me to say hi (my email is in my GH profile) ?

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

Successfully merging this pull request may close these issues.

6 participants