-
Notifications
You must be signed in to change notification settings - Fork 111
Use flow-language-server behind a flag #150
Conversation
Wow! That was fast :) This looks really awesome. Some things that are currently missing from the language server wrapper that would be necessary for parity with this extension today. We should decide what we're comfortable with to launch. I'd be understanding if that means parity with the existing extension.
|
Is there any update here? |
@rattrayalex unfortunately not yet, didn't have time to play with it lately 🙁 |
I'm interested in looking into this. But something that would help me jumping in would be understanding what benefits we are able to get out of this refactor. Is there new functionality with |
The benefit is smaller cost of maintenance, because lots of implementation details are handled by the language server. The drawback is the lack of proper docs on how to interact with the APIs. As for tha functionality, I think there’s still some work to do on Flow sever side |
Does this work? I tried the 'selfhost' mentioned in contributing but couldnt get it to work. The current offering for vscode flow extensions all have several major issues, would be nice to get this published somewhere so people can try it. |
I would really like to help with this PR but I'm missing knowledge about VSCode, its extensions and LSP. It would be helpful to get more info on what's need to be done as well as some guidance so I can contribute to this transition. |
@baransu huh, I'm also a newbie vscode extension dev here 😅, just wanted to play around, see if it's worth migrating (and since we could offload a lot to official flow team, it's worth it). I think you can start with official vscode docs and play around with some tutorial. Then see example of language server: https://code.visualstudio.com/docs/extensions/example-language-server (what we need here is a language client, server is implemented by Flow team) As for LSP, here are official docs https://github.com/Microsoft/language-server-protocol but I didn't find them helpful to be honest (maybe it was lack of time to get through it thoroughly?). A lot of the work done is by quick trial and error and looking up others work. What I found helpful however is e.g. ESLint plugin for vscode, which is also implemented with LSP: https://github.com/Microsoft/vscode-eslint Feel free to build on what I have here or start from scratch, whichever is easier. |
@thymikee Specification of LSP can be found here: https://microsoft.github.io/language-server-protocol/specification |
I'm trying to build a flow-languageserver vscode integration from scratch so I can learn the quirks of it without getting confused by pre-existing stuff: https://github.com/jbachhardie/vscode-flow-ls It currently runs and reports (if not very reliably) so if anyone else wants a green field sort of environment to test stuff out you can clone it. |
Webflow just made an initial donation to see this PR come to fruition. We are excited for the flow language server so the flow community can achieve the same tooling as TypeScript. @thymikee mentioned we could set a "bounty" on certain PRs. Consider #150 our target. 😄 Let us know if there's anything we can do to help move this forward! Thanks. |
Well, now I don't have any excuses to not work on this (just need to reprioritize OSS work for a while) 😅. Thanks @jslauthor for pushing this! As far as the development goes, the idea is to get this feature behind the flag and improve it incrementally until we get feature parity, then switch to LSP by default. I'm happy to get the initial step done and then I hope we'll be able to split the tasks to smaller ones, so anybody interested in getting this done could take a share out of Webflow's generous donation. |
I've made a flow-lsp branch in my clone that changes the extension to delegate to I've only tested it with a very simple JavaScript file. // @flow
function square(n: string): number {
// uncomment and Ctrl+Space here for string functions
// n.
return 5;
}
square(true); // Error!
class Animal {
talk(): void {
}
eat(): boolean {
return false;
}
}
let myInstance: Animal = new Animal();
myInstance.eat();
myInstance.talk();
// uncomment and Ctrl+Space here
// myInstance. Sometimes things are super laggy, I have no idea why. I'm pretty sure 8 seconds is too long. I don't know what other people's experiences have been in their own experiments.
|
From some more investigating, I realized that I can't drop We can't inspect the response for |
so far, all lsp-based forks I've seen do not work with multiple flow sub-projects (not multi-root, just several folders with .flowconfig). It should't be hard to support, and vscode has some examples about how to do this. I'm commenting here now to say I really hope this extension won't switch to some newer lsp based implementation until the thanks everyone making this great plugin. |
@rvion There are three ways to help with that I think.
|
Thing is I'm pretty sure Flow itself doesn't support running multiple instances of its server simultaneously so even if you did manage to get the multiple Might want to look into how flow-mono-cli does it. |
1bef1a2
to
b34cbcf
Compare
Thanks for your input @rcjsuen @rvion, I'll definitely keep that in mind (@jbachhardie nice, wish this Since this extension is the official one, we decided to expose the LSP version behind a flag ( |
Here: https://code.visualstudio.com/docs/extensions/example-language-server , you can see 3 links of lsp integration examples, 2 of them spawning multiple lsp servers: per root and per folder (what I ask to be kept). I made a quick and dirty extension some time ago based on this example spanning language servers in a for-loop with hardcoded path to my projects, it was working-ish, but I felt I was going to re-invent the wheel, and spend too much time creating a new extension while this one just work very well.
No, Flow does support running multiple instances of its servers imultaneously
so no, absolutely no performance cost
I don't think so / I would advice AGAINST. for this extension, all the pieces are alreay in the extension, I'm just asking about finding where .flowconfig are, and starting servers there. also
Sorry if I was not clear: this very extension (flowtype/flow-for-vscode) works perfectly as of now with mono-repos by starting several flow servers under the hood.
anyway, thank you very much for working on this plugin. |
also,
|
Hi, @rvion. Thank you for getting back to me.
Sorry, could you clarify this? What is not being done in the language server? The handling of one directory with multiple subdirectories that each contain its own
Yes, that is the point of that extension. To simply wrap the flow-language-server project as-is with as minimal of a configuration as possible.
I was just trying to say that "if you install that extension and your use case works then the work that is currently progressing in this pull request should also satisfy your use case". That is not to say that if your use case isn't satisfied today then it won't be satisfied tomorrow.
Just to clarify, only 1 of the 3 examples spawn multiple language servers.
On the topic of folders and workspaces, how do you start VS Code?
|
@rcjsuen I won't respond more as you're starting to pollute this thread with non relevant questions, and sidetracking discussions. I asked for an existing feature not to be removed. that's all. |
You are correct, I should've ran some tests before going on a fairly old issue in the Flow repo. So yeah it's definitely possible and could technically be done at the extension level by managing multiple languageserver instances. We definitely should be managing at least one instance per workspace folder. I might give it a shot (and put it in a PR for this repo if it works). |
11f6462
to
1add87d
Compare
Better monorepo support would be fantastic. One thing to keep in mind is that not every subfolder with a |
Just to add color the discussion but a monorepo to be more useful the a collection of project folders would have a single flowconfig for all projects. |
@orta I think this is ready to review and merge. Based on that we can iterate on adding more features like coverage or improved diagnostics as followups |
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.
Yep, changes are nice, small and atomic - I'm happy to give this a shot then.
This is shipped as 0.8.0 - glad to see it moving 👍 |
Summary
This PR aims to rewrite the plugin to use latest
flow-language-server
, implementing Language Server Protocol.It may take a while, because I'm not sure if I find enough time to make it, but hey, at least I started!
Fixes #148
cc @wbinnssmith
TODO: