Skip to content

Commit

Permalink
Add 'flow lsp' command
Browse files Browse the repository at this point in the history
Summary:
Our goal is for Flow to speak LSP natively.

`flow lsp` will launch an "LSP adapter". The purpose of this LSP adapter is primarily just to manage the lifetime and connection status of the Flow server.

Most LSP servers just spin up when needed, and close when needed. But Flow and Hack are different: they are singleton persistent services. So when an editor like Nuclide invokes `flow lsp`, it will launch the adapter process and speak LSP to it over stdin/stdout. The adapter process will start up a flow server if necessary, or connect to an existing one if there. It will (in a future diff) forward LSP requests to that server, and forward the responses back to the client. If ever the flow server exits (as is normal in a rebase\! or if the user types commands at the command-line) then the LSP adapter process continues to run. It will offer the user a button to click to restart the flow server, or restart it automatically. It will monitor whether the server is running, and reconnect to it as soon as it is running.

I had wanted to write `flow lsp` just as a really thin layer which basically did nothing other than forwarding LSP messages to the server. But because it has to monitor the status of the server, and clean up + restart nicely in the event of the server going down, that makes it a more heavyweight layer.

In future diffs I'll add the actual forwarding of messages to the server. Haven't got there yet.

Reviewed By: gabelevi

Differential Revision: D6508165

fbshipit-source-id: 46cb378534c9798c2b0647b51e5563801bdb8092
  • Loading branch information
ljw1004 authored and facebook-github-bot committed Mar 16, 2018
1 parent 8716051 commit c5d21c6
Show file tree
Hide file tree
Showing 3 changed files with 946 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ocp_build_flow.ocp.fb
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ begin library "flow-commands"
"tp-core"
"hh-utils"
"hh-utils-collections"
"hh-utils-filecontent"
"hh-utils-fileurl"
"hh-utils-json"
"hh-utils-jsonrpc"
"hh-utils-lsp"
"lwt"
"lwt_ppx"
]
Expand Down
Loading

0 comments on commit c5d21c6

Please sign in to comment.