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

Ark: Support for JupyterLab-LSP #4192

Open
lionel- opened this issue Jul 31, 2024 · 2 comments
Open

Ark: Support for JupyterLab-LSP #4192

lionel- opened this issue Jul 31, 2024 · 2 comments
Labels
area: kernels Issues related to Jupyter kernels and LSP servers lang: r

Comments

@lionel-
Copy link
Contributor

lionel- commented Jul 31, 2024

I would have loved to show Ark completions running in Jupyter lab in our Posit::conf talk, so I looked into how this could be done in case there's an easy way to set it up. Unfortunately jupyterlab-lsp currently requires a static spec file describing how to launch the server and an stdio connection instead of TCP (see https://jupyterlab-lsp.readthedocs.io/en/latest/Configuring.html). These requirements make it too tricky to implement in short order.

For the longer term, here are the two ways I can think of for implementing this:

  1. Split the LSP from the kernel (Ark: Decouple LSP and kernel? #3180) and use a regular jupyter-lsp spec file to launch an LSP instance. This has the downside that the LSP will not be connected to the kernel and will not know about dynamic state such as variables in the global environment.

  2. Work with the jupyterlab people to formalise a Jupyter request message for which the kernel responds with a connection spec containing the arguments that allow a second instance of Ark to connect to the kernel.

The second option could work whether we have fully split the LSP from the kernel or not.

  • If we have, this LSP instance will analyse the project independently. To get updated about dynamic state after top-level commands it connects to the kernel via 0MQ and subscribes to IOPub.

  • If we haven't split the LSP from the kernel, we just use the separate Ark instance as a relay to the instance in the kernel. It would connect to the kernel LSP via TCP.

This last scenario is the one that requires the least amount of changes to Ark, but we do need jupyterlab requesting the spec from our kernel instead of using a static one.

@lionel- lionel- added lang: r area: kernels Issues related to Jupyter kernels and LSP servers labels Jul 31, 2024
@juliasilge juliasilge modified the milestones: Future, Release Candidate Jul 31, 2024
@lionel-
Copy link
Contributor Author

lionel- commented Sep 23, 2024

We should also implement support for Jupyter's complete_request: https://jupyter-client.readthedocs.io/en/stable/messaging.html#completion

The Ark handler currently returns the empty set: https://github.com/posit-dev/ark/blob/0e26941d0f8e7dffc8ce57eb5dbeedc13cf7f2ef/crates/ark/src/shell.rs#L181

@lionel-
Copy link
Contributor Author

lionel- commented Sep 23, 2024

Upstream issue: jupyter-lsp/jupyterlab-lsp#1099

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: kernels Issues related to Jupyter kernels and LSP servers lang: r
Projects
None yet
Development

No branches or pull requests

2 participants