jupyter-lsp / jupyterlab-lsp

Coding assistance for JupyterLab (code navigation + hover suggestions + linters + autocompletion + rename) using Language Server Protocol
https://jupyterlab-lsp.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.82k stars 148 forks source link

Spiking new language server #907

Open gwincr11 opened 1 year ago

gwincr11 commented 1 year ago

Hello,

I am trying to setup a new language server but I need to add some custom calls to the language server.

I believe what I need is

  1. The ability to enable, and disable a language server from the front end and check before calling.
  2. The ability to send some setup info to the language server about the environment it is in.
  3. The ability to send a get completions message.
  4. The ability to track when completions are excepted or not.

I am able to get my language server running by following the docs around the wheel entry points however I am not finding any documentation around sending custom messages. I am also happy to help contribute things with some assistance.

Thanks for the help!

krassowski commented 1 year ago

Where would you like to add these calls? In a custom JupyterLab extension? We certainly can expose API for that. If this is what you are looking for, do you have suggestions on how the API should look like?

gwincr11 commented 1 year ago

Hello! Thanks for the help!

I did a bit more digging of all the calls our LSP supports, we have 24 different calls and growing, that we need to make that are not in the spec, ideally Jupyter LSP would be extensible in a way that we could make custom calls as the LSP spec is written as such. Is this possible today?

I am working on a custom JupyterLab extension to implement these calls, I would love to have something close to a pub sub implementation. Some of the calls I am looking to make are:

set editor info:

{
  "jsonrpc": "2.0",
  "id": "1",
  "method": "setEditorInfo",
  "params": {
    "editorInfo": {
      "name": "Jupyter Lab",
      "version": "0.1"
    },
    "editorPluginInfo": {
      "name": "Test lsp",
      "version": "0.1"
    }
  }
}

Create testing context

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "testing/createContext",
  "params": {}
}

use testing token

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "testing/useTestingToken",
  "params": {
    "testingCtx": 0
  }
}

get completions:

{
  "jsonrpc": "2.0",
  "id": 4,
  "method": "getCompletions",
  "params": {
    "doc": {
      "position": {
        "line": 0,
        "character": 15
      },
      "uri": "file:///home/test/test.py",
      "version": 0
    },
    "options": {
      "testingCtx": 0
    }
  }
}

At this time I am just trying to build a spike as Jupyter is a proposed IDE to implement for our team, however if the tooling is not able to support this we may need to choose another tool to work with. Any advice on how to get Jupyter LSP to allow me to spike out custom messages to the language server would be helpful in showing that it is possible to get things working to the decision makers that be. Or any guidance on how we could extend or contribute to the project to get this working would also be helpful. I am finding the docs a bit hard to figure out, I would be happy to help improve them once I had a better understanding if that is helpful to others.

Thanks so much!

ps. If you want to talk more I can shoot you an email using your email on you GitHub account.