Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
figure out how to interact with persistent subprocesses like LSP servers using pantsd and the v2 engine #7079
pants runs multiple background processes with pantsd, e.g. for file watching with watchman, but this capability isn't exposed to plugins, or even anywhere else in the pants codebase. We do support
Since pantsd handles its own lifecycle and that of subprocesses, we are already doing a lot of the work necessary to support this. We mainly need to hash out the interface for such a process, and how it would interact with command-line goals. Some remaining open questions:
How to specify and invoke persistent subprocesses
After thinking about the above questions a bit, I remembered that we already have #6579, which I'm working on, which more clearly defines the pants "pailgun" extension of the nailgun protocol. I think we should almost definitely considering using the pailgun protocol directly to implement a pants wrapper around persistent subprocesses, even ones which aren't JVM tools. pailgun already handles communicating by stdin/stdout, which LSP/BSP servers are required to do .
I am seeing this plug into the v2 engine by having users who wish to create a persistent subprocess defining a
@subprocess_rule('lsp-scala', [Select(BuildFileAddresses), Select(LspOptions), Select(PersistentSubprocessFactory)]) def create_lsp_server_for_targets(addresses, options, factory): # create command line and env from options and targets yield factory.create(argv=[...], env=[...], ...)
The above is also instantly cacheable in the normal v2 model (the
How to communicate with the subprocess
LSP and BSP have a pretty well-defined protocol for messages (see links above). It doesn't seem super difficult to simply define
response = yield Get(WorkunitOutputCompleted, WorkunitOutputRequest(workunit, 'compiling x:y [3/4]', [WorkUnitLabel.MESSAGE])
This is an example of an
I'm not familiar enough with LSP or BSP yet to write more here, but this might be a first step for anyone who's interested in working on this and hopefully makes it more clear that we have ~all the pieces to proceed.